- Timestamp:
- Jan 10, 2011 3:11:09 PM (14 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 992199e
- Parents:
- 9299455
- Location:
- guiframe
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/gui_manager.py
rb5ca223 rb7c7a1c 55 55 Initialize the Frame object 56 56 """ 57 from local_perspectives.plotting import plotting57 58 58 wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, 59 59 size=(window_width, window_height)) … … 86 86 # Modify this so that we can specify the directory to look into 87 87 self.plugins = [] 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 88 92 self.plugins.append(plotting.Plugin()) 93 self.plugins.append(data_loader.Plugin()) 94 89 95 self.plugins += self._find_plugins() 90 96 … … 375 381 return ID 376 382 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: 389 id = wx.NewId() 390 for item in plugin.populate_file_menu(): 391 m_name, m_hint, m_handler = item 392 self.filemenu.Append(id, m_name, m_hint) 393 wx.EVT_MENU(self, id, m_handler) 394 self.filemenu.AppendSeparator() 395 377 396 def _setup_menus(self): 378 397 """ … … 380 399 """ 381 400 # Menu 382 menubar = wx.MenuBar()401 self._menubar = wx.MenuBar() 383 402 # File menu 384 403 self.filemenu = wx.Menu() 385 404 386 id = wx.NewId() 387 self.filemenu.Append(id, '&Open', 'Load data file into the application') 388 wx.EVT_MENU(self, id, self._on_open) 389 #self.filemenu.AppendSeparator() 390 405 # some menu of plugin to be seen under file menu 406 self._populate_file_menu() 391 407 id = wx.NewId() 392 408 self.filemenu.Append(id, '&Save', … … 400 416 401 417 # Add sub menus 402 menubar.Append(self.filemenu, '&File')418 self._menubar.Append(self.filemenu, '&File') 403 419 404 420 # Window menu … … 425 441 "Show %s window" % panel.window_caption) 426 442 wx.EVT_MENU(self, int(item), self._on_view) 427 menubar.Append(viewmenu, '&Window')443 self._menubar.Append(viewmenu, '&Window') 428 444 429 445 # Perspective … … 443 459 "Switch to %s perspective" % plug.sub_menu) 444 460 wx.EVT_MENU(self, id, plug.on_perspective) 445 menubar.Append(p_menu, '&Perspective')461 self._menubar.Append(p_menu, '&Perspective') 446 462 447 463 # Tools menu … … 458 474 wx.EVT_MENU(self, id, tool[2]) 459 475 if toolsmenu is not None: 460 menubar.Append(toolsmenu, '&Tools')476 self._menubar.Append(toolsmenu, '&Tools') 461 477 462 478 # Help menu … … 494 510 for (self.next_id, menu, name) in \ 495 511 item.populate_menu(self.next_id, self): 496 menubar.Append(menu, name)512 self._menubar.Append(menu, name) 497 513 498 menubar.Append(helpmenu, '&Help')499 self.SetMenuBar( menubar)514 self._menubar.Append(helpmenu, '&Help') 515 self.SetMenuBar(self._menubar) 500 516 501 517 def _on_status_event(self, evt): … … 657 673 Store info to retrieve in xml before closing the application 658 674 """ 659 try:660 doc = xml.dom.minidom.Document()661 main_node = doc.createElement("file Path")662 doc.appendChild(main_node)663 664 for item in self.filePathList:665 id, menuitem_name, path, title = item666 pt1 = doc.createElement("File")667 pt1.setAttribute("name", menuitem_name)668 pt2 = doc.createElement("path")669 pt2.appendChild(doc.createTextNode(str(path)))670 pt1.appendChild(pt2)671 pt3 = doc.createElement("title")672 pt3.appendChild(doc.createTextNode(str(title)))673 pt1.appendChild(pt3)674 main_node.appendChild(pt1)675 676 fd = open("fileOpened.xml",'w')677 fd.write(doc.toprettyxml())678 fd.close()679 except:680 pass681 #import sys682 675 wx.Exit() 683 676 sys.exit() … … 847 840 pass 848 841 return path 849 850 def load_ascii_1D(self, path): 851 """ 852 """ 853 from .data_loader import load_ascii_1D 854 return load_ascii_1D(path) 855 842 856 843 class DefaultPanel(wx.Panel): 857 844 """ -
guiframe/local_perspectives/plotting/plotting.py
r7f84e22 rb7c7a1c 30 30 self.plot_panels = [] 31 31 32 def is_always_active(self): 33 """ 34 return True is this plugin is always active even if the user is 35 switching between perspectives 36 """ 37 return True 38 32 39 def populate_menu(self, id, parent): 33 40 """ -
guiframe/plugin_base.py
rb5ca223 rb7c7a1c 33 33 Abstract class for gui_manager Plugins. 34 34 """ 35 # Define if the plugin is local to Viewerframe and always active 36 self._always_active = False 35 37 ## Plug-in name. It will appear on the application menu. 36 38 self.sub_menu = name … … 44 46 self.perspective = [] 45 47 48 def set_is_active(self, active=False): 49 """ 50 """ 51 self._always_active = active 52 53 def is_always_active(self): 54 """ 55 return True is this plugin is always active and it is local to guiframe 56 even if the user is switching between perspectives 57 """ 58 return self._always_active 59 60 def populate_file_menu(self): 61 """ 62 get a menu item and append it under file menu of the application 63 return [[menu item name, menu_hint, menu handler]] 64 """ 65 return [] 46 66 47 67 def populate_menu(self, id, parent):
Note: See TracChangeset
for help on using the changeset viewer.