-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDescriptivesFrame.py
158 lines (133 loc) · 5.32 KB
/
DescriptivesFrame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
"""
DescriptivesFrame.py
A wxPython dialog to allow users to select a range of descriptive
statistics and variables for analysis.
"""
import wx
import salstat_stats, AllRoutines
class DescribeObj(object):
def __init__(self):
pass
class DFrame(wx.Dialog):
def __init__(self, parent, id, grid):
wx.Dialog.__init__(self, parent, id, "Describe data", \
size = (800,600),style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
self.grid = grid
self.res = None
self.alphaValNeeded = False
self.SetMinSize((400,300))
ico = wx.Icon('icons/PurpleIcon05_32.png',wx.BITMAP_TYPE_PNG)
self.SetIcon(ico)
sizerH01 = wx.BoxSizer(wx.HORIZONTAL)
self.panel1 = wx.Panel(self)
self.panel2 = wx.Panel(self)
sizerL = wx.BoxSizer(wx.VERTICAL)
sizerR = wx.BoxSizer(wx.VERTICAL)
panelR03 = wx.Panel(self, size=(-1, 30))
self.tests = wx.Notebook(self)
panelR02 = wx.Panel(self, size=(-1, 30))
cancelButton = wx.Button(panelR03, 1341, "Cancel", pos=(20,0), size=(90,-1))
okButton = wx.Button(panelR03, 1342, "Analyse", pos=(130,0), size=(90,-1))
okButton.SetDefault()
wx.StaticText(panelR02, -1, "Alpha value:", pos=(0,-1))
self.alphaText = wx.TextCtrl(panelR02, -1, pos=(120,0), size=(40,-1))
self.alphaText.Disable()
t1 = wx.StaticText(self, -1, "Describe these variables:")
t2 = wx.StaticText(self, -1, "Grouped by these variables:")
t3 = wx.StaticText(self, -1, " ")
t4 = wx.StaticText(self, -1, "Select descriptive statistics:")
self.GetVars()
self.varListDV = wx.CheckListBox(self, -1, choices=self.vars)
self.varListGRP = wx.CheckListBox(self, -1, choices=self.vars)
testshort, testlong = self.GetTests()
self.testListShort = wx.CheckListBox(self.tests, 1343, choices=testshort)
self.testListLong = wx.CheckListBox(self.tests, 1344, choices=testlong)
self.tests.AddPage(self.testListShort, "Most used tests")
self.tests.AddPage(self.testListLong, "All tests")
bord = 10
sizerL.Add(t1, 0, wx.ALL, border=bord)
sizerL.Add(self.varListDV, 1, wx.EXPAND|wx.ALL)
sizerL.Add(t2, 0, wx.ALL, border=bord)
sizerL.Add(self.varListGRP, 1, wx.EXPAND|wx.ALL)
sizerL.Add(t3, 0, wx.ALL, border=bord)
sizerR.Add(t4, 0, wx.ALL, border=bord)
sizerR.Add(self.tests, 1, wx.EXPAND|wx.ALL)
sizerR.Add(panelR02, 0, wx.ALL|wx.ALIGN_LEFT, border=bord)
sizerR.Add(panelR03, 0, wx.ALL|wx.ALIGN_RIGHT, border=bord)
sizerH01.Add(sizerL, 1, wx.EXPAND|wx.ALL, border=bord)
sizerH01.AddSpacer(0)
sizerH01.Add(sizerR, 1, wx.EXPAND|wx.ALL, border=bord)
self.SetAutoLayout(True)
self.SetSizer(sizerH01)
self.Layout()
self.Bind(wx.EVT_BUTTON, self.CancelButton, id=1341)
self.Bind(wx.EVT_BUTTON, self.OkayButton, id=1342)
self.Bind(wx.EVT_CHECKLISTBOX, self.CheckChecked, id=1343)
self.Bind(wx.EVT_CHECKLISTBOX, self.CheckChecked, id=1344)
def CheckChecked(self, event):
page = self.tests.GetSelection()
if page == 0:
stats = self.testListShort.GetCheckedStrings()
elif page == 1:
stats = self.testListLong.GetCheckedStrings()
alphaFlag = False
for stat in stats:
if stat in self.alphaTests:
self.alphaText.Enable()
self.alphaValNeeded = True
alphaFlag = True
if not alphaFlag:
self.alphaText.Disable()
self.alphaValNeeded = False
def CancelButton(self, event):
self.res = "cancel"
self.alpha = None
self.Close()
def OkayButton(self, event):
self.res = "ok"
alpha_val = self.alphaText.GetValue()
if self.CanClose():
self.Close()
def GetValues(self):
DVs = self.varListDV.GetChecked()
self.DVs = []
for DV in DVs:
self.DVs.append(self.ColNums[DV])
self.GRPs = self.varListGRP.GetChecked()
page = self.tests.GetSelection()
if page == 0:
self.stats = self.testListShort.GetCheckedStrings()
elif page == 1:
self.stats = self.testListLong.GetCheckedStrings()
def CanClose(self):
self.alpha = None
if self.alphaValNeeded:
try:
self.alpha = float(self.alphaText.GetValue())
if (self.alpha > 0.0) and (self.alpha < 1.0):
return True
else:
return False
except ValueError:
return False
else:
return True
def GetVars(self):
if self.grid:
self.vars, self.ColNums = self.grid.GetUsedCols()
else:
self.vars = ["var 001", "var 002","var 003", "var 004"]
self.ColNums = range(len(self.vars))
def GetTests(self):
testshort = AllRoutines.GetMostUsedTests()
testlong = AllRoutines.GetAllTests()
self.alphaTests = AllRoutines.GetExtraTests()
return testshort, testlong
def OnClose(self, event):
self.Close()
if __name__ == '__main__':
app = wx.App()
frame = DFrame(None, -1, None)
frame.ShowModal()
print (frame.alpha)
app.MainLoop()