1111from monitors import Monitors
1212from scanner import Scanner
1313from parse import Parser
14+ import sys
1415
1516
1617class MyGLCanvas (wxcanvas .GLCanvas ):
@@ -192,7 +193,6 @@ def on_resize(self, event):
192193 x , y = self .GetViewStart ()
193194 self .canvas .SetPosition ((- x , - y ))
194195
195-
196196class Gui (wx .Frame ):
197197 """Configure the main window and all the widgets.
198198
@@ -236,7 +236,10 @@ def __init__(self, title):
236236 # File io widgets
237237 open_image = wx .ArtProvider .GetBitmap (wx .ART_FILE_OPEN , wx .ART_TOOLBAR )
238238 open_button = wx .BitmapButton (self , wx .ID_ANY , open_image )
239- fileio_sizer .Add (open_button , 0 )
239+ fileio_sizer .Add (open_button , 1 , wx .RIGHT , 5 )
240+ quit_image = wx .ArtProvider .GetBitmap (wx .ART_QUIT , wx .ART_TOOLBAR )
241+ quit_button = wx .BitmapButton (self , wx .ID_ANY , quit_image )
242+ fileio_sizer .Add (quit_button , 1 , wx .LEFT , 5 )
240243
241244 # Cycles widgets
242245 text = wx .StaticText (self , wx .ID_ANY , "Cycles:" )
@@ -264,6 +267,14 @@ def __init__(self, title):
264267 # Monitor widgets
265268 text = wx .StaticText (self , wx .ID_ANY , "Monitors" )
266269 self .lower_sizer .Add (text , 0 , wx .ALL | wx .CENTER , 10 )
270+
271+ self .monitors_sizer = wx .BoxSizer (wx .VERTICAL )
272+ self .scrolled_panel = wx .ScrolledWindow (self , style = wx .VSCROLL )
273+ self .scrolled_panel .SetScrollRate (10 , 10 )
274+ self .scrolled_panel .SetSizer (self .monitors_sizer )
275+ self .lower_sizer .Add (self .scrolled_panel , 100 , wx .EXPAND )
276+ self .monitors_sizer .Fit (self .scrolled_panel )
277+
267278 self .add_sizer = wx .BoxSizer (wx .HORIZONTAL )
268279 self .lower_sizer .Add (self .add_sizer , wx .CENTER )
269280 add_image = wx .ArtProvider .GetBitmap (wx .ART_PLUS )
@@ -274,12 +285,13 @@ def __init__(self, title):
274285
275286 # Bind events to widgets
276287 open_button .Bind (wx .EVT_BUTTON , self .OpenFile )
288+ quit_button .Bind (wx .EVT_BUTTON , self .Quit )
277289 run_button .Bind (wx .EVT_BUTTON , self .Run )
278290 cont_button .Bind (wx .EVT_BUTTON , self .Continue )
279291 add_button .Bind (wx .EVT_BUTTON , self .CreateMonitor )
280292
281293 # Set screen size
282- self .SetSizeHints (500 , 440 )
294+ self .SetSizeHints (500 , 500 )
283295 self .SetSize (600 , 600 )
284296 self .SetSizer (self .main_sizer )
285297 self .SetPosition ((100 , 100 ))
@@ -337,19 +349,20 @@ def CreateMonitor(self, event):
337349 def AddMonitor (self , signal_name ):
338350 """Add a monitor that already exists to GUI."""
339351 monitor_sizer = wx .BoxSizer (wx .HORIZONTAL )
340- pos = len (self .lower_sizer .GetChildren ()) - 1
352+ pos = len (self .monitors_sizer .GetChildren ())
341353
342- self .lower_sizer . Insert ( pos , monitor_sizer , 0 , wx .EXPAND , 0 )
354+ self .monitors_sizer . Add ( monitor_sizer , 0 , wx .EXPAND , 0 )
343355 minus_image = wx .ArtProvider .GetBitmap (wx .ART_MINUS )
344- zap_button = wx .BitmapButton (self , wx .ID_ANY , minus_image )
345- text = wx .StaticText (self , wx .ID_ANY , signal_name )
356+ zap_button = wx .BitmapButton (self . scrolled_panel , wx .ID_ANY , minus_image )
357+ text = wx .StaticText (self . scrolled_panel , wx .ID_ANY , signal_name )
346358 text .SetMinSize ((60 , - 1 ))
347359 monitor_sizer .Add (zap_button , 0 , wx .CENTER | wx .ALL , 20 )
348360 monitor_sizer .Add (text , 0 , wx .CENTER | wx .RIGHT , 10 )
349361 self .scroll_gl = ScrollableGLPanel (
350- self , signal_name , self .cycles_completed )
362+ self . scrolled_panel , signal_name , self .cycles_completed )
351363 monitor_sizer .Add (self .scroll_gl , 1 , wx .EXPAND | wx .CENTER | wx .ALL , 5 )
352364
365+ self .scrolled_panel .FitInside ()
353366 self .Layout ()
354367
355368 zap_button .Bind (wx .EVT_BUTTON ,
@@ -363,6 +376,7 @@ def ZapMonitor(self, event, pos, signal_name):
363376 if self .monitors .remove_monitor (device , port ):
364377 # Remove from GUI
365378 self .lower_sizer .GetChildren ()[pos ].DeleteWindows ()
379+ self .scrolled_panel .FitInside ()
366380 self .Layout ()
367381 else :
368382 self .Error ("Could not zap monitor." )
@@ -459,3 +473,6 @@ def Continue(self, event):
459473 def Error (self , error_msg ):
460474 """Create error box."""
461475 wx .MessageBox (error_msg , 'Error' , wx .OK | wx .ICON_ERROR )
476+
477+ def Quit (self , event ):
478+ sys .exit ()
0 commit comments