[41d466f] | 1 | |
---|
[d955bf19] | 2 | ################################################################################ |
---|
| 3 | #This software was developed by the University of Tennessee as part of the |
---|
| 4 | #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 5 | #project funded by the US National Science Foundation. |
---|
| 6 | # |
---|
| 7 | #See the license text in license.txt |
---|
| 8 | # |
---|
| 9 | #copyright 2008, University of Tennessee |
---|
| 10 | ################################################################################ |
---|
[7681bac] | 11 | |
---|
[d68c655] | 12 | |
---|
[41d466f] | 13 | import wx |
---|
| 14 | import wx.aui |
---|
[32c0841] | 15 | import os |
---|
| 16 | import sys |
---|
[b0eee0f0] | 17 | import xml |
---|
[db10f97] | 18 | |
---|
[41d466f] | 19 | try: |
---|
| 20 | # Try to find a local config |
---|
| 21 | import imp |
---|
| 22 | path = os.getcwd() |
---|
[cbb2e40] | 23 | if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \ |
---|
[32c0841] | 24 | (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))): |
---|
| 25 | fObj, path, descr = imp.find_module('local_config', [path]) |
---|
| 26 | config = imp.load_module('local_config', fObj, path, descr) |
---|
[278cc25] | 27 | else: |
---|
[cbb2e40] | 28 | # Try simply importing local_config |
---|
| 29 | import local_config as config |
---|
[41d466f] | 30 | except: |
---|
| 31 | # Didn't find local config, load the default |
---|
| 32 | import config |
---|
[4e9583c] | 33 | |
---|
| 34 | import warnings |
---|
| 35 | warnings.simplefilter("ignore") |
---|
[3c44c66] | 36 | |
---|
[4e9583c] | 37 | import logging |
---|
[32c0841] | 38 | #from sans.guicomm.events import NewLoadedDataEvent |
---|
[aebc4cc] | 39 | from sans.guicomm.events import EVT_STATUS |
---|
[32c0841] | 40 | #from sans.guicomm.events import EVT_NEW_PLOT |
---|
| 41 | #from sans.guicomm.events import EVT_SLICER_PARS_UPDATE |
---|
[aebc4cc] | 42 | from sans.guicomm.events import EVT_ADD_MANY_DATA |
---|
[32c0841] | 43 | #from data_manager import DataManager |
---|
| 44 | |
---|
| 45 | STATE_FILE_EXT = ['.inv', '.fitv', '.prv'] |
---|
[adfcab3] | 46 | |
---|
[b5ca223] | 47 | |
---|
[7681bac] | 48 | |
---|
[41d466f] | 49 | class ViewerFrame(wx.Frame): |
---|
| 50 | """ |
---|
[d955bf19] | 51 | Main application frame |
---|
[41d466f] | 52 | """ |
---|
[c9454bb] | 53 | def __init__(self, parent, id, title, window_height=300, window_width=300): |
---|
[41d466f] | 54 | """ |
---|
[d955bf19] | 55 | Initialize the Frame object |
---|
[41d466f] | 56 | """ |
---|
[b7c7a1c] | 57 | |
---|
[32c0841] | 58 | wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, |
---|
| 59 | size=(window_width, window_height)) |
---|
[d0802c3] | 60 | # Preferred window size |
---|
| 61 | self._window_height = window_height |
---|
| 62 | self._window_width = window_width |
---|
[41d466f] | 63 | |
---|
[fc2b91a] | 64 | # Logging info |
---|
| 65 | logging.basicConfig(level=logging.DEBUG, |
---|
| 66 | format='%(asctime)s %(levelname)s %(message)s', |
---|
| 67 | filename='sans_app.log', |
---|
| 68 | filemode='w') |
---|
[c44e7cc] | 69 | path = os.path.dirname(__file__) |
---|
[32c0841] | 70 | temp_path = os.path.join(path,'images') |
---|
[c44e7cc] | 71 | ico_file = os.path.join(temp_path,'ball.ico') |
---|
[278cc25] | 72 | if os.path.isfile(ico_file): |
---|
| 73 | self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO)) |
---|
[cbb2e40] | 74 | else: |
---|
[32c0841] | 75 | temp_path = os.path.join(os.getcwd(),'images') |
---|
[c44e7cc] | 76 | ico_file = os.path.join(temp_path,'ball.ico') |
---|
[cbb2e40] | 77 | if os.path.isfile(ico_file): |
---|
| 78 | self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO)) |
---|
[41d466f] | 79 | |
---|
| 80 | ## Application manager |
---|
| 81 | self.app_manager = None |
---|
[32c0841] | 82 | self._mgr = None |
---|
| 83 | self.file_menu = None |
---|
[4e9583c] | 84 | |
---|
[41d466f] | 85 | ## Find plug-ins |
---|
| 86 | # Modify this so that we can specify the directory to look into |
---|
[32c0841] | 87 | self.plugins = [] |
---|
[b7c7a1c] | 88 | #add local plugin |
---|
| 89 | |
---|
| 90 | from sans.guiframe.local_perspectives.plotting import plotting |
---|
| 91 | from sans.guiframe.local_perspectives.data_loader import data_loader |
---|
[41d466f] | 92 | self.plugins.append(plotting.Plugin()) |
---|
[b7c7a1c] | 93 | self.plugins.append(data_loader.Plugin()) |
---|
| 94 | |
---|
[a88ac04] | 95 | self.plugins += self._find_plugins() |
---|
| 96 | |
---|
[41d466f] | 97 | ## List of panels |
---|
| 98 | self.panels = {} |
---|
| 99 | |
---|
| 100 | ## Next available ID for wx gui events |
---|
[2310d69] | 101 | #TODO: No longer used - remove all calls to this |
---|
[41d466f] | 102 | self.next_id = 20000 |
---|
| 103 | |
---|
[2310d69] | 104 | # Default locations |
---|
| 105 | self._default_save_location = os.getcwd() |
---|
| 106 | |
---|
[f9e803e] | 107 | # Welcome panel |
---|
| 108 | self.defaultPanel = None |
---|
[b91c736] | 109 | #panel on focus |
---|
| 110 | self.panel_on_focus = None |
---|
[a0d56d5] | 111 | # Check for update |
---|
[af20f6b] | 112 | #self._check_update(None) |
---|
[b0eee0f0] | 113 | ## maximum number of opened files' paths to store |
---|
| 114 | self.n_maxfileopen = 2 |
---|
| 115 | ## number of file open |
---|
[32c0841] | 116 | self.n_fileOpen = 0 |
---|
[b0eee0f0] | 117 | ## list of path of open files |
---|
[32c0841] | 118 | self.filePathList = [] |
---|
[b0eee0f0] | 119 | ## list of open file with name form menu |
---|
| 120 | #self._saveOpenData() |
---|
[32c0841] | 121 | ## Dictionary of open file where keys are filename and |
---|
| 122 | # values are number of copy of data plotted |
---|
[25ccf33] | 123 | ## using the same loaded file |
---|
[32c0841] | 124 | self.indice_load_data = {} |
---|
[278cc25] | 125 | # Register the close event so it calls our own method |
---|
| 126 | wx.EVT_CLOSE(self, self._onClose) |
---|
| 127 | # Register to status events |
---|
| 128 | self.Bind(EVT_STATUS, self._on_status_event) |
---|
[b91c736] | 129 | #Register add extra data on the same panel event on load |
---|
| 130 | self.Bind(EVT_ADD_MANY_DATA, self.set_panel_on_focus) |
---|
| 131 | |
---|
| 132 | def set_panel_on_focus(self, event): |
---|
| 133 | """ |
---|
[d955bf19] | 134 | Store reference to the last panel on focus |
---|
[b91c736] | 135 | """ |
---|
| 136 | self.panel_on_focus = event.panel |
---|
[0bd2cd8] | 137 | |
---|
[278cc25] | 138 | def build_gui(self): |
---|
[d955bf19] | 139 | """ |
---|
| 140 | """ |
---|
[41d466f] | 141 | # Set up the layout |
---|
| 142 | self._setup_layout() |
---|
| 143 | |
---|
| 144 | # Set up the menu |
---|
| 145 | self._setup_menus() |
---|
[c9454bb] | 146 | #self.Fit() |
---|
[af20f6b] | 147 | #self._check_update(None) |
---|
[41d466f] | 148 | |
---|
| 149 | def _setup_layout(self): |
---|
| 150 | """ |
---|
[d955bf19] | 151 | Set up the layout |
---|
[41d466f] | 152 | """ |
---|
| 153 | # Status bar |
---|
[db10f97] | 154 | from statusbar import StatusBar |
---|
| 155 | self.sb = StatusBar(self, wx.ID_ANY) |
---|
[dd66fbd] | 156 | self.SetStatusBar(self.sb) |
---|
[41d466f] | 157 | # Add panel |
---|
| 158 | self._mgr = wx.aui.AuiManager(self) |
---|
[c9454bb] | 159 | self._mgr.SetDockSizeConstraint(0.5, 0.5) |
---|
[41d466f] | 160 | # Load panels |
---|
| 161 | self._load_panels() |
---|
| 162 | self._mgr.Update() |
---|
[db10f97] | 163 | |
---|
| 164 | def SetStatusText(self, *args, **kwds): |
---|
[d955bf19] | 165 | """ |
---|
| 166 | """ |
---|
[db10f97] | 167 | number = self.sb.get_msg_position() |
---|
| 168 | wx.Frame.SetStatusText(number=number, *args, **kwds) |
---|
| 169 | |
---|
| 170 | def PopStatusText(self, *args, **kwds): |
---|
[d955bf19] | 171 | """ |
---|
| 172 | """ |
---|
[db10f97] | 173 | field = self.sb.get_msg_position() |
---|
| 174 | wx.Frame.PopStatusText(field=field) |
---|
| 175 | |
---|
| 176 | def PushStatusText(self, *args, **kwds): |
---|
[d955bf19] | 177 | """ |
---|
| 178 | """ |
---|
[db10f97] | 179 | field = self.sb.get_msg_position() |
---|
[32c0841] | 180 | wx.Frame.PushStatusText(self, field=field, string=string) |
---|
[278cc25] | 181 | |
---|
| 182 | def add_perspective(self, plugin): |
---|
| 183 | """ |
---|
[d955bf19] | 184 | Add a perspective if it doesn't already |
---|
| 185 | exist. |
---|
[278cc25] | 186 | """ |
---|
| 187 | is_loaded = False |
---|
| 188 | for item in self.plugins: |
---|
[32c0841] | 189 | if plugin.__class__ == item.__class__: |
---|
| 190 | #print "Plugin %s already loaded" % plugin.__class__.__name__ |
---|
| 191 | is_loaded = True |
---|
[278cc25] | 192 | if not is_loaded: |
---|
| 193 | self.plugins.append(plugin) |
---|
[41d466f] | 194 | |
---|
| 195 | def _find_plugins(self, dir="perspectives"): |
---|
| 196 | """ |
---|
[d955bf19] | 197 | Find available perspective plug-ins |
---|
| 198 | |
---|
| 199 | :param dir: directory in which to look for plug-ins |
---|
| 200 | |
---|
| 201 | :return: list of plug-ins |
---|
| 202 | |
---|
[41d466f] | 203 | """ |
---|
| 204 | import imp |
---|
| 205 | plugins = [] |
---|
| 206 | # Go through files in panels directory |
---|
| 207 | try: |
---|
| 208 | list = os.listdir(dir) |
---|
[a88ac04] | 209 | ## the default panel is the panel is the last plugin added |
---|
| 210 | for item in list: |
---|
[41d466f] | 211 | toks = os.path.splitext(os.path.basename(item)) |
---|
| 212 | name = None |
---|
| 213 | if not toks[0] == '__init__': |
---|
| 214 | |
---|
[32c0841] | 215 | if toks[1] == '.py' or toks[1] == '': |
---|
[41d466f] | 216 | name = toks[0] |
---|
| 217 | |
---|
| 218 | path = [os.path.abspath(dir)] |
---|
| 219 | file = None |
---|
| 220 | try: |
---|
[32c0841] | 221 | if toks[1] == '': |
---|
[41d466f] | 222 | mod_path = '.'.join([dir, name]) |
---|
[32c0841] | 223 | module = __import__(mod_path, globals(), |
---|
| 224 | locals(), [name]) |
---|
[41d466f] | 225 | else: |
---|
| 226 | (file, path, info) = imp.find_module(name, path) |
---|
[32c0841] | 227 | module = imp.load_module( name, file, item, info) |
---|
[41d466f] | 228 | if hasattr(module, "PLUGIN_ID"): |
---|
| 229 | try: |
---|
| 230 | plugins.append(module.Plugin()) |
---|
[32c0841] | 231 | msg = "Found plug-in: %s" % module.PLUGIN_ID |
---|
| 232 | logging.info(msg) |
---|
[41d466f] | 233 | except: |
---|
[32c0841] | 234 | msg = "Error accessing PluginPanel" |
---|
| 235 | msg += " in %s\n %s" % (name, sys.exc_value) |
---|
| 236 | config.printEVT(msg) |
---|
[41d466f] | 237 | except: |
---|
[32c0841] | 238 | #print sys.exc_value |
---|
| 239 | msg = "ViewerFrame._find_plugins: %s" % sys.exc_value |
---|
| 240 | logging.error(msg) |
---|
[41d466f] | 241 | finally: |
---|
[32c0841] | 242 | if not file == None: |
---|
[41d466f] | 243 | file.close() |
---|
| 244 | except: |
---|
[32c0841] | 245 | # Should raise and catch at a higher level and |
---|
| 246 | # display error on status bar |
---|
[41d466f] | 247 | pass |
---|
| 248 | return plugins |
---|
| 249 | |
---|
[f9e803e] | 250 | def set_welcome_panel(self, panel_class): |
---|
| 251 | """ |
---|
[d955bf19] | 252 | Sets the default panel as the given welcome panel |
---|
| 253 | |
---|
| 254 | :param panel_class: class of the welcome panel to be instantiated |
---|
| 255 | |
---|
[f9e803e] | 256 | """ |
---|
[d955bf19] | 257 | self.defaultPanel = panel_class(self, -1, style=wx.RAISED_BORDER) |
---|
[b28278e] | 258 | |
---|
[41d466f] | 259 | def _load_panels(self): |
---|
| 260 | """ |
---|
[d955bf19] | 261 | Load all panels in the panels directory |
---|
[41d466f] | 262 | """ |
---|
| 263 | |
---|
| 264 | # Look for plug-in panels |
---|
[c1469ebe] | 265 | panels = [] |
---|
[41d466f] | 266 | for item in self.plugins: |
---|
| 267 | if hasattr(item, "get_panels"): |
---|
| 268 | ps = item.get_panels(self) |
---|
| 269 | panels.extend(ps) |
---|
| 270 | |
---|
| 271 | # Show a default panel with some help information |
---|
| 272 | # It also sets the size of the application windows |
---|
[c9454bb] | 273 | #TODO: Use this for slpash screen |
---|
[f9e803e] | 274 | if self.defaultPanel is None: |
---|
[32c0841] | 275 | self.defaultPanel = DefaultPanel(self, -1, style=wx.RAISED_BORDER) |
---|
[f9e803e] | 276 | |
---|
[41d466f] | 277 | self.panels["default"] = self.defaultPanel |
---|
[ca88b2e] | 278 | |
---|
[41d466f] | 279 | self._mgr.AddPane(self.defaultPanel, wx.aui.AuiPaneInfo(). |
---|
| 280 | Name("default"). |
---|
| 281 | CenterPane(). |
---|
[32c0841] | 282 | # This is where we set the size of |
---|
| 283 | # the application window |
---|
| 284 | BestSize(wx.Size(self._window_width, |
---|
| 285 | self._window_height)). |
---|
| 286 | #MinSize(wx.Size(self._window_width, |
---|
| 287 | #self._window_height)). |
---|
[41d466f] | 288 | Show()) |
---|
[6d920cd] | 289 | |
---|
[41d466f] | 290 | # Add the panels to the AUI manager |
---|
| 291 | for panel_class in panels: |
---|
| 292 | p = panel_class |
---|
| 293 | id = wx.NewId() |
---|
| 294 | |
---|
| 295 | # Check whether we need to put this panel |
---|
| 296 | # in the center pane |
---|
[6f59a98] | 297 | if hasattr(p, "CENTER_PANE") and p.CENTER_PANE: |
---|
[41d466f] | 298 | if p.CENTER_PANE: |
---|
| 299 | self.panels[str(id)] = p |
---|
| 300 | self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). |
---|
| 301 | Name(p.window_name).Caption(p.window_caption). |
---|
| 302 | CenterPane(). |
---|
[c9454bb] | 303 | #BestSize(wx.Size(550,600)). |
---|
| 304 | #MinSize(wx.Size(500,500)). |
---|
[41d466f] | 305 | Hide()) |
---|
| 306 | else: |
---|
| 307 | self.panels[str(id)] = p |
---|
| 308 | self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). |
---|
| 309 | Name(p.window_name).Caption(p.window_caption). |
---|
| 310 | Right(). |
---|
| 311 | Dock(). |
---|
| 312 | TopDockable(). |
---|
| 313 | BottomDockable(). |
---|
| 314 | LeftDockable(). |
---|
| 315 | RightDockable(). |
---|
| 316 | MinimizeButton(). |
---|
[c9454bb] | 317 | Hide()) |
---|
| 318 | #BestSize(wx.Size(550,600))) |
---|
| 319 | #MinSize(wx.Size(500,500))) |
---|
[b28278e] | 320 | |
---|
[2310d69] | 321 | def get_context_menu(self, graph=None): |
---|
[41d466f] | 322 | """ |
---|
[d955bf19] | 323 | Get the context menu items made available |
---|
| 324 | by the different plug-ins. |
---|
| 325 | This function is used by the plotting module |
---|
[41d466f] | 326 | """ |
---|
| 327 | menu_list = [] |
---|
| 328 | for item in self.plugins: |
---|
| 329 | if hasattr(item, "get_context_menu"): |
---|
[2310d69] | 330 | menu_list.extend(item.get_context_menu(graph)) |
---|
[41d466f] | 331 | return menu_list |
---|
| 332 | |
---|
| 333 | def popup_panel(self, p): |
---|
| 334 | """ |
---|
[d955bf19] | 335 | Add a panel object to the AUI manager |
---|
| 336 | |
---|
| 337 | :param p: panel object to add to the AUI manager |
---|
[41d466f] | 338 | |
---|
[d955bf19] | 339 | :return: ID of the event associated with the new panel [int] |
---|
| 340 | |
---|
| 341 | """ |
---|
[41d466f] | 342 | ID = wx.NewId() |
---|
| 343 | self.panels[str(ID)] = p |
---|
| 344 | |
---|
| 345 | count = 0 |
---|
| 346 | for item in self.panels: |
---|
[383189f9] | 347 | if self.panels[item].window_name.startswith(p.window_name): |
---|
[41d466f] | 348 | count += 1 |
---|
| 349 | windowname = p.window_name |
---|
| 350 | caption = p.window_caption |
---|
[32c0841] | 351 | if count > 0: |
---|
[41d466f] | 352 | windowname += str(count+1) |
---|
| 353 | caption += (' '+str(count)) |
---|
| 354 | p.window_name = windowname |
---|
| 355 | p.window_caption = caption |
---|
| 356 | |
---|
| 357 | self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). |
---|
| 358 | Name(windowname).Caption(caption). |
---|
| 359 | Floatable(). |
---|
| 360 | #Float(). |
---|
| 361 | Right(). |
---|
| 362 | Dock(). |
---|
| 363 | TopDockable(). |
---|
| 364 | BottomDockable(). |
---|
| 365 | LeftDockable(). |
---|
| 366 | RightDockable(). |
---|
| 367 | MinimizeButton(). |
---|
| 368 | #Hide(). |
---|
| 369 | #Show(). |
---|
[c9454bb] | 370 | Resizable(True). |
---|
| 371 | # Use a large best size to make sure the AUI manager |
---|
| 372 | # takes all the available space |
---|
[6ab0ad1] | 373 | BestSize(wx.Size(400,400))) |
---|
[d0802c3] | 374 | pane = self._mgr.GetPane(windowname) |
---|
| 375 | self._mgr.MaximizePane(pane) |
---|
| 376 | self._mgr.RestoreMaximizedPane() |
---|
[41d466f] | 377 | # Register for showing/hiding the panel |
---|
| 378 | wx.EVT_MENU(self, ID, self._on_view) |
---|
| 379 | |
---|
| 380 | self._mgr.Update() |
---|
| 381 | return ID |
---|
| 382 | |
---|
[b7c7a1c] | 383 | def _populate_file_menu(self): |
---|
| 384 | """ |
---|
| 385 | Insert menu item under file menu |
---|
| 386 | """ |
---|
| 387 | for plugin in self.plugins: |
---|
| 388 | if len(plugin.populate_file_menu()) > 0: |
---|
[df23f90] | 389 | |
---|
[b7c7a1c] | 390 | for item in plugin.populate_file_menu(): |
---|
| 391 | m_name, m_hint, m_handler = item |
---|
[df23f90] | 392 | id = wx.NewId() |
---|
[b7c7a1c] | 393 | self.filemenu.Append(id, m_name, m_hint) |
---|
| 394 | wx.EVT_MENU(self, id, m_handler) |
---|
| 395 | self.filemenu.AppendSeparator() |
---|
| 396 | |
---|
[41d466f] | 397 | def _setup_menus(self): |
---|
| 398 | """ |
---|
[d955bf19] | 399 | Set up the application menus |
---|
[41d466f] | 400 | """ |
---|
| 401 | # Menu |
---|
[b7c7a1c] | 402 | self._menubar = wx.MenuBar() |
---|
[41d466f] | 403 | # File menu |
---|
[b0eee0f0] | 404 | self.filemenu = wx.Menu() |
---|
[fc2b91a] | 405 | |
---|
[b7c7a1c] | 406 | # some menu of plugin to be seen under file menu |
---|
| 407 | self._populate_file_menu() |
---|
[ca88b2e] | 408 | id = wx.NewId() |
---|
[32c0841] | 409 | self.filemenu.Append(id, '&Save', |
---|
| 410 | 'Save project as a SanaView (svs) file') |
---|
[b35d3d1] | 411 | wx.EVT_MENU(self, id, self._on_save) |
---|
| 412 | #self.filemenu.AppendSeparator() |
---|
| 413 | |
---|
| 414 | id = wx.NewId() |
---|
[32c0841] | 415 | self.filemenu.Append(id, '&Quit', 'Exit') |
---|
[fc2b91a] | 416 | wx.EVT_MENU(self, id, self.Close) |
---|
[41d466f] | 417 | |
---|
[adfcab3] | 418 | # Add sub menus |
---|
[b7c7a1c] | 419 | self._menubar.Append(self.filemenu, '&File') |
---|
[adfcab3] | 420 | |
---|
[6f59a98] | 421 | # Window menu |
---|
[41d466f] | 422 | # Attach a menu item for each panel in our |
---|
| 423 | # panel list that also appears in a plug-in. |
---|
| 424 | |
---|
[6f59a98] | 425 | # Only add the panel menu if there is only one perspective and |
---|
| 426 | # it has more than two panels. |
---|
[32c0841] | 427 | # Note: the first plug-in is always the plotting plug-in. |
---|
| 428 | #The first application |
---|
[6f59a98] | 429 | # plug-in is always the second one in the list. |
---|
[32c0841] | 430 | if len(self.plugins) == 2: |
---|
[6f59a98] | 431 | plug = self.plugins[1] |
---|
[41d466f] | 432 | pers = plug.get_perspective() |
---|
[0d9dae8] | 433 | |
---|
[32c0841] | 434 | if len(pers) > 1: |
---|
[6f59a98] | 435 | viewmenu = wx.Menu() |
---|
| 436 | for item in self.panels: |
---|
| 437 | if item == 'default': |
---|
| 438 | continue |
---|
| 439 | panel = self.panels[item] |
---|
| 440 | if panel.window_name in pers: |
---|
[32c0841] | 441 | viewmenu.Append(int(item), panel.window_caption, |
---|
| 442 | "Show %s window" % panel.window_caption) |
---|
[6f59a98] | 443 | wx.EVT_MENU(self, int(item), self._on_view) |
---|
[b7c7a1c] | 444 | self._menubar.Append(viewmenu, '&Window') |
---|
[adfcab3] | 445 | |
---|
[41d466f] | 446 | # Perspective |
---|
| 447 | # Attach a menu item for each defined perspective. |
---|
[d68c655] | 448 | # Only add the perspective menu if there are more than one perspectives |
---|
[adfcab3] | 449 | n_perspectives = 0 |
---|
[41d466f] | 450 | for plug in self.plugins: |
---|
| 451 | if len(plug.get_perspective()) > 0: |
---|
[adfcab3] | 452 | n_perspectives += 1 |
---|
| 453 | |
---|
[32c0841] | 454 | if n_perspectives > 1: |
---|
[adfcab3] | 455 | p_menu = wx.Menu() |
---|
| 456 | for plug in self.plugins: |
---|
| 457 | if len(plug.get_perspective()) > 0: |
---|
| 458 | id = wx.NewId() |
---|
[32c0841] | 459 | p_menu.Append(id, plug.sub_menu, |
---|
| 460 | "Switch to %s perspective" % plug.sub_menu) |
---|
[adfcab3] | 461 | wx.EVT_MENU(self, id, plug.on_perspective) |
---|
[b7c7a1c] | 462 | self._menubar.Append(p_menu, '&Perspective') |
---|
[4e9583c] | 463 | |
---|
[d68c655] | 464 | # Tools menu |
---|
| 465 | # Go through plug-ins and find tools to populate the tools menu |
---|
| 466 | toolsmenu = None |
---|
| 467 | for item in self.plugins: |
---|
| 468 | if hasattr(item, "get_tools"): |
---|
| 469 | for tool in item.get_tools(): |
---|
| 470 | # Only create a menu if we have at least one tool |
---|
| 471 | if toolsmenu is None: |
---|
| 472 | toolsmenu = wx.Menu() |
---|
| 473 | id = wx.NewId() |
---|
| 474 | toolsmenu.Append(id, tool[0], tool[1]) |
---|
| 475 | wx.EVT_MENU(self, id, tool[2]) |
---|
| 476 | if toolsmenu is not None: |
---|
[b7c7a1c] | 477 | self._menubar.Append(toolsmenu, '&Tools') |
---|
[d68c655] | 478 | |
---|
[41d466f] | 479 | # Help menu |
---|
| 480 | helpmenu = wx.Menu() |
---|
[c1469ebe] | 481 | # add the welcome panel menu item |
---|
[629e8b9] | 482 | if self.defaultPanel is not None: |
---|
| 483 | id = wx.NewId() |
---|
[32c0841] | 484 | helpmenu.Append(id, '&Welcome', '') |
---|
[629e8b9] | 485 | helpmenu.AppendSeparator() |
---|
| 486 | wx.EVT_MENU(self, id, self.show_welcome_panel) |
---|
[fa452e4] | 487 | # Look for help item in plug-ins |
---|
| 488 | for item in self.plugins: |
---|
| 489 | if hasattr(item, "help"): |
---|
| 490 | id = wx.NewId() |
---|
| 491 | helpmenu.Append(id,'&%s help' % item.sub_menu, '') |
---|
| 492 | wx.EVT_MENU(self, id, item.help) |
---|
[41d466f] | 493 | if config._do_aboutbox: |
---|
| 494 | id = wx.NewId() |
---|
| 495 | helpmenu.Append(id,'&About', 'Software information') |
---|
| 496 | wx.EVT_MENU(self, id, self._onAbout) |
---|
[af20f6b] | 497 | |
---|
| 498 | # Checking for updates needs major refactoring to work with py2exe |
---|
| 499 | # We need to make sure it doesn't hang the application if the server |
---|
| 500 | # is not up. We also need to make sure there's a proper executable to |
---|
| 501 | # run if we spawn a new background process. |
---|
| 502 | #id = wx.NewId() |
---|
[32c0841] | 503 | #helpmenu.Append(id,'&Check for update', |
---|
| 504 | #'Check for the latest version of %s' % config.__appname__) |
---|
[af20f6b] | 505 | #wx.EVT_MENU(self, id, self._check_update) |
---|
[41d466f] | 506 | |
---|
| 507 | # Look for plug-in menus |
---|
| 508 | # Add available plug-in sub-menus. |
---|
| 509 | for item in self.plugins: |
---|
| 510 | if hasattr(item, "populate_menu"): |
---|
[32c0841] | 511 | for (self.next_id, menu, name) in \ |
---|
| 512 | item.populate_menu(self.next_id, self): |
---|
[b7c7a1c] | 513 | self._menubar.Append(menu, name) |
---|
[0d9dae8] | 514 | |
---|
[b7c7a1c] | 515 | self._menubar.Append(helpmenu, '&Help') |
---|
| 516 | self.SetMenuBar(self._menubar) |
---|
[d955bf19] | 517 | |
---|
[41d466f] | 518 | def _on_status_event(self, evt): |
---|
| 519 | """ |
---|
[d955bf19] | 520 | Display status message |
---|
[41d466f] | 521 | """ |
---|
[db10f97] | 522 | self.sb.set_status(event=evt) |
---|
[dd66fbd] | 523 | |
---|
[41d466f] | 524 | def _on_view(self, evt): |
---|
| 525 | """ |
---|
[d955bf19] | 526 | A panel was selected to be shown. If it's not already |
---|
| 527 | shown, display it. |
---|
| 528 | |
---|
| 529 | :param evt: menu event |
---|
| 530 | |
---|
[41d466f] | 531 | """ |
---|
| 532 | self.show_panel(evt.GetId()) |
---|
[c1469ebe] | 533 | |
---|
[b28278e] | 534 | def on_close_welcome_panel(self): |
---|
[c1469ebe] | 535 | """ |
---|
[d955bf19] | 536 | Close the welcome panel |
---|
[c1469ebe] | 537 | """ |
---|
[629e8b9] | 538 | if self.defaultPanel is None: |
---|
| 539 | return |
---|
[c1469ebe] | 540 | self._mgr.GetPane(self.panels["default"].window_name).Hide() |
---|
| 541 | self._mgr.Update() |
---|
[b28278e] | 542 | # set a default perspective |
---|
| 543 | self.set_default_perspective() |
---|
[c1469ebe] | 544 | |
---|
| 545 | def show_welcome_panel(self, event): |
---|
| 546 | """ |
---|
[d955bf19] | 547 | Display the welcome panel |
---|
[c1469ebe] | 548 | """ |
---|
[629e8b9] | 549 | if self.defaultPanel is None: |
---|
| 550 | return |
---|
[c1469ebe] | 551 | for id in self.panels.keys(): |
---|
| 552 | if self._mgr.GetPane(self.panels[id].window_name).IsShown(): |
---|
| 553 | self._mgr.GetPane(self.panels[id].window_name).Hide() |
---|
| 554 | # Show default panel |
---|
| 555 | if not self._mgr.GetPane(self.panels["default"].window_name).IsShown(): |
---|
| 556 | self._mgr.GetPane(self.panels["default"].window_name).Show() |
---|
| 557 | |
---|
| 558 | self._mgr.Update() |
---|
| 559 | |
---|
[41d466f] | 560 | def show_panel(self, uid): |
---|
| 561 | """ |
---|
[d955bf19] | 562 | Shows the panel with the given id |
---|
| 563 | |
---|
| 564 | :param uid: unique ID number of the panel to show |
---|
| 565 | |
---|
[41d466f] | 566 | """ |
---|
| 567 | ID = str(uid) |
---|
| 568 | config.printEVT("show_panel: %s" % ID) |
---|
| 569 | if ID in self.panels.keys(): |
---|
| 570 | if not self._mgr.GetPane(self.panels[ID].window_name).IsShown(): |
---|
| 571 | self._mgr.GetPane(self.panels[ID].window_name).Show() |
---|
[383189f9] | 572 | # Hide default panel |
---|
| 573 | self._mgr.GetPane(self.panels["default"].window_name).Hide() |
---|
[41d466f] | 574 | self._mgr.Update() |
---|
[4e9583c] | 575 | |
---|
| 576 | def _on_open(self, event): |
---|
[b3644f3] | 577 | """ |
---|
| 578 | """ |
---|
[fc2b91a] | 579 | path = self.choose_file() |
---|
[4e9583c] | 580 | if path is None: |
---|
[700f9b4] | 581 | return |
---|
[b3644f3] | 582 | |
---|
[4e9583c] | 583 | from data_loader import plot_data |
---|
[9b18735] | 584 | from sans.perspectives import invariant |
---|
[4e9583c] | 585 | if path and os.path.isfile(path): |
---|
[32c0841] | 586 | basename = os.path.basename(path) |
---|
| 587 | if basename.endswith('.svs'): |
---|
| 588 | #remove panels for new states |
---|
[7a07864] | 589 | for item in self.panels: |
---|
| 590 | try: |
---|
| 591 | self.panels[item].clear_panel() |
---|
[32c0841] | 592 | except: |
---|
| 593 | pass |
---|
[7a07864] | 594 | #reset states and plot data |
---|
| 595 | for item in STATE_FILE_EXT: |
---|
[32c0841] | 596 | exec "plot_data(self, path,'%s')" % str(item) |
---|
| 597 | else: |
---|
| 598 | plot_data(self, path) |
---|
[aebc4cc] | 599 | if self.defaultPanel is not None and \ |
---|
| 600 | self._mgr.GetPane(self.panels["default"].window_name).IsShown(): |
---|
| 601 | self.on_close_welcome_panel() |
---|
[df23f90] | 602 | |
---|
[b35d3d1] | 603 | |
---|
| 604 | def _on_save(self, event): |
---|
| 605 | """ |
---|
| 606 | Save state into a file |
---|
| 607 | """ |
---|
| 608 | # Ask the user the location of the file to write to. |
---|
| 609 | |
---|
| 610 | ## Default file location for save |
---|
| 611 | self._default_save_location = os.getcwd() |
---|
| 612 | path = None |
---|
[32c0841] | 613 | dlg = wx.FileDialog(self, "Choose a file", |
---|
| 614 | self._default_save_location, "", "*.svs", wx.SAVE) |
---|
[b35d3d1] | 615 | if dlg.ShowModal() == wx.ID_OK: |
---|
| 616 | path = dlg.GetPath() |
---|
| 617 | self._default_save_location = os.path.dirname(path) |
---|
| 618 | else: |
---|
| 619 | return None |
---|
| 620 | dlg.Destroy() |
---|
| 621 | if path is None: |
---|
| 622 | return |
---|
| 623 | # default cansas xml doc |
---|
| 624 | doc = None |
---|
| 625 | for item in self.panels: |
---|
| 626 | try: |
---|
[7a07864] | 627 | if self.panels[item].window_name == 'Invariant': |
---|
| 628 | data = self.panels[item]._data |
---|
| 629 | if data != None: |
---|
| 630 | state = self.panels[item].state |
---|
[32c0841] | 631 | manager = self.panels[item]._manager |
---|
| 632 | new_doc = manager.state_reader.write_toXML(data, state) |
---|
[7a07864] | 633 | if hasattr(doc, "firstChild"): |
---|
[32c0841] | 634 | child = new_doc.firstChild.firstChild |
---|
| 635 | doc.firstChild.appendChild(child) |
---|
[7a07864] | 636 | else: |
---|
| 637 | doc = new_doc |
---|
| 638 | elif self.panels[item].window_name == 'pr_control': |
---|
| 639 | data = self.panels[item].manager.current_plottable |
---|
| 640 | if data != None: |
---|
| 641 | state = self.panels[item].get_state() |
---|
[32c0841] | 642 | manager = self.panels[item].manager |
---|
| 643 | new_doc = manager.state_reader.write_toXML(data, state) |
---|
[7a07864] | 644 | if hasattr(doc, "firstChild"): |
---|
[32c0841] | 645 | child = new_doc.firstChild.firstChild |
---|
| 646 | doc.firstChild.appendChild(child) |
---|
[7a07864] | 647 | else: |
---|
| 648 | doc = new_doc |
---|
| 649 | elif self.panels[item].window_name == 'Fit panel': |
---|
| 650 | for index in range(self.panels[item].GetPageCount()): |
---|
| 651 | selected_page = self.panels[item].GetPage(index) |
---|
| 652 | if hasattr(selected_page,"get_data"): |
---|
| 653 | data = selected_page.get_data() |
---|
| 654 | state = selected_page.state |
---|
[32c0841] | 655 | reader = selected_page.manager.state_reader |
---|
| 656 | new_doc = reader.write_toXML(data, state) |
---|
[7a07864] | 657 | if doc != None and hasattr(doc, "firstChild"): |
---|
[32c0841] | 658 | child = new_doc.firstChild.firstChild |
---|
| 659 | doc.firstChild.appendChild(child) |
---|
[028a0e8] | 660 | else: |
---|
[7a07864] | 661 | doc = new_doc |
---|
[b35d3d1] | 662 | except: |
---|
| 663 | pass |
---|
| 664 | # Write the XML document |
---|
| 665 | if doc != None: |
---|
| 666 | fd = open(path, 'w') |
---|
| 667 | fd.write(doc.toprettyxml()) |
---|
| 668 | fd.close() |
---|
| 669 | else: |
---|
[32c0841] | 670 | #print "Nothing to save..." |
---|
[b35d3d1] | 671 | raise RuntimeError, "%s is not a SansView (.svs) file..." % path |
---|
| 672 | |
---|
[41d466f] | 673 | def _onClose(self, event): |
---|
[b0eee0f0] | 674 | """ |
---|
[d955bf19] | 675 | Store info to retrieve in xml before closing the application |
---|
[b0eee0f0] | 676 | """ |
---|
[41d466f] | 677 | wx.Exit() |
---|
| 678 | sys.exit() |
---|
[b5ca223] | 679 | |
---|
| 680 | def quit_guiframe(self): |
---|
| 681 | """ |
---|
| 682 | Pop up message to make sure the user wants to quit the application |
---|
| 683 | """ |
---|
| 684 | message = "Do you really want to quit \n" |
---|
| 685 | message += "this application?" |
---|
| 686 | dial = wx.MessageDialog(self, message, 'Question', |
---|
| 687 | wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION) |
---|
| 688 | if dial.ShowModal() == wx.ID_YES: |
---|
| 689 | return True |
---|
| 690 | else: |
---|
| 691 | return False |
---|
| 692 | |
---|
[41d466f] | 693 | def Close(self, event=None): |
---|
| 694 | """ |
---|
[d955bf19] | 695 | Quit the application |
---|
[41d466f] | 696 | """ |
---|
[b5ca223] | 697 | flag = self.quit_guiframe() |
---|
[ba535a6] | 698 | if flag: |
---|
[32c0841] | 699 | #import sys |
---|
[ba535a6] | 700 | wx.Frame.Close(self) |
---|
| 701 | wx.Exit() |
---|
| 702 | sys.exit() |
---|
[41d466f] | 703 | |
---|
| 704 | def _check_update(self, event=None): |
---|
| 705 | """ |
---|
[d955bf19] | 706 | Check with the deployment server whether a new version |
---|
| 707 | of the application is available. |
---|
| 708 | A thread is started for the connecting with the server. The thread calls |
---|
| 709 | a call-back method when the current version number has been obtained. |
---|
[52070a1] | 710 | """ |
---|
[d68c655] | 711 | if hasattr(config, "__update_URL__"): |
---|
| 712 | import version |
---|
[32c0841] | 713 | checker = version.VersionThread(config.__update_URL__, |
---|
| 714 | self._process_version, |
---|
| 715 | baggage=event==None) |
---|
[d68c655] | 716 | checker.start() |
---|
[52070a1] | 717 | |
---|
| 718 | def _process_version(self, version, standalone=True): |
---|
| 719 | """ |
---|
[d955bf19] | 720 | Call-back method for the process of checking for updates. |
---|
| 721 | This methods is called by a VersionThread object once the current |
---|
| 722 | version number has been obtained. If the check is being done in the |
---|
| 723 | background, the user will not be notified unless there's an update. |
---|
| 724 | |
---|
| 725 | :param version: version string |
---|
| 726 | :param standalone: True of the update is being checked in |
---|
| 727 | the background, False otherwise. |
---|
| 728 | |
---|
[52070a1] | 729 | """ |
---|
| 730 | try: |
---|
[32c0841] | 731 | if cmp(version, config.__version__) > 0: |
---|
| 732 | msg = "Version %s is available! See the Help " |
---|
| 733 | msg += "menu to download it." % version |
---|
| 734 | self.SetStatusText(msg) |
---|
[52070a1] | 735 | if not standalone: |
---|
| 736 | import webbrowser |
---|
| 737 | webbrowser.open(config.__download_page__) |
---|
| 738 | else: |
---|
| 739 | if not standalone: |
---|
[32c0841] | 740 | msg = "You have the latest version" |
---|
| 741 | msg += " of %s" % config.__appname__ |
---|
| 742 | self.SetStatusText(msg) |
---|
[41d466f] | 743 | except: |
---|
[32c0841] | 744 | msg = "guiframe: could not get latest application" |
---|
| 745 | msg += " version number\n %s" % sys.exc_value |
---|
| 746 | logging.error(msg) |
---|
[52070a1] | 747 | if not standalone: |
---|
[32c0841] | 748 | msg = "Could not connect to the application server." |
---|
| 749 | msg += " Please try again later." |
---|
| 750 | self.SetStatusText(msg) |
---|
[52070a1] | 751 | |
---|
[41d466f] | 752 | def _onAbout(self, evt): |
---|
| 753 | """ |
---|
[d955bf19] | 754 | Pop up the about dialog |
---|
| 755 | |
---|
| 756 | :param evt: menu event |
---|
| 757 | |
---|
[41d466f] | 758 | """ |
---|
| 759 | if config._do_aboutbox: |
---|
| 760 | import aboutbox |
---|
| 761 | dialog = aboutbox.DialogAbout(None, -1, "") |
---|
[6ab0ad1] | 762 | dialog.ShowModal() |
---|
[4e9583c] | 763 | |
---|
| 764 | def _onreloaFile(self, event): |
---|
| 765 | """ |
---|
| 766 | load a data previously opened |
---|
| 767 | """ |
---|
[32c0841] | 768 | from .data_loader import plot_data |
---|
[4e9583c] | 769 | for item in self.filePathList: |
---|
[32c0841] | 770 | id, _, path, _ = item |
---|
[4e9583c] | 771 | if id == event.GetId(): |
---|
| 772 | if path and os.path.isfile(path): |
---|
| 773 | plot_data(self, path) |
---|
| 774 | break |
---|
| 775 | |
---|
[41d466f] | 776 | def set_manager(self, manager): |
---|
| 777 | """ |
---|
[d955bf19] | 778 | Sets the application manager for this frame |
---|
| 779 | |
---|
| 780 | :param manager: frame manager |
---|
[41d466f] | 781 | """ |
---|
| 782 | self.app_manager = manager |
---|
| 783 | |
---|
| 784 | def post_init(self): |
---|
| 785 | """ |
---|
[d955bf19] | 786 | This initialization method is called after the GUI |
---|
| 787 | has been created and all plug-ins loaded. It calls |
---|
| 788 | the post_init() method of each plug-in (if it exists) |
---|
| 789 | so that final initialization can be done. |
---|
[41d466f] | 790 | """ |
---|
| 791 | for item in self.plugins: |
---|
| 792 | if hasattr(item, "post_init"): |
---|
| 793 | item.post_init() |
---|
| 794 | |
---|
[b28278e] | 795 | def set_default_perspective(self): |
---|
| 796 | """ |
---|
[d955bf19] | 797 | Choose among the plugin the first plug-in that has |
---|
| 798 | "set_default_perspective" method and its return value is True will be |
---|
| 799 | as a default perspective when the welcome page is closed |
---|
[b28278e] | 800 | """ |
---|
| 801 | for item in self.plugins: |
---|
| 802 | if hasattr(item, "set_default_perspective"): |
---|
| 803 | if item.set_default_perspective(): |
---|
| 804 | item.on_perspective(event=None) |
---|
| 805 | return |
---|
| 806 | |
---|
[41d466f] | 807 | def set_perspective(self, panels): |
---|
| 808 | """ |
---|
[d955bf19] | 809 | Sets the perspective of the GUI. |
---|
| 810 | Opens all the panels in the list, and closes |
---|
| 811 | all the others. |
---|
| 812 | |
---|
| 813 | :param panels: list of panels |
---|
[41d466f] | 814 | """ |
---|
| 815 | for item in self.panels: |
---|
| 816 | # Check whether this is a sticky panel |
---|
| 817 | if hasattr(self.panels[item], "ALWAYS_ON"): |
---|
| 818 | if self.panels[item].ALWAYS_ON: |
---|
| 819 | continue |
---|
| 820 | if self.panels[item].window_name in panels: |
---|
| 821 | if not self._mgr.GetPane(self.panels[item].window_name).IsShown(): |
---|
| 822 | self._mgr.GetPane(self.panels[item].window_name).Show() |
---|
| 823 | else: |
---|
| 824 | if self._mgr.GetPane(self.panels[item].window_name).IsShown(): |
---|
| 825 | self._mgr.GetPane(self.panels[item].window_name).Hide() |
---|
| 826 | self._mgr.Update() |
---|
[4e9583c] | 827 | |
---|
| 828 | def choose_file(self, path=None): |
---|
[41d466f] | 829 | """ |
---|
[d955bf19] | 830 | Functionality that belongs elsewhere |
---|
| 831 | Should add a hook to specify the preferred file type/extension. |
---|
[41d466f] | 832 | """ |
---|
[4e9583c] | 833 | #TODO: clean this up |
---|
[32c0841] | 834 | from .data_loader import choose_data_file |
---|
[8068b52] | 835 | # Choose a file path |
---|
[32c0841] | 836 | if path == None: |
---|
[4e9583c] | 837 | path = choose_data_file(self, self._default_save_location) |
---|
[32c0841] | 838 | if not path == None: |
---|
[2310d69] | 839 | try: |
---|
[4e9583c] | 840 | self._default_save_location = os.path.dirname(path) |
---|
[2310d69] | 841 | except: |
---|
[83ee3851] | 842 | pass |
---|
[2310d69] | 843 | return path |
---|
[b7c7a1c] | 844 | |
---|
[41d466f] | 845 | class DefaultPanel(wx.Panel): |
---|
| 846 | """ |
---|
[d955bf19] | 847 | Defines the API for a panels to work with |
---|
| 848 | the GUI manager |
---|
[41d466f] | 849 | """ |
---|
| 850 | ## Internal nickname for the window, used by the AUI manager |
---|
| 851 | window_name = "default" |
---|
| 852 | ## Name to appear on the window title bar |
---|
| 853 | window_caption = "Welcome panel" |
---|
| 854 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
| 855 | CENTER_PANE = True |
---|
| 856 | |
---|
| 857 | |
---|
| 858 | # Toy application to test this Frame |
---|
| 859 | class ViewApp(wx.App): |
---|
[d955bf19] | 860 | """ |
---|
| 861 | """ |
---|
[41d466f] | 862 | def OnInit(self): |
---|
[d955bf19] | 863 | """ |
---|
| 864 | """ |
---|
[41d466f] | 865 | self.frame = ViewerFrame(None, -1, config.__appname__) |
---|
| 866 | self.frame.Show(True) |
---|
| 867 | |
---|
| 868 | if hasattr(self.frame, 'special'): |
---|
| 869 | self.frame.special.SetCurrent() |
---|
| 870 | self.SetTopWindow(self.frame) |
---|
| 871 | return True |
---|
| 872 | |
---|
| 873 | def set_manager(self, manager): |
---|
| 874 | """ |
---|
[d955bf19] | 875 | Sets a reference to the application manager |
---|
| 876 | of the GUI manager (Frame) |
---|
[41d466f] | 877 | """ |
---|
| 878 | self.frame.set_manager(manager) |
---|
| 879 | |
---|
[278cc25] | 880 | def build_gui(self): |
---|
| 881 | """ |
---|
[d955bf19] | 882 | Build the GUI |
---|
[278cc25] | 883 | """ |
---|
| 884 | self.frame.build_gui() |
---|
| 885 | self.frame.post_init() |
---|
| 886 | |
---|
[f9e803e] | 887 | def set_welcome_panel(self, panel_class): |
---|
| 888 | """ |
---|
[d955bf19] | 889 | Set the welcome panel |
---|
| 890 | |
---|
| 891 | :param panel_class: class of the welcome panel to be instantiated |
---|
| 892 | |
---|
[f9e803e] | 893 | """ |
---|
| 894 | self.frame.set_welcome_panel(panel_class) |
---|
| 895 | |
---|
[278cc25] | 896 | def add_perspective(self, perspective): |
---|
| 897 | """ |
---|
[d955bf19] | 898 | Manually add a perspective to the application GUI |
---|
[278cc25] | 899 | """ |
---|
| 900 | self.frame.add_perspective(perspective) |
---|
| 901 | |
---|
[41d466f] | 902 | |
---|
| 903 | if __name__ == "__main__": |
---|
| 904 | app = ViewApp(0) |
---|
[32c0841] | 905 | app.MainLoop() |
---|
| 906 | |
---|
| 907 | |
---|