1 | ''' |
---|
2 | Created on Feb 18, 2015 |
---|
3 | |
---|
4 | @author: jkrzywon |
---|
5 | ''' |
---|
6 | |
---|
7 | __id__ = "$Id: acknoweldgebox.py 2015-18-02 jkrzywon $" |
---|
8 | __revision__ = "$Revision: 1193 $" |
---|
9 | |
---|
10 | import wx |
---|
11 | import wx.richtext |
---|
12 | import wx.lib.hyperlink |
---|
13 | import random |
---|
14 | import os.path |
---|
15 | import os |
---|
16 | try: |
---|
17 | # Try to find a local config |
---|
18 | import imp |
---|
19 | path = os.getcwd() |
---|
20 | if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \ |
---|
21 | (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))): |
---|
22 | fObj, path, descr = imp.find_module('local_config', [path]) |
---|
23 | config = imp.load_module('local_config', fObj, path, descr) |
---|
24 | else: |
---|
25 | # Try simply importing local_config |
---|
26 | import local_config as config |
---|
27 | except: |
---|
28 | # Didn't find local config, load the default |
---|
29 | import config |
---|
30 | |
---|
31 | |
---|
32 | class GpuOptions(wx.Dialog): |
---|
33 | """ |
---|
34 | "Acknowledgement" Dialog Box |
---|
35 | |
---|
36 | Shows the current method for acknowledging SasView in |
---|
37 | scholarly publications. |
---|
38 | |
---|
39 | """ |
---|
40 | |
---|
41 | def __init__(self, *args, **kwds): |
---|
42 | |
---|
43 | kwds["style"] = wx.DEFAULT_DIALOG_STYLE |
---|
44 | wx.Dialog.__init__(self, *args, **kwds) |
---|
45 | |
---|
46 | try: |
---|
47 | from sasmodels.kernelcl import environment |
---|
48 | env = environment() |
---|
49 | clinfo = [ctx.devices[0].name |
---|
50 | for ctx in env.context] |
---|
51 | clinfo.append("No OpenCL") |
---|
52 | except ImportError: |
---|
53 | clinfo = None |
---|
54 | |
---|
55 | ##################################### |
---|
56 | self.panel1 = wx.Panel(self, -1) |
---|
57 | static_box1 = wx.StaticBox(self.panel1, -1, "OpenCL Options") |
---|
58 | |
---|
59 | #contextes = ("Intel(R) Iris(TM) Graphics 6100", |
---|
60 | # "Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz", |
---|
61 | # "No OpenCL") |
---|
62 | rows = len(clinfo) |
---|
63 | |
---|
64 | flexsizer = wx.FlexGridSizer(rows, 1, hgap=20, vgap=10) |
---|
65 | self.fitter_button = {} |
---|
66 | for fitter in clinfo: |
---|
67 | button = wx.RadioButton(self.panel1, -1, |
---|
68 | label=fitter, name=fitter) |
---|
69 | self.fitter_button[fitter] = button |
---|
70 | #self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio, id=button.GetId()) |
---|
71 | flexsizer.Add(button, 0, 0) |
---|
72 | |
---|
73 | fit_hsizer = wx.StaticBoxSizer(static_box1, orient=wx.VERTICAL) |
---|
74 | fit_hsizer.Add(flexsizer, 0, wx.ALL, 5) |
---|
75 | |
---|
76 | self.panel1.SetSizer(fit_hsizer) |
---|
77 | |
---|
78 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
79 | self.vbox.Add(self.panel1, 0, wx.ALL, 10) |
---|
80 | ########################################### |
---|
81 | #self.preamble = wx.StaticText(self, -1, config._acknowledgement_preamble) |
---|
82 | #items = [config._acknowledgement_preamble_bullet1, |
---|
83 | # config._acknowledgement_preamble_bullet2, |
---|
84 | # config._acknowledgement_preamble_bullet3, |
---|
85 | # config._acknowledgement_preamble_bullet4] |
---|
86 | #self.list1 = wx.StaticText(self, -1, "\t(1) " + items[0]) |
---|
87 | #self.list2 = wx.StaticText(self, -1, "\t(2) " + items[1]) |
---|
88 | #self.list3 = wx.StaticText(self, -1, "\t(3) " + items[2]) |
---|
89 | #self.list4 = wx.StaticText(self, -1, "\t(4) " + items[3]) |
---|
90 | #self.static_line = wx.StaticLine(self, 0) |
---|
91 | self.__set_properties() |
---|
92 | self.__do_layout() |
---|
93 | |
---|
94 | def __set_properties(self): |
---|
95 | """ |
---|
96 | :TODO - add method documentation |
---|
97 | """ |
---|
98 | # begin wxGlade: DialogAbout.__set_properties |
---|
99 | #self.preamble.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) |
---|
100 | #self.preamble.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) |
---|
101 | self.SetTitle("Fitting on GPU Options") |
---|
102 | #Increased size of box from (525, 225), SMK, 04/10/16 |
---|
103 | self.SetSize((400, 150)) |
---|
104 | # end wxGlade |
---|
105 | |
---|
106 | def __do_layout(self): |
---|
107 | """ |
---|
108 | :TODO - add method documentation |
---|
109 | """ |
---|
110 | # begin wxGlade: DialogAbout.__do_layout |
---|
111 | sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
112 | #sizer_titles = wx.BoxSizer(wx.VERTICAL) |
---|
113 | #sizer_titles.Add(self.preamble, 0, wx.ALL|wx.EXPAND, 5) |
---|
114 | #sizer_titles.Add(self.list1, 0, wx.ALL|wx.EXPAND, 5) |
---|
115 | #sizer_titles.Add(self.list2, 0, wx.ALL|wx.EXPAND, 5) |
---|
116 | #sizer_titles.Add(self.list3, 0, wx.ALL|wx.EXPAND, 5) |
---|
117 | #sizer_titles.Add(self.list4, 0, wx.ALL|wx.EXPAND, 5) |
---|
118 | #sizer_titles.Add(self.static_line, 0, wx.ALL|wx.EXPAND, 0) |
---|
119 | #sizer_titles.Add(self.ack, 0, wx.ALL|wx.EXPAND, 5) |
---|
120 | #sizer_main.Add(sizer_titles, -1, wx.ALL|wx.EXPAND, 5) |
---|
121 | self.SetAutoLayout(True) |
---|
122 | self.SetSizer(sizer_main) |
---|
123 | self.Layout() |
---|
124 | self.Centre() |
---|
125 | # end wxGlade |
---|
126 | |
---|
127 | |
---|
128 | ##### testing code ############################################################ |
---|
129 | class MyApp(wx.App): |
---|
130 | """ |
---|
131 | Class for running module as stand alone for testing |
---|
132 | """ |
---|
133 | def OnInit(self): |
---|
134 | """ |
---|
135 | Defines an init when running as standalone |
---|
136 | """ |
---|
137 | wx.InitAllImageHandlers() |
---|
138 | dialog = GpuOptions(None, -1, "") |
---|
139 | self.SetTopWindow(dialog) |
---|
140 | dialog.ShowModal() |
---|
141 | dialog.Destroy() |
---|
142 | return 1 |
---|
143 | |
---|
144 | # end of class MyApp |
---|
145 | |
---|
146 | if __name__ == "__main__": |
---|
147 | app = MyApp(0) |
---|
148 | app.MainLoop() |
---|