Click here to Skip to main content
14,870,673 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
So, I'm trying to make some function run without freezing the GUI. There is some way to change the text from a textblock in another thread? For example:

import wpf
import thread

from System.Windows import Application, Window

class MyWindow(Window):
    def __init__(self):
        wpf.LoadComponent(self, 'WpfApplication2.xaml')

    def setText(self):
        self.textblock.Text = "Hiiii!"

    def button_Click(self, sender, e):

if __name__ == '__main__':

and my wpf:

       Title="WpfApplication2" Height="300" Width="300"> 
           <TextBlock x:Name="textblock" Text="Oi" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" FontSize="32" TextAlignment="Center" />
        <Button x:Name="button" Content="Change" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="100" Height="50" Click="button_Click"/>


I can't in any way that I try, to change the text block in another thread. There is no way to make, for example, a infinite while loop to update data, without freezing the GUI?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900