Dear Experts:
I made one GUI interface with Tkinter. I have some buttons on the GUI and one button is designed as "start test" which will invoke one "start test" window. I put one "ok" and one "cancel" button in this window. When I click the "ok" button it will use execfile() to call another python file which will start multiple threads to run. The multiple threads did finish but I immediately got "python.exe has stopped working" error message. Do you have any suggestions? My operation system is Windows Vista with service pack 1. Looks like it is not related to OS and it could be related to my script. I attached part of my script below.
Thank you very much!
Haiyan
Related scripts in GUI side:
Related scripts in BootScript.py:
The thread class definition:
I made one GUI interface with Tkinter. I have some buttons on the GUI and one button is designed as "start test" which will invoke one "start test" window. I put one "ok" and one "cancel" button in this window. When I click the "ok" button it will use execfile() to call another python file which will start multiple threads to run. The multiple threads did finish but I immediately got "python.exe has stopped working" error message. Do you have any suggestions? My operation system is Windows Vista with service pack 1. Looks like it is not related to OS and it could be related to my script. I attached part of my script below.
Thank you very much!
Haiyan
Related scripts in GUI side:
Code:
def pressed_start_test(self): self.Start_Test_Window = Toplevel() self.Start_Test_Window.title("Start Test for Selected Slots") self.startTest_Label1 = Label( self.Start_Test_Window, text = "Start Test for Selected Slots?", width = 40, padx=5, pady=5, relief = RAISED ) self.startTest_Label1.grid( row = 0, column = 0, columnspan = 2, sticky = W+E+N+S ) self.startTest_button1 = Button( self.Start_Test_Window, text = "OK", width = 20, padx=5, pady=5, command = self.pressed_startTest_OK, font = "Arial 9 bold") self.startTest_button1.grid( row = 1, column = 0, columnspan = 1, sticky = W+E+N+S ) self.startTest_button1.bind( "<Enter>", self.rolloverEnter ) self.startTest_button1.bind( "<Leave>", self.rolloverLeave ) self.startTest_button2 = Button( self.Start_Test_Window, text = "Cancel", width = 20, padx=5, pady=5, command = self.pressed_startTest_Cancel, font = "Arial 9 bold") self.startTest_button2.grid( row = 1, column = 1, columnspan = 1, sticky = W+E+N+S ) self.startTest_button2.bind( "<Enter>", self.rolloverEnter ) self.startTest_button2.bind( "<Leave>", self.rolloverLeave ) def pressed_startTest_OK(self): valid_checked_button_list = self.get_checked_button_name() f = open('selected_slot_driveSN.list', 'w') p = pickle.Pickler(f) p.dump(valid_checked_button_list) f.close() self.Start_Test_Window.destroy() execfile("BootScript.py", globals()) def pressed_startTest_Cancel(self): self.Start_Test_Window.destroy()
Related scripts in BootScript.py:
Code:
for i in range(len(selected_slot__list)): boat_slot_thread = IOProcessThread(selected_slot__list[i][1], selected_slot__list[i][0][1]-1) # Slot Number boat_slot_thread.start() time.sleep(1) print >> PC_process_log, "Boat_%d_Slot_%d_%s started..." %(selected_slot__list[i][0][0], selected_slot__list[i][0][1], selected_slot__list[i][1])
Code:
class IOProcessThread(threading.Thread): #------------------------------------------------------------------------------------------------------- # Override Thread's __init__ method to accept the parameters needed: def __init__ ( self, SN, slot ): threading.Thread.__init__ ( self ) self.SN = SN self.slot = slot #------------------------------------------------------------------------------------------------------- def run ( self ): testStartTimeList = str(datetime.now())[0:19].split() filenametuple = (self.SN, testStartTimeList[0], testStartTimeList[1].replace(':', '.'))# File name can't have ':', so replace with '.' filename_log = '_'.join(filenametuple) + '.txt' # Souce test out file filename_csv = '_'.join(filenametuple) + '.csv' # Date only test out file for database testout_log = open(filename_log, 'w') testout_csv = open(filename_csv, 'w') stateMachine('INIT', self.slot, testout_log, testout_csv)
Comment