Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/gpu_options.py
ra9279cc r6a569b3 5 5 ''' 6 6 7 import os 8 import warnings 9 7 10 import wx 8 11 import wx.richtext 9 12 import wx.lib.hyperlink 10 import os11 13 12 14 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 13 14 try:15 # Try to find a local config16 import imp17 path = os.getcwd()18 if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \19 (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))):20 fObj, path, descr = imp.find_module('local_config', [path])21 config = imp.load_module('local_config', fObj, path, descr)22 else:23 # Try simply importing local_config24 import local_config as config25 except:26 # Didn't find local config, load the default27 import config28 29 15 30 16 class GpuOptions(wx.Dialog): … … 50 36 self.option_button = {} 51 37 for index, clopt in enumerate(clinfo): 52 button = wx.RadioButton(self.panel1, -1, 53 label=clopt, name=clopt) 38 button = wx.RadioButton(self.panel1, -1, label=clopt, name=clopt) 54 39 if clopt != "No OpenCL": 55 40 self.option_button[clopt] = str(index) 56 41 else: 57 42 self.option_button[clopt] = "None" 58 self.Bind(wx.EVT_RADIOBUTTON, self. OnRadio, id=button.GetId())43 self.Bind(wx.EVT_RADIOBUTTON, self.on_radio, id=button.GetId()) 59 44 boxsizer.Add(button, 0, 0) 60 45 … … 73 58 help_btn.SetToolTipString("Help on the GPU options") 74 59 75 self.Bind(wx.EVT_BUTTON, self. OnAccept, accept_btn)76 self.Bind(wx.EVT_BUTTON, self. OnHelp, help_btn)77 self.Bind(wx.EVT_CLOSE, self. OnClose)60 self.Bind(wx.EVT_BUTTON, self.on_accept, accept_btn) 61 self.Bind(wx.EVT_BUTTON, self.on_help, help_btn) 62 self.Bind(wx.EVT_CLOSE, self.on_close) 78 63 79 64 btn_sizer = wx.BoxSizer(wx.HORIZONTAL) 80 btn_sizer.Add((10, 20), 1)# stretchable whitespace65 btn_sizer.Add((10, 20), 1) # stretchable whitespace 81 66 btn_sizer.Add(accept_btn, 0) 82 btn_sizer.Add((10, 20), 0)# non-stretchable whitespace67 btn_sizer.Add((10, 20), 0) # non-stretchable whitespace 83 68 btn_sizer.Add(help_btn, 0) 84 69 … … 93 78 def _get_clinfo(self): 94 79 try: 95 #TODO: Is PYOPENCL_CTX setup up in this order?96 80 import pyopencl as cl 97 81 clinfo = [] … … 100 84 clinfo.append(device.name) 101 85 clinfo.append("No OpenCL") 102 except: 103 warnings.warn(str(exc)) 86 except ImportError: 104 87 warnings.warn("pyopencl import failed") 105 88 clinfo = None 106 89 return clinfo 107 90 108 def OnRadio(self, event): 91 def on_radio(self, event): 92 """ 93 Action triggered when button is selected 94 :param event: 95 :return: 96 """ 97 109 98 import sasmodels 110 99 button = event.GetEventObject() … … 114 103 reload(sasmodels.core) 115 104 116 def OnAccept(self, event):105 def on_accept(self, event): 117 106 """ 118 107 Close window on accpetance … … 120 109 event.Skip() 121 110 122 def OnHelp(self, event):111 def on_help(self): 123 112 """ 124 113 Provide help on opencl options. 125 114 """ 126 _TreeLocation = "user/gpu_computations.html"127 _anchor = "#device-selection"115 TreeLocation = "user/gpu_computations.html" 116 anchor = "#device-selection" 128 117 DocumentationWindow(self, -1, 129 _TreeLocation, _anchor, "OpenCL Options Help")118 TreeLocation, anchor, "OpenCL Options Help") 130 119 131 def OnClose(self, event):120 def on_close(self, event): 132 121 """ 133 122 Close window 134 123 """ 135 124 event.Skip() 136 137 ##### testing code ############################################################138 class MyApp(wx.App):139 """140 Class for running module as stand alone for testing141 """142 def OnInit(self):143 """144 Defines an init when running as standalone145 """146 wx.InitAllImageHandlers()147 dialog = GpuOptions(None, -1, "")148 self.SetTopWindow(dialog)149 dialog.ShowModal()150 dialog.Destroy()151 return 1152 153 # end of class MyApp154 155 if __name__ == "__main__":156 app = MyApp(0)157 app.MainLoop()
Note: See TracChangeset
for help on using the changeset viewer.