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 | """ |
---|
11 | for the properties window |
---|
12 | """ |
---|
13 | self.parent = parent |
---|
14 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
15 | sizer = wx.GridBagSizer(5,5) |
---|
16 | |
---|
17 | x_size = 70 |
---|
18 | |
---|
19 | ix = 1 |
---|
20 | iy = 1 |
---|
21 | sizer.Add(wx.StaticText(self, -1, 'X'), (iy, ix)) |
---|
22 | ix += 2 |
---|
23 | sizer.Add(wx.StaticText(self, -1, 'Y'), (iy, ix)) |
---|
24 | ix += 2 |
---|
25 | sizer.Add(wx.StaticText(self, -1, 'View'), (iy, ix)) |
---|
26 | iy += 1 |
---|
27 | ix = 1 |
---|
28 | self.xvalue = wx.ComboBox(self, -1) |
---|
29 | x_size += self.xvalue.GetSize()[0] |
---|
30 | sizer.Add(self.xvalue, (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
31 | |
---|
32 | ix += 2 |
---|
33 | self.yvalue = wx.ComboBox(self, -1) |
---|
34 | x_size += self.yvalue.GetSize()[0] |
---|
35 | sizer.Add(self.yvalue, (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
36 | |
---|
37 | ix += 2 |
---|
38 | self.view = wx.ComboBox(self, -1) |
---|
39 | x_size += self.view.GetSize()[0] |
---|
40 | self.view.SetMinSize((160, 30)) |
---|
41 | sizer.Add(self.view, (iy,ix), (1,1), |
---|
42 | wx.EXPAND|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
43 | self.SetMinSize((x_size, 50)) |
---|
44 | vbox.Add(sizer, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
45 | |
---|
46 | btCancel = wx.Button(self, wx.ID_CANCEL,'Cancel') |
---|
47 | btOk = wx.Button(self, wx.ID_OK, "OK") |
---|
48 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
49 | sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
50 | sizer_button.Add(btOk, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
51 | sizer_button.Add(btCancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
52 | vbox.Add(sizer_button, 0, |
---|
53 | wx.EXPAND|wx.TOP|wx.BOTTOM|wx.ADJUST_MINSIZE, 10) |
---|
54 | # scale value for x |
---|
55 | self.xvalue.SetValue("ln(x)") |
---|
56 | self.xvalue.Insert("x", 0) |
---|
57 | self.xvalue.Insert("x^(2)", 1) |
---|
58 | self.xvalue.Insert("x^(4)", 2) |
---|
59 | self.xvalue.Insert("ln(x)", 3) |
---|
60 | self.xvalue.Insert("log10(x)", 4) |
---|
61 | self.xvalue.Insert("log10(x^(4))", 5) |
---|
62 | |
---|
63 | # scale value for y |
---|
64 | self.yvalue.SetValue("ln(y)") |
---|
65 | self.yvalue.Insert("y", 0) |
---|
66 | self.yvalue.Insert("1/y", 1) |
---|
67 | self.yvalue.Insert("ln(y)", 2) |
---|
68 | self.yvalue.Insert("y^(2)", 3) |
---|
69 | self.yvalue.Insert("y*x^(4)", 4) |
---|
70 | self.yvalue.Insert("1/sqrt(y)", 5) |
---|
71 | self.yvalue.Insert("log10(y)", 6) |
---|
72 | self.yvalue.Insert("ln(y*x)", 7) |
---|
73 | self.yvalue.Insert("ln(y*x^(2))", 8) |
---|
74 | self.yvalue.Insert("ln(y*x^(4))", 9) |
---|
75 | self.yvalue.Insert("log10(y*x^(4))", 10) |
---|
76 | # type of view or model used |
---|
77 | self.view.SetValue("--") |
---|
78 | self.view.Insert("--", 0) |
---|
79 | self.view.Insert("Linear y vs x", 1) |
---|
80 | self.view.Insert("Guinier lny vs x^(2)", 2) |
---|
81 | self.view.Insert("XS Guinier ln(y*x) vs x^(2)", 3) |
---|
82 | self.view.Insert("Porod y*x^(4) vs x^(4)", 4) |
---|
83 | self.SetSizer(vbox) |
---|
84 | self.Fit() |
---|
85 | self.Centre() |
---|
86 | |
---|
87 | def setValues(self, x, y, view): |
---|
88 | """ |
---|
89 | """ |
---|
90 | return self.xvalue.SetValue(x), self.yvalue.SetValue(y),\ |
---|
91 | self.view.SetValue(view) |
---|
92 | |
---|
93 | def getValues(self): |
---|
94 | """ |
---|
95 | """ |
---|
96 | return self.xvalue.GetValue(), self.yvalue.GetValue(),\ |
---|
97 | self.view.GetValue() |
---|