Changeset 29:5bcc0ef808c5 for src/mlx/gui
- Timestamp:
- 02/25/12 13:40:17 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/common.py
r28 r29 9 9 pygobject = False 10 10 import pygtk 11 import gtk.gdk as gdk 11 12 import gtk 12 13 import gobject … … 19 20 print "Using PyGObject" 20 21 pygobject = True 22 from gi.repository import Gdk as gdk 21 23 from gi.repository import Gtk as gtk 22 24 from gi.repository import GObject as gobject -
src/mlx/gui/gui.py
r28 r29 1 1 # The main file for the GUI 2 2 3 from common import * 3 from statusicon import StatusIcon 4 from mlx.gui.common import * 4 5 5 6 import mlx.const as const … … 32 33 def __init__(self): 33 34 """Construct the GUI.""" 34 35 35 gobject.threads_init() 36 36 … … 41 41 self._simulator = None 42 42 43 def build(self ):43 def build(self, iconDirectory): 44 44 """Build the GUI.""" 45 45 46 win = gtk.Window() 46 47 win.set_title("MAVA Logger X " + const.VERSION) 47 48 win.set_icon_from_file("logo.ico") 48 win.connect("delete-event", gtk.main_quit) 49 win.connect("delete-event", lambda a, b: self.hideMainWindow()) 50 win.connect("window-state-event", self._handleMainWindowState) 49 51 50 52 mainVBox = gtk.VBox() … … 62 64 logFrame.set_border_width(8) 63 65 mainVBox.pack_start(logFrame, True, True, 0) 64 66 65 67 win.show_all() 68 69 self._mainWindow = win 70 71 self._statusIcon = StatusIcon(iconDirectory, self) 66 72 67 73 def run(self): … … 93 99 gobject.idle_add(self._setData, state) 94 100 101 def _handleMainWindowState(self, window, event): 102 """Hande a change in the state of the window""" 103 iconified = gdk.WindowState.ICONIFIED if pygobject \ 104 else gdk.WINDOW_STATE_ICONIFIED 105 if (event.changed_mask&iconified)!=0 and (event.new_window_state&iconified)!=0: 106 self.hideMainWindow() 107 108 def hideMainWindow(self): 109 """Hide the main window and save its position.""" 110 (self._mainWindowX, self._mainWindowY) = \ 111 self._mainWindow.get_window().get_root_origin() 112 self._mainWindow.hide() 113 self._statusIcon.mainWindowHidden() 114 return True 115 116 def showMainWindow(self): 117 """Show the main window at its former position.""" 118 self._mainWindow.move(self._mainWindowX, self._mainWindowY) 119 self._mainWindow.deiconify() 120 self._mainWindow.show() 121 self._statusIcon.mainWindowShown() 122 123 def toggleMainWindow(self): 124 """Toggle the main window.""" 125 if self._mainWindow.get_visible(): 126 self.hideMainWindow() 127 else: 128 self.showMainWindow() 129 95 130 def _drawConnState(self, connStateArea, eventOrContext): 96 131 """Draw the connection state.""" … … 254 289 255 290 setupBox.pack_start(alignment, False, False, 8) 291 292 setupBox.pack_start(gtk.VSeparator(), False, False, 8) 293 294 self._quitButton = gtk.Button(label = "Quit") 295 self._quitButton.set_tooltip_text("Quit the program.") 296 297 self._quitButton.connect("clicked", gtk.main_quit) 298 299 setupBox.pack_start(self._quitButton, False, False, 0) 256 300 257 301 return setupFrame
Note:
See TracChangeset
for help on using the changeset viewer.