Changeset 71ac835 in sasview for src/sas/sasgui/perspectives/fitting
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/gpu_options.py
r8f02f7f r71ac835 36 36 self.option_button = {} 37 37 self.buttons = [] 38 #Check if SAS_OPENCL is already set 39 self.sas_opencl = os.environ.get("SAS_OPENCL","") 38 40 for index, clopt in enumerate(clinfo): 39 41 button = wx.CheckBox(self.panel1, -1, label=clopt, name=clopt) 42 40 43 if clopt != "No OpenCL": 41 44 self.option_button[clopt] = str(index) 45 if self.sas_opencl == str(index): 46 button.SetValue(1) 42 47 else: 43 48 self.option_button[clopt] = "None" 49 if self.sas_opencl.lower() == "none" : 50 button.SetValue(1) 51 44 52 self.Bind(wx.EVT_CHECKBOX, self.on_check, id=button.GetId()) 45 53 self.buttons.append(button) … … 55 63 56 64 accept_btn = wx.Button(self, wx.ID_OK) 57 accept_btn.SetToolTipString("Accept OpenCL settings") 65 accept_btn.SetToolTipString("Accept new OpenCL settings. This will" 66 "overwrite SAS_OPENCL variable if set") 58 67 59 68 help_id = wx.NewId() … … 61 70 help_btn.SetToolTipString("Help on the GPU options") 62 71 72 reset_id = wx.NewId() 73 reset_btn = wx.Button(self, reset_id, 'Reset') 74 reset_btn.SetToolTipString("Restore initial settings") 75 63 76 self.Bind(wx.EVT_BUTTON, self.on_OK, accept_btn) 77 self.Bind(wx.EVT_BUTTON, self.on_reset, reset_btn) 64 78 self.Bind(wx.EVT_BUTTON, self.on_help, help_btn) 65 79 … … 67 81 btn_sizer.Add((10, 20), 1) # stretchable whitespace 68 82 btn_sizer.Add(accept_btn, 0) 83 btn_sizer.Add((10, 20), 0) # non-stretchable whitespace 84 btn_sizer.Add(reset_btn, 0) 69 85 btn_sizer.Add((10, 20), 0) # non-stretchable whitespace 70 86 btn_sizer.Add(help_btn, 0) … … 80 96 def _get_clinfo(self): 81 97 clinfo = [] 82 83 98 try: 84 99 import pyopencl as cl … … 102 117 if btn != selected_button: 103 118 btn.SetValue(0) 104 os.environ["SAS_OPENCL"]= self.option_button[selected_button.Name]119 self.sas_opencl = self.option_button[selected_button.Name] 105 120 106 121 def on_OK(self, event): … … 109 124 """ 110 125 import sasmodels 126 #If statement added to handle Reset 127 if self.sas_opencl: 128 os.environ["SAS_OPENCL"] = self.sas_opencl 129 else: 130 if "SAS_OPENCL" in os.environ: 131 del(os.environ["SAS_OPENCL"]) 111 132 sasmodels.kernelcl.ENV = None 112 133 #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 113 134 reload(sasmodels.core) 114 135 event.Skip() 136 137 def on_reset(self, event): 138 """ 139 Close window on accpetance 140 """ 141 for btn in self.buttons: 142 btn.SetValue(0) 143 self.sas_opencl=None 115 144 116 145 def on_help(self, event):
Note: See TracChangeset
for help on using the changeset viewer.