Hello,

I have an application with a db update dialog: a static text and two buttons. One of the button is bind with the do_update method which uses multiprocessing module to run a long task in the background. To communicate from there, I use Publisher() class. A receiver for that is set up in the Dialog, so I can receive messages from the work in the background.

But when I try to upload the StaticText Label, I get nowhere.
Could you figure out why?

Here is some code:

class DbUpdateDlg(wx.Dialog):
        """update the database"""
        def __init__(self, parent = None):
                wx.Dialog.__init__(self, parent, title="Actualizează baza de date", size=(500, 200))
                Publisher().subscribe(self.__update_txt_message, ('updatedlg', 'message'))
                ...
                txt_updatemsg = wx.StaticText(panel, 0, label=text)
                ...

        def do_update(self, e):
                self.txt_updatemsg.SetLabel("Dont stop this! \n")
                self.btn_update.Disable()
                self.btn_cancel.Disable()

                p = Process(target=self.DBob.do_update)
                p.start()
                while p.is_alive():
                        wx.GetApp().Yield(True)
                        if not p.is_alive():
                            self.btn_cancel.Enable()
        ....
        ....
        def __update_txt_message(self, message):
                self.txt_updatemsg.SetLabel(message.data)

DBob is a class in another module with do_update:

def do_update(self):
                """make the update for whole db"""
                Publisher().sendMessage(('updatedlg', 'message'), "some msg")
                wx.Sleep(5)
                return

When I run the script, I get messages in __update_txt_message but SetLabel fails!
Weird thing is that if I put a GetLabel right after SetLabel I see the new value!

Any ideas?
Thanks!

Recommended Answers

All 2 Replies

Weird thing is that if I put a GetLabel right after SetLabel I see the new value!

The combination most likely function as a Refresh(). I would just go with the combo since wx.Dialog() does not show a Refresh() method in the manual. You might have discovered a nice little secret here!

Hello vegaseat,

What do you mean by "just go with the combo" ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.