Hi,
I’m new to python and wxpython so need some help choosing the architecture.
Bascially i have
-
A GUI which should indicate status , currently i’m just using a wxBUTTON and it’s label() and backgroundColor() methods to update the status.
-
The status button shows ‘START’ and when the user presses the start button proceed to (3)
3.3.0 change the status button to ‘SELECT Type …’
3.1 open a dialog box to ask for the type of device(which is a dialog box with buttons) and when user selects one of the dialog box proceed to (4)
4.4.0 change the status button to ‘SCANNING COM…’
4.1 I have to read a COM port which has a timeout of 5 secs and
4.2 check if proper data was read if not then change the status button to 'RE-SCAN code ’ and repeat the read (4.1) again from the COM port else proceed to (5)
5.5.0 change the status button to ‘DECODING Received Data…’
5.1 Perform some task on the properly received data from (4) and proceed to (6)
6.6.0 proceed to (3)
The user will be able to quit the loop anytime using a abort button in the GUI.
In short,
1.keep running the state machine in the thread in infinite loop and send events to GUI
2.update the GUI status button on receiving the events from state machine inside thread
3.update the state machine’s state from the GUI as GUI has to wait for user selection in the DialogBox buttons.
Putting the above statechart using wx.EVT_IDLE was very unresponsive as COM port reading was holding up the gui task
So in-order to make the GUI more responsive i have chosen to make the Task (3) to (6) in a separate thread.
and i’m facing problem with the sync between the events flowing from thread->GUI.
There should be some way to lock the state_machine running in the thread until the GUI has done some specific task say Dialog box pop up and user accepted a button in step(3.0,3.1)
the ShowModal() doesn’t seem to work as the thread would put another event which would trigger another another same Dialog box.
I’m totally confused with synchronising …!