我在IronPython中有一个应用程序,我用wpf加载我的xaml:“wpf.LoadComponent(.... xaml)”
我的应用程序中有一个Button和一个TextBox,当我按下按钮时,应用程序开始做2分钟的工作,我需要在此工作期间更新应用程序的文本框。 但我不能这样做。我的textBox只在2分钟工作完成时更新它。
有任何帮助吗? 谢谢
答案 0 :(得分:0)
类Window1(Window): def init (个体经营): wpf.LoadComponent(self,r' .... \ myWindow.xaml')
def execute1(self)
self.textBoxRes.Text += "\nExecuting step one -------------"
text= internalCode()
self.textBoxRes.Text += "\nEnd step 1 -------------"
return text
def execute2(self)
self.textBoxRes.Text += "\nExecuting step two-------------"
text= internalCode2()
self.textBoxRes.Text += "\nEnd step 2 -------------"
return text
def execute3(self)
self.textBoxRes.Text += "\nExecuting step three -------------"
text= internalCode3()
self.textBoxRes.Text += "\nEnd step 3 -------------"
return text
def execute4(self)
self.textBoxRes.Text += "\nExecuting step four-------------"
text= internalCode4()
self.textBoxRes.Text += "\End step 4. Result: "
return text
def Execute_Click(self, sender, e):
self.textBoxRes.Text = "Starting :"
res1= self.execute1()
if res1==0:
res2=self.execute2()
if res2==0:
res3=self.execute3()
if res3==0:
res4= self.execute4()
self.textBoxRes.Text += "Stop"
如果名称 ==' 主要': 应用()。运行(窗口1())
答案 1 :(得分:0)
让我们假设您有一个文本框,只需使用.Text
为其指定一个条目的Xaml:
<TextBox x:Name="ent" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,4,10,2"/>
IronPython代码:
self.ent = self.FindName('ent')
self.ent.Text = ....
答案 2 :(得分:0)
以下代码片段可能会对您有所帮助。
XAML:
<Label Content="" HorizontalAlignment="Left" Margin="62,163,0,0" VerticalAlignment="Top" Height="472" Width="880" Foreground="Black" FontSize="18" Background="White" x:Name="label1"/>
IronPython:
def Button_Click1(self, sender, e):
self.label1 = self.FindName('label1')
self.label1.Content = "Test Succeeded"
pass