wpf - Ironpython wpf RichTextBox
问题描述
如何在 Ironpython 中检索 RichTextBox 的内容?XAML:
<RichTextBox
x:Name = "Sheet_Name"
Grid.Column="0"
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="174,62,0,0"
Width="348"
Height="476" />
这是铁蟒:
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('IronPython.Wpf')
from pyrevit import script
xamlfile = script.get_bundle_file('ui.xaml')
import wpf
from System import*
class MyWindow(Windows.Window):
def __init__(self):
wpf.LoadComponent(self, xamlfile)
def Create_Sheets(self,sender,args):
RTB = self.Sheet_Number
TR = TextRange(RTB.Document.ContentStart, RTB.Document.ContentEnd).Text
def Help(self,sender,args):
print('Help')
MyWindow().ShowDialog()
上述方法不起作用,因为未定义 TextRange。
编辑: 如果导入以下内容,则上述工作:
from System.Windows.Documents import TextRange
解决方案
推荐阅读
- c - 为什么在函数内部分配 GstBuffer 会导致 gst_buffer_add_meta 由于缓冲区不可写而失败?
- react-native - React Navigation V5 嵌套导航器有问题
- c# - .NET Core 3.0 默认路由到区域
- vba - 如何使用 VBA 运行 Outlook 的规则?
- flutter - 在水平 ListView 中,如何单独设置项目的高度?
- gcc - gcc编译器无限运行编译Hello World程序
- python - 分类神经网络不学习
- git - 如何压缩所有提交并与 master 合并并推送到 GitHub
- python-3.x - 以键为列的字典到 DataFrame
- powerbi - Power bi 中的 SUM 函数在 Visual(LINE AND STACKED COLUMN CHART)中显示错误的值,但在 CARD 中显示正确的值