- Timestamp:
- Feb 11, 2011 9:39:37 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:
- e3f438d
- Parents:
- 5631f70
- Location:
- guiframe
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/__init__.py
r41d466f rba924ed 1 2 3 import os 4 from distutils.filelist import findall 5 6 def get_data_path(media): 7 """ 8 """ 9 # Check for data path in the package 10 path = os.path.join(os.path.dirname(__file__), media) 11 if os.path.isdir(path): 12 return path 13 14 # Check for data path next to exe/zip file. 15 # If we are inside a py2exe zip file, we need to go up 16 # to get to the directory containing 17 # the media for this module 18 path = os.path.dirname(__file__) 19 #Look for maximum n_dir up of the current dir to find media 20 n_dir = 12 21 for i in range(n_dir): 22 path, _ = os.path.split(path) 23 media_path = os.path.join(path, media) 24 if os.path.isdir(media_path): 25 module_media_path = os.path.join(media_path, 'images') 26 if os.path.isdir(module_media_path): 27 return module_media_path 28 return media_path 29 30 raise RuntimeError('Could not find guiframe images files') 31 32 def data_files(): 33 """ 34 Return the data files associated with guiframe images . 35 36 The format is a list of (directory, [files...]) pairs which can be 37 used directly in setup(...,data_files=...) for setup.py. 38 39 """ 40 data_files = [] 41 path = get_data_path(media="images") 42 for f in findall(path): 43 data_files.append(('icons', [f])) 44 return data_files -
guiframe/gui_style.py
rf036c692 rba924ed 4 4 """ 5 5 import wx 6 import os 7 from sans.guiframe import get_data_path 8 6 9 7 10 class GUIFRAME: … … 30 33 PRINT_ID = wx.NewId() 31 34 CURRENT_APPLICATION = wx.NewId() 35 36 class GUIFRAME_ICON: 37 PATH = get_data_path(media='images') 38 SAVE_ICON_PATH = os.path.join(PATH, 'save.png') 39 UNDO_ICON_PATH = os.path.join(PATH, 'undo.png') 40 REDO_ICON_PATH = os.path.join(PATH, 'redo.png') 41 BOOKMARK_ICON_PATH = os.path.join(PATH, 'bookmark.png') 42 ZOOM_IN_ID_PATH = os.path.join(PATH, 'zoom_in.png') 43 ZOOM_OUT_ID_PATH = os.path.join(PATH, 'zoom_out.png') 44 ZOOM_ID_PATH = os.path.join(PATH, 'search_pan.png') 45 DRAG_ID_PATH = os.path.join(PATH, 'drag_hand.png') 46 RESET_ID_PATH = os.path.join(PATH, 'reset.png') 47 PREVIEW_ID_PATH = os.path.join(PATH, 'report.png') 48 PRINT_ID_PATH = os.path.join(PATH, 'printer.png') 49 50 SAVE_ICON = wx.Image(os.path.join(PATH, 'save.png')) 51 UNDO_ICON = wx.Image(os.path.join(PATH, 'undo.png')) 52 REDO_ICON = wx.Image(os.path.join(PATH, 'redo.png')) 53 BOOKMARK_ICON = wx.Image(os.path.join(PATH, 'bookmark.png')) 54 ZOOM_IN_ICON = wx.Image(os.path.join(PATH, 'zoom_in.png')) 55 ZOOM_OUT_ICON = wx.Image(os.path.join(PATH, 'zoom_out.png')) 56 ZOOM_ICON = wx.Image(os.path.join(PATH, 'search_pan.png')) 57 DRAG_ICON = wx.Image(os.path.join(PATH, 'drag_hand.png')) 58 RESET_ICON = wx.Image(os.path.join(PATH, 'reset.png')) 59 REPORT_ICON = wx.Image(os.path.join(PATH, 'report.png')) 60 PREVIEW_ICON = wx.Image(os.path.join(PATH, 'preview.png')) 61 PRINT_ICON = wx.Image(os.path.join(PATH, 'printer.png')) 32 62 33 63 if __name__ == "__main__": -
guiframe/gui_toolbar.py
r93fe7e2 rba924ed 1 1 2 2 import wx 3 import os 3 4 from wx import ToolBar as Tbar 5 6 4 7 from sans.guiframe.gui_style import GUIFRAME_ID 5 8 from sans.guiframe.gui_style import GUIFRAME_ICON 9 10 11 def clear_image(image): 12 w, h = image.GetSize() 13 factor = 155 14 compress = lambda x: int(x * factor/255.) + factor 15 for y in range(h): 16 for x in range(w): 17 grey = compress(image.GetGreen(x, y)) 18 image.SetRGB(x, y, grey, grey, grey) 19 if image.HasAlpha(): 20 image.ConvertAlphaToMask() 21 return image 6 22 7 23 class GUIToolBar(Tbar): 24 """ 25 Implement toolbar for guiframe 26 """ 8 27 def __init__(self, parent, *args, **kwds): 9 28 Tbar.__init__(self, parent, *args, **kwds) … … 11 30 self.do_layout() 12 31 self.on_bind_button() 13 32 14 33 def do_layout(self): 15 34 """ 16 35 """ 17 tbar_size = (-1,-1) 18 save_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, 19 size=tbar_size) 20 self.AddLabelTool(GUIFRAME_ID.SAVE_ID, 'Save', save_bmp, shortHelp='Save') 21 self.AddSeparator() 22 23 bookmark_bmp = wx.ArtProvider.GetBitmap(wx.ART_ADD_BOOKMARK, wx.ART_TOOLBAR, 24 size=tbar_size) 25 self.AddLabelTool(GUIFRAME_ID.BOOKMARK_ID, 'Bookmark', bookmark_bmp,shortHelp='Bookmark') 26 self.AddSeparator() 27 zoom_in_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_TOOLBAR, 28 size=tbar_size) 29 self.AddLabelTool(GUIFRAME_ID.ZOOM_IN_ID, 'Zoom in', zoom_in_bmp,shortHelp='Zoom in') 30 self.AddSeparator() 31 zoom_out_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_DOWN, wx.ART_TOOLBAR, 32 size=tbar_size) 33 self.AddLabelTool(GUIFRAME_ID.ZOOM_OUT_ID,'Zoom out',zoom_out_bmp,shortHelp='Zoom out') 34 self.AddSeparator() 35 zoom_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR, 36 size=tbar_size) 37 self.AddLabelTool(GUIFRAME_ID.ZOOM_ID, 'Zoom', zoom_bmp,shortHelp='Zoom') 38 self.AddSeparator() 39 drag_bmp = wx.ArtProvider.GetBitmap(wx.ART_REMOVABLE, wx.ART_TOOLBAR, 40 size=tbar_size) 41 self.AddLabelTool(GUIFRAME_ID.DRAG_ID, 'Drag', drag_bmp,shortHelp='Drag') 42 self.AddSeparator() 43 preview_bmp = wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_TOOLBAR, 44 size=tbar_size) 45 self.AddLabelTool(GUIFRAME_ID.PREVIEW_ID, 'Preview', preview_bmp,shortHelp='Report') 46 self.AddSeparator() 47 print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR, 48 size=tbar_size) 49 self.AddLabelTool(GUIFRAME_ID.PRINT_ID, 'Print', print_bmp,shortHelp='Print') 50 self.AddSeparator() 51 undo_bmp = wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR, 52 size=tbar_size) 53 self.AddLabelTool(GUIFRAME_ID.UNDO_ID, 'Undo', undo_bmp,shortHelp='Undo') 54 self.AddSeparator() 55 redo_bmp = wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_TOOLBAR, 56 size=tbar_size) 57 self.AddLabelTool(GUIFRAME_ID.REDO_ID, 'Redo', redo_bmp,shortHelp='Redo') 36 tbar_size = (22, 22) 37 button_type = wx.ITEM_NORMAL 38 save_im = GUIFRAME_ICON.SAVE_ICON 39 save_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 40 save_bmp = save_im.ConvertToBitmap() 41 #disable_save_bmp = clear_image(save_im).ConvertToBitmap() 42 disable_save_bmp = wx.NullBitmap 43 self.AddLabelTool(GUIFRAME_ID.SAVE_ID, 'Save', save_bmp, 44 disable_save_bmp,button_type, shortHelp='Save') 45 self.AddSeparator() 46 bookmark_im = GUIFRAME_ICON.BOOKMARK_ICON 47 bookmark_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 48 bookmark_bmp = bookmark_im.ConvertToBitmap() 49 #disable_bookmark_bmp = clear_image(bookmark_im).ConvertToBitmap() 50 disable_bookmark_bmp = wx.NullBitmap 51 self.AddLabelTool(GUIFRAME_ID.BOOKMARK_ID, 'Bookmark', bookmark_bmp, 52 disable_bookmark_bmp, button_type,'Bookmark') 53 self.AddSeparator() 54 zoom_in_im = GUIFRAME_ICON.ZOOM_IN_ICON 55 zoom_in_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 56 zoom_in_bmp = zoom_in_im.ConvertToBitmap() 57 #disable_zoom_in_bmp = clear_image(zoom_in_im).ConvertToBitmap() 58 disable_zoom_in_bmp = wx.NullBitmap 59 self.AddLabelTool(GUIFRAME_ID.ZOOM_IN_ID, 'Zoom In', zoom_in_bmp, 60 disable_zoom_in_bmp, button_type,'Zoom In') 61 self.AddSeparator() 62 zoom_out_im = GUIFRAME_ICON.ZOOM_OUT_ICON 63 zoom_out_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 64 zoom_out_bmp = zoom_out_im.ConvertToBitmap() 65 #disable_zoom_out_bmp = clear_image(zoom_out_im).ConvertToBitmap() 66 disable_zoom_out_bmp = wx.NullBitmap 67 self.AddLabelTool(GUIFRAME_ID.ZOOM_OUT_ID, 'Zoom Out', zoom_out_bmp, 68 disable_zoom_out_bmp, button_type,'Zoom Out') 69 self.AddSeparator() 70 zoom_im = GUIFRAME_ICON.ZOOM_ICON 71 zoom_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 72 zoom_bmp = zoom_im.ConvertToBitmap() 73 #disable_zoom_bmp = clear_image(zoom_im).ConvertToBitmap() 74 disable_zoom_bmp = wx.NullBitmap 75 self.AddLabelTool(GUIFRAME_ID.ZOOM_ID, 'Zoom', zoom_bmp, 76 disable_zoom_bmp, button_type,'Zoom In') 77 self.AddSeparator() 78 drag_im = GUIFRAME_ICON.DRAG_ICON 79 drag_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 80 drag_bmp = drag_im.ConvertToBitmap() 81 #disable_drag_bmp = clear_image(drag_im).ConvertToBitmap() 82 disable_drag_bmp = wx.NullBitmap 83 self.AddLabelTool(GUIFRAME_ID.DRAG_ID, 'Drag', drag_bmp, 84 disable_drag_bmp, button_type,'Drag') 85 self.AddSeparator() 86 report_im = GUIFRAME_ICON.REPORT_ICON 87 report_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 88 report_bmp = report_im.ConvertToBitmap() 89 #disable_report_bmp = clear_image(report_im).ConvertToBitmap() 90 disable_report_bmp = wx.NullBitmap 91 self.AddLabelTool(GUIFRAME_ID.PREVIEW_ID, 'Report', report_bmp, 92 disable_report_bmp, button_type,'Report') 93 self.AddSeparator() 94 print_im = GUIFRAME_ICON.PRINT_ICON 95 print_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 96 print_bmp = print_im.ConvertToBitmap() 97 #disable_print_bmp = clear_image(print_im).ConvertToBitmap() 98 disable_print_bmp = wx.NullBitmap 99 self.AddLabelTool(GUIFRAME_ID.PRINT_ID, 'Print', print_bmp, 100 disable_print_bmp, button_type, 'Print') 101 self.AddSeparator() 102 undo_im = GUIFRAME_ICON.UNDO_ICON 103 undo_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 104 undo_bmp = undo_im.ConvertToBitmap() 105 #disable_undo_bmp = clear_image(undo_im).ConvertToBitmap() 106 disable_undo_bmp = wx.NullBitmap 107 self.AddLabelTool(GUIFRAME_ID.UNDO_ID, 'Undo', undo_bmp, 108 disable_undo_bmp, button_type,'Undo') 109 self.AddSeparator() 110 redo_im = GUIFRAME_ICON.REDO_ICON 111 redo_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH) 112 redo_bmp = redo_im.ConvertToBitmap() 113 #disable_redo_bmp = clear_image(redo_im).ConvertToBitmap() 114 disable_redo_bmp = wx.NullBitmap 115 self.AddLabelTool(GUIFRAME_ID.REDO_ID, 'Redo', redo_bmp, 116 disable_redo_bmp, button_type,'Redo') 58 117 self.AddSeparator() 59 118 #add button for the current application … … 61 120 self.button_application.SetForegroundColour('black') 62 121 self.button_application.SetBackgroundColour('#1874CD') 122 hint = 'Active Application' 123 self.button_application.SetToolTipString(hint) 63 124 self.AddControl(self.button_application) 64 125 self.AddSeparator() … … 67 128 self.button_panel.SetForegroundColour('black') 68 129 self.button_panel.SetBackgroundColour('#90EE90') 130 hint = 'Panel on Focus' 131 self.button_panel.SetToolTipString(hint) 69 132 self.AddControl(self.button_panel) 70 133 71 134 self.SetToolBitmapSize(tbar_size) 72 135 self.Realize() … … 105 168 self.button_panel.SetLabel(str(panel_name)) 106 169 print "update_button", application_name, panel_name 170 107 171 def update_toolbar(self, panel=None): 108 172 """ 109 173 """ 110 174 if panel is None: 111 #self.Disable()112 175 self.EnableTool(GUIFRAME_ID.PRINT_ID, False) 113 176 self.EnableTool(GUIFRAME_ID.UNDO_ID,False) … … 122 185 self.EnableTool(GUIFRAME_ID.RESET_ID, False) 123 186 else: 124 self.Enable()125 187 self.EnableTool(GUIFRAME_ID.PRINT_ID, panel.get_print_flag()) 126 188 self.EnableTool(GUIFRAME_ID.UNDO_ID, panel.get_undo_flag()) … … 134 196 self.EnableTool(GUIFRAME_ID.DRAG_ID, panel.get_drag_flag()) 135 197 self.EnableTool(GUIFRAME_ID.RESET_ID, panel.get_reset_flag()) 136 198 self.Realize() 137 199 138 200 -
guiframe/setup.py
rfebcd79 rba924ed 13 13 path = os.path.join(os.getcwd(), 'local_perspectives') 14 14 package_dir = { "sans.guiframe":".", 15 "sans.guiframe.local_perspectives":"local_perspectives"} 15 "sans.guiframe.local_perspectives":"local_perspectives", 16 "sans.guiframe.widgets":"widgets"} 16 17 packages = ["sans.guiframe", 17 "sans.guiframe.local_perspectives"] 18 "sans.guiframe.local_perspectives", 19 "sans.guiframe.widgets"] 18 20 # build local plugin 19 21 for dir in os.listdir(path):
Note: See TracChangeset
for help on using the changeset viewer.