1 | """ |
---|
2 | """ |
---|
3 | import wx |
---|
4 | |
---|
5 | class Properties(wx.Dialog): |
---|
6 | """ |
---|
7 | """ |
---|
8 | def __init__(self, parent, id=-1, title="Select the scale of the graph"): |
---|
9 | wx.Dialog.__init__(self, parent, id, title) |
---|
10 | self.parent = parent |
---|
11 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
12 | sizer = wx.GridBagSizer(5, 5) |
---|
13 | |
---|
14 | x_size = 70 |
---|
15 | |
---|
16 | ix = 1 |
---|
17 | iy = 1 |
---|
18 | sizer.Add(wx.StaticText(self, -1, 'X'), (iy, ix)) |
---|
19 | ix += 2 |
---|
20 | sizer.Add(wx.StaticText(self, -1, 'Y'), (iy, ix)) |
---|
21 | ix += 2 |
---|
22 | sizer.Add(wx.StaticText(self, -1, 'View'), (iy, ix)) |
---|
23 | iy += 1 |
---|
24 | ix = 1 |
---|
25 | self.xvalue = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
26 | x_size += self.xvalue.GetSize()[0] |
---|
27 | sizer.Add(self.xvalue, (iy, ix), (1, 1), wx.ADJUST_MINSIZE, 0) |
---|
28 | |
---|
29 | ix += 2 |
---|
30 | self.yvalue = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
31 | x_size += self.yvalue.GetSize()[0] |
---|
32 | sizer.Add(self.yvalue, (iy, ix), (1, 1), wx.ADJUST_MINSIZE, 0) |
---|
33 | |
---|
34 | ix += 2 |
---|
35 | self.view = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
36 | self.view.Bind(wx.EVT_COMBOBOX, self.viewChanged) |
---|
37 | x_size += self.view.GetSize()[0] |
---|
38 | self.view.SetMinSize((160, 30)) |
---|
39 | sizer.Add(self.view, (iy, ix), (1, 1), |
---|
40 | wx.EXPAND | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
41 | self.SetMinSize((x_size, 50)) |
---|
42 | vbox.Add(sizer, 0, wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
43 | |
---|
44 | cancel_button = wx.Button(self, wx.ID_CANCEL, 'Cancel') |
---|
45 | ok_button = wx.Button(self, wx.ID_OK, "OK") |
---|
46 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
47 | sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
48 | sizer_button.Add(ok_button, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
49 | sizer_button.Add(cancel_button, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
50 | vbox.Add(sizer_button, 0, |
---|
51 | wx.EXPAND | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, 10) |
---|
52 | # scale value for x |
---|
53 | self.xvalue.SetValue("ln(x)") |
---|
54 | self.xvalue.Insert("x", 0) |
---|
55 | self.xvalue.Insert("x^(2)", 1) |
---|
56 | self.xvalue.Insert("x^(4)", 2) |
---|
57 | self.xvalue.Insert("ln(x)", 3) |
---|
58 | self.xvalue.Insert("log10(x)", 4) |
---|
59 | self.xvalue.Insert("log10(x^(4))", 5) |
---|
60 | |
---|
61 | # scale value for y |
---|
62 | self.yvalue.SetValue("ln(y)") |
---|
63 | self.yvalue.Insert("y", 0) |
---|
64 | self.yvalue.Insert("1/y", 1) |
---|
65 | self.yvalue.Insert("ln(y)", 2) |
---|
66 | self.yvalue.Insert("y^(2)", 3) |
---|
67 | self.yvalue.Insert("y*x^(2)", 4) |
---|
68 | self.yvalue.Insert("y*x^(4)", 5) |
---|
69 | self.yvalue.Insert("1/sqrt(y)", 6) |
---|
70 | self.yvalue.Insert("log10(y)", 7) |
---|
71 | self.yvalue.Insert("ln(y*x)", 8) |
---|
72 | self.yvalue.Insert("ln(y*x^(2))", 9) |
---|
73 | self.yvalue.Insert("ln(y*x^(4))", 10) |
---|
74 | self.yvalue.Insert("log10(y*x^(4))", 11) |
---|
75 | # type of view or model used |
---|
76 | self.view.SetValue("--") |
---|
77 | self.view.Insert("--", 0) |
---|
78 | self.view.Insert("Linear y vs x", 1) |
---|
79 | self.view.Insert("Guinier lny vs x^(2)", 2) |
---|
80 | self.view.Insert("XS Guinier ln(y*x) vs x^(2)", 3) |
---|
81 | self.view.Insert("Porod y*x^(4) vs x^(4)", 4) |
---|
82 | self.view.Insert("Kratky y*x^(2) vs x", 5) |
---|
83 | self.SetSizer(vbox) |
---|
84 | self.Fit() |
---|
85 | self.Centre() |
---|
86 | |
---|
87 | def viewChanged(self, event): |
---|
88 | event.Skip() |
---|
89 | view = self.view.GetValue() |
---|
90 | if view == "Linear y vs x": |
---|
91 | self.xvalue.SetValue("x") |
---|
92 | self.yvalue.SetValue("y") |
---|
93 | elif view == "Guinier lny vs x^(2)": |
---|
94 | self.xvalue.SetValue("x^(2)") |
---|
95 | self.yvalue.SetValue("ln(y)") |
---|
96 | elif view == "XS Guinier ln(y*x) vs x^(2)": |
---|
97 | self.xvalue.SetValue("x^(2)") |
---|
98 | self.yvalue.SetValue("ln(y*x)") |
---|
99 | elif view == "Porod y*x^(4) vs x^(4)": |
---|
100 | self.xvalue.SetValue("x^(4)") |
---|
101 | self.yvalue.SetValue("y*x^(4)") |
---|
102 | elif view == "Kratky y*x^(2) vs x": |
---|
103 | self.xvalue.SetValue("x") |
---|
104 | self.yvalue.SetValue("y*x^(2)") |
---|
105 | |
---|
106 | def setValues(self, x, y, view): |
---|
107 | """ |
---|
108 | """ |
---|
109 | return self.xvalue.SetValue(x), self.yvalue.SetValue(y), \ |
---|
110 | self.view.SetValue(view) |
---|
111 | |
---|
112 | def getValues(self): |
---|
113 | """ |
---|
114 | """ |
---|
115 | return self.xvalue.GetValue(), self.yvalue.GetValue(), \ |
---|
116 | self.view.GetValue() |
---|