-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathProgramDlg.py
More file actions
76 lines (57 loc) · 3.07 KB
/
ProgramDlg.py
File metadata and controls
76 lines (57 loc) · 3.07 KB
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
import wx
from Program import Program
from HeeksObjDlg import HeeksObjDlg
from HDialog import HControl
class ProgramDlg(HeeksObjDlg):
def __init__(self, object, title = "Program"):
HeeksObjDlg.__init__(self, object, title, add_picture = False)
def AddLeftControls(self):
# add the controls in one column
self.machines = self.object.GetMachines()
choices = []
for machine in self.machines:
choices.append(machine.description)
self.cmbMachine = wx.ComboBox(self, choices = choices)
self.MakeLabelAndControl('Machine', self.cmbMachine).AddToSizer(self.sizerLeft)
self.chkOutputSame = wx.CheckBox( self, label = "output file name follows data file name" )
HControl(wx.ALL, self.chkOutputSame).AddToSizer(self.sizerLeft)
self.Bind(wx.EVT_CHECKBOX, self.OnCheckOutputSame, self.chkOutputSame)
self.txtOutputFile = wx.TextCtrl(self)
self.lblOutputFile, self.btnOutputFile = self.AddFileNameControl(self.sizerLeft, "output file", self.txtOutputFile)
self.cmbUnits = wx.ComboBox(self, choices = ["mm", "inch"])
self.MakeLabelAndControl('Units', self.cmbUnits).AddToSizer(self.sizerLeft)
self.chkAddComments = wx.CheckBox(self, wx.ID_ANY, 'Add Comments')
HControl(wx.ALL, self.chkAddComments).AddToSizer(self.sizerLeft)
self.txtMaterial = wx.TextCtrl(self, wx.ID_ANY)
self.MakeLabelAndControl('Material', self.txtMaterial).AddToSizer(self.sizerLeft)
def SetDefaultFocus(self):
self.cmbMachine.SetFocus()
def EnableControls(self):
output_same = self.chkOutputSame.GetValue()
self.txtOutputFile.Enable(output_same == False)
self.btnOutputFile.Enable(output_same == False)
self.lblOutputFile.Enable(output_same == False)
def OnCheckOutputSame(self, event):
if self.ignore_event_functions: return
self.EnableControls()
def GetDataRaw(self):
if self.cmbMachine.GetSelection() != wx.NOT_FOUND:
self.object.machine = self.machines[self.cmbMachine.GetSelection()]
self.object.output_file_name_follows_data_file_name = self.chkOutputSame.GetValue()
self.object.output_file = self.txtOutputFile.GetValue()
if self.cmbUnits.GetValue() == "inch":
self.object.units = 25.4
else:
self.object.units = 1.0
self.object.add_comments = self.chkAddComments.GetValue()
self.object.material = self.txtMaterial.GetValue()
def SetFromDataRaw(self):
self.cmbMachine.SetValue(self.object.machine.description)
self.chkOutputSame.SetValue(self.object.output_file_name_follows_data_file_name)
self.txtOutputFile.SetValue(self.object.output_file)
if self.object.units == 25.4:
self.cmbUnits.SetValue("inch")
else:
self.cmbUnits.SetValue("mm")
self.chkAddComments.SetValue(self.object.add_comments)
self.txtMaterial.SetValue(self.object.material)