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) |
---|
26 | x_size += self.xvalue.GetSize()[0] |
---|
27 | sizer.Add(self.xvalue, (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
28 | |
---|
29 | ix += 2 |
---|
30 | self.yvalue = wx.ComboBox(self, -1) |
---|
31 | x_size += self.yvalue.GetSize()[0] |
---|
32 | sizer.Add(self.yvalue, (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
33 | |
---|
34 | ix += 2 |
---|
35 | self.view = wx.ComboBox(self, -1) |
---|
36 | x_size += self.view.GetSize()[0] |
---|
37 | self.view.SetMinSize((160, 30)) |
---|
38 | sizer.Add(self.view, (iy, ix), (1, 1), |
---|
39 | wx.EXPAND | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
40 | self.SetMinSize((x_size, 50)) |
---|
41 | vbox.Add(sizer, 0, wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
42 | |
---|
43 | cancel_button = wx.Button(self, wx.ID_CANCEL, 'Cancel') |
---|
44 | ok_button = wx.Button(self, wx.ID_OK, "OK") |
---|
45 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
46 | sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
47 | sizer_button.Add(ok_button, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
48 | sizer_button.Add(cancel_button, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
49 | vbox.Add(sizer_button, 0, |
---|
50 | wx.EXPAND | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, 10) |
---|
51 | # scale value for x |
---|
52 | self.xvalue.SetValue("ln(x)") |
---|
53 | self.xvalue.Insert("x", 0) |
---|
54 | self.xvalue.Insert("x^(2)", 1) |
---|
55 | self.xvalue.Insert("x^(4)", 2) |
---|
56 | self.xvalue.Insert("ln(x)", 3) |
---|
57 | self.xvalue.Insert("log10(x)", 4) |
---|
58 | self.xvalue.Insert("log10(x^(4))", 5) |
---|
59 | |
---|
60 | # scale value for y |
---|
61 | self.yvalue.SetValue("ln(y)") |
---|
62 | self.yvalue.Insert("y", 0) |
---|
63 | self.yvalue.Insert("1/y", 1) |
---|
64 | self.yvalue.Insert("ln(y)", 2) |
---|
65 | self.yvalue.Insert("y^(2)", 3) |
---|
66 | self.yvalue.Insert("y*x^(4)", 4) |
---|
67 | self.yvalue.Insert("1/sqrt(y)", 5) |
---|
68 | self.yvalue.Insert("log10(y)", 6) |
---|
69 | self.yvalue.Insert("ln(y*x)", 7) |
---|
70 | self.yvalue.Insert("ln(y*x^(2))", 8) |
---|
71 | self.yvalue.Insert("ln(y*x^(4))", 9) |
---|
72 | self.yvalue.Insert("log10(y*x^(4))", 10) |
---|
73 | # type of view or model used |
---|
74 | self.view.SetValue("--") |
---|
75 | self.view.Insert("--", 0) |
---|
76 | self.view.Insert("Linear y vs x", 1) |
---|
77 | self.view.Insert("Guinier lny vs x^(2)", 2) |
---|
78 | self.view.Insert("XS Guinier ln(y*x) vs x^(2)", 3) |
---|
79 | self.view.Insert("Porod y*x^(4) vs x^(4)", 4) |
---|
80 | # This did not work in 3.1.2 and does not work now. |
---|
81 | # prefer to fix (should not be too hard) but for the moment |
---|
82 | # am removing as an option the user sees so they don't get |
---|
83 | # disappointed. PDB 7/10/2016 |
---|
84 | # self.view.Insert("Kratky y*x^(2) vs x", 5) |
---|
85 | self.SetSizer(vbox) |
---|
86 | self.Fit() |
---|
87 | self.Centre() |
---|
88 | |
---|
89 | def setValues(self, x, y, view): |
---|
90 | """ |
---|
91 | """ |
---|
92 | return self.xvalue.SetValue(x), self.yvalue.SetValue(y), \ |
---|
93 | self.view.SetValue(view) |
---|
94 | |
---|
95 | def getValues(self): |
---|
96 | """ |
---|
97 | """ |
---|
98 | return self.xvalue.GetValue(), self.yvalue.GetValue(), \ |
---|
99 | self.view.GetValue() |
---|