Changeset 957723f in sasview
- Timestamp:
- Mar 25, 2011 10:37:30 AM (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:
- 3e943e8
- Parents:
- 68b7d43
- Location:
- guiframe
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/config.py
rd955bf19 r957723f 3 3 """ 4 4 import time 5 5 from sans.guiframe.gui_style import GUIFRAME 6 6 # Version of the application 7 7 __appname__ = "DummyView" … … 42 42 _welcome_image = "images/SVwelcome.png" 43 43 _copyright = "(c) 2008, University of Tennessee" 44 #edit the lists below of file state your plugin can read 45 #for sansview this how you can edit these lists 46 #PLUGIN_STATE_EXTENSIONS = ['.prv','.fitv', '.inv'] 47 #APPLICATION_STATE_EXTENSION = '.svs' 48 #WLIST = ['SansView files (*.svs)|*.svs','P(r) files (*.prv)|*.prv', 49 # 'Fitting files (*.fitv)|*.fitv', 50 # 'Invariant files (*.inv)|*.inv'] 51 52 PLUGIN_STATE_EXTENSIONS = [] 53 APPLICATION_STATE_EXTENSION = None 54 WLIST = [] 55 SPLASH_SCREEN_PATH = "images/danse_logo.png" 56 DEFAULT_STYLE = GUIFRAME.SINGLE_APPLICATION 57 SPLASH_SCREEN_WIDTH = 500 58 SPLASH_SCREEN_HEIGHT = 300 59 SS_MAX_DISPLAY_TIME = 3000 #3 sec 60 PLOPANEL_WIDTH = 400 61 PLOPANEL_HEIGTH = 400 62 GUIFRAME_WIDTH = 1000 63 GUIFRAME_HEIGHT = 800 64 44 65 45 66 import wx.lib.newevent -
guiframe/dummyapp.py
r783940c r957723f 4 4 """ 5 5 import gui_manager 6 from sans.guiframe.gui_style import GUIFRAME 6 7 7 from sans.guiframe.plugin_base import PluginBase 8 8 … … 10 10 """ 11 11 """ 12 #PROG_SPLASH_PATH = None13 STYLE = GUIFRAME.SINGLE_APPLICATION14 12 15 13 class TestPlugin(PluginBase): -
guiframe/gui_manager.py
r783940c r957723f 51 51 52 52 53 PLOPANEL_WIDTH = 400 54 PLOPANEL_HEIGTH = 400 55 GUIFRAME_WIDTH = 1000 56 GUIFRAME_HEIGHT = 800 57 PROG_SPLASH_SCREEN = "images/danse_logo.png" 58 EXTENSIONS = ['.inv', '.fitv', '.prv', '.svs'] 53 #read some constants from config 54 APPLICATION_STATE_EXTENSION = config.APPLICATION_STATE_EXTENSION 55 56 APPLICATION_NAME = config.__appname__ 57 SPLASH_SCREEN_PATH = config.SPLASH_SCREEN_PATH 58 DEFAULT_STYLE = config.DEFAULT_STYLE 59 SPLASH_SCREEN_WIDTH = config.SPLASH_SCREEN_WIDTH 60 SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 61 SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 62 PLOPANEL_WIDTH = config.PLOPANEL_WIDTH 63 PLOPANEL_HEIGTH = config.PLOPANEL_HEIGTH 64 GUIFRAME_WIDTH = config.GUIFRAME_WIDTH 65 GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT 66 PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 67 extension_list = [] 68 if APPLICATION_STATE_EXTENSION is not None: 69 extension_list.append(APPLICATION_STATE_EXTENSION) 70 EXTENSIONS = PLUGIN_STATE_EXTENSIONS + extension_list 71 try: 72 WLIST = '|'.join(config.WLIST) 73 except: 74 WLIST = '' 75 59 76 60 77 class ViewerFrame(wx.Frame): … … 992 1009 reader.read(path) 993 1010 return 994 elif extension == '.svs':1011 elif extension == APPLICATION_STATE_EXTENSION: 995 1012 reader.read(path) 996 1013 … … 1001 1018 self._data_panel.load_data_list(data_state) 1002 1019 self._mgr.GetPane(self._data_panel.window_name).Show(True) 1003 1020 1021 def load_state(self, path): 1022 """ 1023 """ 1024 if path and os.path.isfile(path): 1025 basename = os.path.basename(path) 1026 if APPLICATION_STATE_EXTENSION is not None \ 1027 and basename.endswith(APPLICATION_STATE_EXTENSION): 1028 #remove panels for new states 1029 for plug in self.plugins: 1030 reader, ext = plug.get_extensions() 1031 if ext is not None and ext.strip() != ''\ 1032 and ext.lower() not in EXTENSIONS: 1033 plug.clear_panel() 1034 self.panel_on_focus = None 1035 self.get_data(path) 1036 if self.defaultPanel is not None and \ 1037 self._mgr.GetPane(self.panels["default"].window_name).IsShown(): 1038 self.on_close_welcome_panel() 1039 1040 def load_data(self, path): 1041 """ 1042 """ 1043 if not os.path.isfile(path): 1044 return 1045 basename = os.path.basename(path) 1046 root, extension = os.path.splitext(basename) 1047 if extension.lower() in EXTENSIONS: 1048 log_msg = "Data Loader cannot " 1049 log_msg += "load: %s\n" % str(path) 1050 log_msg += "Try File opening ...." 1051 print log_msg 1052 return 1053 1054 try: 1055 print "Loading Data..." + str(path) + "\n" 1056 temp = self.loader.load(path) 1057 if temp.__class__.__name__ == "list": 1058 for item in temp: 1059 data = self.parent.create_gui_data(item, path) 1060 output[data.id] = data 1061 else: 1062 data = self.parent.create_gui_data(temp, path) 1063 output[data.id] = data 1064 1065 self.add_data(data_list=output) 1066 except: 1067 error_message = "Error while loading Data: %s\n" % str(path) 1068 error_message += str(sys.exc_value) + "\n" 1069 print error_message 1070 1071 1004 1072 def _on_open_state(self, event): 1005 1073 """ … … 1009 1077 self._default_save_location = os.getcwd() 1010 1078 1011 wlist = ['SansView files (*.svs)|*.svs',1012 'P(r) files (*.prv)|*.prv',1013 'Fitting files (*.fitv)|*.fitv',1014 'Invariant files (*.inv)|*.inv']1015 wlist = '|'.join(wlist)1016 1079 dlg = wx.FileDialog(self, 1017 1080 "Choose a file", 1018 1081 self._default_save_location, "", 1019 wlist)1082 WLIST) 1020 1083 if dlg.ShowModal() == wx.ID_OK: 1021 1084 path = dlg.GetPath() … … 1023 1086 self._default_save_location = os.path.dirname(path) 1024 1087 dlg.Destroy() 1025 if path and os.path.isfile(path): 1026 basename = os.path.basename(path) 1027 if basename.endswith('.svs'): 1028 #remove panels for new states 1029 for plug in self.plugins: 1030 plug.clear_panel() 1031 self.panel_on_focus = None 1032 1033 self.get_data(path) 1034 1035 if self.defaultPanel is not None and \ 1036 self._mgr.GetPane(self.panels["default"].window_name).IsShown(): 1037 self.on_close_welcome_panel() 1088 self.load_state(path=path) 1038 1089 1039 1090 def _on_save_application(self, event): … … 1055 1106 path = None 1056 1107 dlg = wx.FileDialog(self, "Save Project file", 1057 self._default_save_location, "", '.svs', wx.SAVE) 1108 self._default_save_location, "", 1109 APPLICATION_STATE_EXTENSION, 1110 wx.SAVE) 1058 1111 if dlg.ShowModal() == wx.ID_OK: 1059 1112 path = dlg.GetPath() … … 1094 1147 fd.close() 1095 1148 else: 1096 raise 1097 #print "Nothing to save..." 1098 #raise RuntimeError, "%s is not a SansView (.svs) file..." % path 1149 msg = "%s cannot read %s\n" % (str(APPLICATION_NAME), str(path)) 1150 raise RuntimeError, msg 1099 1151 return doc 1100 1152 … … 1695 1747 """ 1696 1748 """ 1697 SIZE = (GUIFRAME_WIDTH,GUIFRAME_HEIGHT)1698 TITLE = config.__appname__1699 PROG_SPLASH_PATH = PROG_SPLASH_SCREEN1700 STYLE = GUIFRAME.SINGLE_APPLICATION1701 SPLASH_WIDTH = 5001702 SPLASH_HEIGHT = 3001703 SPLASH_MAX_DISPLAY_TIME = 3000 #3 sec1704 1705 1749 def OnInit(self): 1706 1750 """ 1707 1751 """ 1708 pos, size = self.window_placement( self.SIZE)1752 pos, size = self.window_placement((GUIFRAME_WIDTH, GUIFRAME_HEIGHT)) 1709 1753 self.frame = ViewerFrame(parent=None, 1710 title= self.TITLE,1754 title=APPLICATION_NAME, 1711 1755 pos=pos, 1712 gui_style = self.STYLE,1756 gui_style = DEFAULT_STYLE, 1713 1757 size=size) 1714 # Display a splash screen on top of the frame. 1758 #try to load file at the start 1759 #try: 1760 # self.open_file() 1761 #except: 1762 # raise 1763 self.s_screen = None 1764 # Display a splash screen on top of the frame. 1715 1765 if len(sys.argv) > 1 and '--time' in sys.argv[1:]: 1716 1766 log_time("Starting to display the splash screen") 1717 if self.PROG_SPLASH_PATH is not None and \ 1718 os.path.isfile(self.PROG_SPLASH_PATH): 1719 try: 1720 s_screen = self.display_splash_screen(parent=self.frame, path=self.PROG_SPLASH_PATH) 1767 1768 try: 1769 if os.path.isfile(SPLASH_SCREEN_PATH): 1770 self.s_screen = self.display_splash_screen(parent=self.frame, 1771 path=SPLASH_SCREEN_PATH) 1772 else: 1773 self.frame.Show() 1774 except: 1775 try: 1776 self.frame.Show() 1721 1777 except: 1722 try: 1723 self.frame.Show() 1724 except: 1725 1726 msg = "Cannot display splash screen\n" 1727 msg += str (sys.exc_value) 1728 #raise 1729 logging.error(msg) 1730 else: 1731 self.frame.Show() 1778 raise 1779 msg = "Cannot display splash screen\n" 1780 msg += str (sys.exc_value) 1781 #raise 1782 logging.error(msg) 1783 1732 1784 1733 1785 … … 1739 1791 return True 1740 1792 1793 def load(self, path): 1794 """ 1795 """ 1796 if self.frame is not None: 1797 self.frame.load(path) 1798 1799 def open_file(self): 1800 """ 1801 open a state file at the start of the application 1802 """ 1803 if len(sys.argv) >= 2: 1804 if sys.argv[0].lower() in ['sansview.py', 'sansview.exe']: 1805 path = sys.argv[1] 1806 if os.path.isfile(path): 1807 self.load(path) 1808 else: 1809 print "SansView cannot read this file: %s" % str(path) 1810 1741 1811 def set_manager(self, manager): 1742 1812 """ … … 1752 1822 self.frame.build_gui() 1753 1823 self.frame.post_init() 1824 if self.s_screen.IsShown(): 1825 self.s_screen.Close() 1754 1826 1755 1827 def set_welcome_panel(self, panel_class): … … 1801 1873 1802 1874 def display_splash_screen(self, parent, 1803 path= PROG_SPLASH_SCREEN):1875 path=SPLASH_SCREEN_PATH): 1804 1876 """Displays the splash screen. It will exactly cover the main frame.""" 1805 1877 1806 1878 # Prepare the picture. On a 2GHz intel cpu, this takes about a second. 1807 1879 x, y = parent.GetSizeTuple() 1808 1880 image = wx.Image(path, wx.BITMAP_TYPE_PNG) 1809 image.Rescale(self.SPLASH_WIDTH, self.SPLASH_HEIGHT, wx.IMAGE_QUALITY_HIGH) 1881 image.Rescale(SPLASH_SCREEN_WIDTH, 1882 SPLASH_SCREEN_HEIGHT, wx.IMAGE_QUALITY_HIGH) 1810 1883 bm = image.ConvertToBitmap() 1811 1884 … … 1826 1899 wx.STAY_ON_TOP), 1827 1900 1828 milliseconds= self.SPLASH_MAX_DISPLAY_TIME,1901 milliseconds=SS_MAX_DISPLAY_TIME, 1829 1902 parent=parent, 1830 1903 id=wx.ID_ANY) -
guiframe/local_perspectives/data_loader/data_loader.py
re88ebfd r957723f 17 17 from sans.guiframe.utils import parse_name 18 18 from sans.guiframe.gui_style import GUIFRAME 19 20 EXTENSIONS = ['.svs', '.prv','.fitv', '.inv'] 19 try: 20 # Try to find a local config 21 import imp 22 path = os.getcwd() 23 if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \ 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) 27 else: 28 # Try simply importing local_config 29 import local_config as config 30 except: 31 # Didn't find local config, load the default 32 import config 33 34 extension_list = [] 35 if APPLICATION_STATE_EXTENSION is not None: 36 extension_list.append(APPLICATION_STATE_EXTENSION) 37 EXTENSIONS = PLUGIN_STATE_EXTENSIONS + extension_list 21 38 22 39 class Plugin(PluginBase): -
guiframe/local_perspectives/plotting/plotting.py
r783940c r957723f 89 89 return False 90 90 91 def clear_panel(self, group_id): 91 def clear_panel(self): 92 """ 93 """ 94 pass 95 96 def clear_panel_by_id(self, group_id): 92 97 """ 93 98 clear the graph … … 239 244 return self.delete_panel(group_id) 240 245 if event.action.lower() == "clear": 241 return self.clear_panel (group_id)246 return self.clear_panel_by_id(group_id) 242 247 243 248 title = None -
guiframe/plugin_base.py
r3658717e r957723f 138 138 return [] 139 139 140 def clear_panel(self): 141 """ 142 reset all panels 143 """ 144 140 145 141 def get_tools(self): 146 142 """
Note: See TracChangeset
for help on using the changeset viewer.