Python Forum
Multiprocessing in wx Frame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiprocessing in wx Frame
#1
I create a GUI window by using wx Frame/Panel and make a sample with some dummy code below.
when click on Run button, it will call function_1 with 0 as parameter and get returned result.
function_1 will take 2 minutes to finish but when running, the window will freeze until done.
I'm wondering if possible to run it in anther processor or thread which is different from its parent wx.Frame by using something like multiprocessing or multithreading. so I can still work on the window while function_1 is running. Thanks.

import wx

class Frame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, title="Multiprocessing", size=(550, 550), pos = (300, 300))
        p = wx.Panel(self)
        runButton = wx.Button(self, label="Run it", pos=(200, 200))
        runButton.Bind(wx.EVT_BUTTON, self.onClick)
    def onClick(self,event):
        print('function_1 will run 2 minutes and return result.')
#       r = function_1(0)
#       function_2(r)
#   def function_1():
#       ......
#       return result
if __name__ == "__main__":
    app = wx.App()
    win = Frame()
    win.CreateStatusBar()
    win.Show()
    app.MainLoop()
Reply


Messages In This Thread
Multiprocessing in wx Frame - by ian - Aug-16-2017, 08:41 PM
RE: Multiprocessing in wx Frame - by ian - Aug-19-2017, 12:53 AM
RE: Multiprocessing in wx Frame - by snippsat - Aug-19-2017, 08:49 AM
RE: Multiprocessing in wx Frame - by ian - Aug-20-2017, 08:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Scrollbar, Frame and size of Frame Maksim 2 9,167 Sep-30-2019, 07:30 AM
Last Post: Maksim
  [Tkinter] create and insert a new frame on top of another frame atlass218 4 11,325 Apr-18-2019, 05:36 PM
Last Post: atlass218
  [Tkinter] Frame size only works if frame is empty(Solved) Tuck12173 7 6,592 Jan-29-2018, 10:44 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020