Nov-14-2017, 06:12 PM
import wx import json import queue import threading class MyDialog(wx.Frame): def __init__(self, parent, title): self.no_resize = wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX) wx.Frame.__init__(self, parent, title=title, size=(500, 450),style = self.no_resize) self.panel = wx.Panel(self, size=(250, 270)) self.emp_selection = wx.ComboBox(self.panel, -1, pos=(40, 50), size=(200,100)) self.start_read_thread() #code to load other GUI components self.Centre() self.Show(True) def read_employees(self, read_file): list_of_emails = queue.Queue() with open(read_file) as f_obj: employees = json.load(f_obj) list_of_emails = [empEmail for empEmail in employees.keys()] wx.CallAfter(self.emp_selection.Append, list_of_emails) def start_read_thread(self): filename = 'employee.json' empThread = threading.Thread(target=self.read_employees, args=(filename,)) empThread.start()I have a GUI application that loads a combobox, and starts a thread to read some data and load it into the combobox. I don't want the read to block, so that the other GUI components can load.
After calling
thread.start()
when is it appropriate to call thread.join()
? From my understanding, join()
waits for the thread to complete, I don't want that, I want to start the thread and allow all the other components to load. Is it bad practice not to call join()
?