@@ -61,11 +61,13 @@ def __init__(self, *args, **kwargs):
6161
6262 # initialize values
6363 self .version = 0.0
64+ self .app_version = "0.0"
6465 self .connected = False
6566
66- # Path
67+ # Path to where application was launched
6768 self .appdir = os .path .dirname (sys .argv [0 ])
6869 self .logger .info ('Logging is enabled' )
70+ self .logger .info ('Application launched from %s' , self .appdir )
6971
7072 # initialize config variables
7173 self .ip_address = tk .StringVar ()
@@ -78,21 +80,28 @@ def __init__(self, *args, **kwargs):
7880
7981 self .title ("BlocklyProp" )
8082
81- # Set icon
83+ # Set icon for Windows platform
8284 self .logger .info ('Operating system is %s' , os .name )
8385 if "nt" == os .name :
8486 self .wm_iconbitmap (bitmap = 'blocklyprop.ico' )
85- else :
86- #self.wm_iconbitmap(bitmap = "@myicon.xbm")
87- pass
8887
88+ # Init the system
8989 self .initialize ()
9090 self .initialize_menu ()
91- # Verify the hardware is connected and available
9291
92+ # Set the application version and app_version values
9393 def set_version (self , version ):
94- self .logger .info ('Application version is %s' , version )
95- self .version = version
94+ # The application version number was converted to a traditional 'major'.'minor'.'patch_level'
95+ # format. There is code in the BlocklyProp Javascript that expects the version number as a
96+ # float. We handle that issue here.
97+ ver_elements = VERSION .split ('.' )
98+ if len (ver_elements ) >= 2 :
99+ n_version = float (ver_elements [0 ] + '.' + ver_elements [1 ])
100+ else :
101+ n_version = 0.4
102+
103+ self .version = n_version
104+ self .app_version = version
96105
97106 def initialize (self ):
98107 self .logger .info ('Initializing the UI' )
@@ -204,17 +213,19 @@ def handle_connect(self):
204213 self .logger .info ('Connect state is: %s' , self .connected )
205214
206215 if self .connected :
216+ self .logger .debug ('Terminating server process' )
207217 BlocklyServer .stop (self .q )
208218 self .server_process .terminate ()
209219 self .connected = False
220+
221+ # Set the connect/disconnect button text to the alternate state
210222 self .btn_connect ['text' ] = "Connect"
211223 else :
212224 # read entered values and start server
213225 self .server_process = multiprocessing .Process (
214226 target = BlocklyServer .main ,
215227 args = (int (self .port .get ()), self .version , self .q ))
216228
217- # self.server_process = threading.Thread(target=BlocklyServer.main, args=(int(self.port.get()), self.version)) #, kwargs={'out':self.stdoutToQueue})
218229 self .server_process .start ()
219230
220231 self .connected = True
@@ -238,23 +249,27 @@ def handle_code_browser(self):
238249 def handle_client_code_browser (self ):
239250 webbrowser .open_new ('http://github.com/parallaxinc/BlocklyPropClient' )
240251
252+ # Open the application About dialog box
241253 def about_info (self ):
242254 try :
243255 with open (self .appdir + '/about.txt' , 'r' ) as about_file :
244256 tkMessageBox .showinfo ("About BlocklyProp" , about_file .read ())
245- except :
257+ except OSError :
246258 tkMessageBox .showinfo ("About BlocklyProp" , "About file is missing" )
247259
260+ # Open the application Quit dialog box and process user selection
248261 def handle_close (self ):
249262 self .logger .info ('Opening Quit dialog' )
250263
251264 if tkMessageBox .askokcancel ("Quit?" , "Are you sure you want to quit?" ):
252- self .logger .info ('Quitting' )
253265 # stop server if running
254266 if self .connected :
255- # BlocklyServer.stop( )
267+ self . logger . info ( 'Terminating server process' )
256268 self .server_process .terminate ()
269+
257270 self .quit ()
271+ else :
272+ self .logger .debug ('Cancelling application quit request' )
258273
259274 def text_catcher (self ):
260275 try :
@@ -268,23 +283,13 @@ def text_catcher(self):
268283 self .ent_log .yview_pickplace ("end" )
269284 self .ent_log ['state' ] = 'disabled'
270285 except EOFError :
271- print ('EOF Error' )
272- # self.logger.error('Unexpected end of file encountered')
286+ # print('EOF Error')
287+ self .logger .error ('Unexpected end of file encountered' )
273288
274289
275290if __name__ == '__main__' :
276291 multiprocessing .freeze_support ()
277292
278293 bp_client = BlocklyPropClient ()
279-
280- # The application version number was converted to a traditional 'major'.'minor'.'patch_level'
281- # format. There is code in the BlocklyProp Javascript that expects the cersion number as a
282- # float. We handle that issue here.
283- ver_elements = VERSION .split ('.' )
284- if len (ver_elements ) >= 2 :
285- n_version = float (ver_elements [0 ] + '.' + ver_elements [1 ])
286- else :
287- n_version = 0.4
288-
289- bp_client .set_version (n_version )
294+ bp_client .set_version (VERSION )
290295 bp_client .mainloop ()
0 commit comments