def InputExtrusionHeight(self, value, extrude_makes_a_solid, taper_angle): dlg = HDialog('Make Extrusion') sizerMain = wx.BoxSizer(wx.VERTICAL) value_control = LengthCtrl(dlg) value_control.SetValue(value) dlg.AddLabelAndControl(sizerMain, 'Height', value_control) solid_check_box = None if extrude_makes_a_solid != None: solid_check_box = wx.CheckBox(dlg, label='Extrude makes a solid') solid_check_box.SetValue(extrude_makes_a_solid) sizerMain.Add(solid_check_box, 0, wx.ALL | wx.ALIGN_LEFT, control_border) taper_angle_control = None if taper_angle != None: taper_angle_control = DoubleCtrl(dlg) taper_angle_control.SetValue(taper_angle) dlg.AddLabelAndControl(sizerMain, 'Taper Outward Angle', taper_angle_control) dlg.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain) dlg.SetSizer(sizerMain) sizerMain.Fit(dlg) value_control.SetFocus() if dlg.ShowModal() == wx.ID_OK: value = value_control.GetValue() if extrude_makes_a_solid != None: extrude_makes_a_solid = solid_check_box.GetValue() if taper_angle != None: taper_angle = taper_angle_control.GetValue() return True, value, extrude_makes_a_solid, taper_angle return False, value, extrude_makes_a_solid, taper_angle
def InputLength(self, prompt, name, value): dlg = HDialog('Input') sizerMain = wx.BoxSizer(wx.VERTICAL) static_label = wx.StaticText(dlg, label = prompt) sizerMain.Add( static_label, 0, wx.ALL, wx.ALIGN_LEFT, control_border ) value_control = LengthCtrl(dlg) value_control.SetValue(value) dlg.AddLabelAndControl( sizerMain, name, value_control ) dlg.MakeOkAndCancel( wx.HORIZONTAL ).AddToSizer( sizerMain ) dlg.SetSizer( sizerMain ) sizerMain.SetSizeHints(dlg) sizerMain.Fit(dlg) value_control.SetFocus() if dlg.ShowModal() == wx.ID_OK: return value_control.GetValue() return None
class DepthOpDlg(SpeedOpDlg): def __init__(self, object, drill_pictures, title): self.drill_pictures = drill_pictures SpeedOpDlg.__init__(self, object, False, title) def AddLeftControls(self): self.lgthClearanceHeight = LengthCtrl(self) self.MakeLabelAndControl('Clearance Height', self.lgthClearanceHeight).AddToSizer( self.sizerLeft) self.lgthRapidDownToHeight = LengthCtrl(self) self.MakeLabelAndControl('Rapid Safety Space', self.lgthRapidDownToHeight).AddToSizer( self.sizerLeft) self.lgthStartDepth = LengthCtrl(self) self.MakeLabelAndControl( 'Start Depth', self.lgthStartDepth).AddToSizer(self.sizerLeft) self.lgthFinalDepth = LengthCtrl(self) self.MakeLabelAndControl( 'Final Depth', self.lgthFinalDepth).AddToSizer(self.sizerLeft) self.lgthStepDown = LengthCtrl(self) self.MakeLabelAndControl('Step Down', self.lgthStepDown).AddToSizer(self.sizerLeft) self.lgthZFinishDepth = LengthCtrl(self) self.MakeLabelAndControl( 'Z Finish Depth', self.lgthZFinishDepth).AddToSizer(self.sizerLeft) self.lgthZThruDepth = LengthCtrl(self) self.MakeLabelAndControl( 'Z Through Depth', self.lgthZThruDepth).AddToSizer(self.sizerLeft) SpeedOpDlg.AddLeftControls(self) def AddRightControls(self): SpeedOpDlg.AddRightControls(self) def SetDefaultFocus(self): self.lgthClearanceHeight.SetFocus() def GetDataRaw(self): self.object.clearance_height = self.lgthClearanceHeight.GetValue() self.object.rapid_safety_space = self.lgthRapidDownToHeight.GetValue() self.object.start_depth = self.lgthStartDepth.GetValue() self.object.final_depth = self.lgthFinalDepth.GetValue() self.object.step_down = self.lgthStepDown.GetValue() self.object.z_finish_depth = self.lgthZFinishDepth.GetValue() self.object.z_thru_depth = self.lgthZThruDepth.GetValue() SpeedOpDlg.GetDataRaw(self) def SetFromDataRaw(self): self.lgthClearanceHeight.SetValue(self.object.clearance_height) self.lgthRapidDownToHeight.SetValue(self.object.rapid_safety_space) self.lgthStartDepth.SetValue(self.object.start_depth) self.lgthFinalDepth.SetValue(self.object.final_depth) self.lgthStepDown.SetValue(self.object.step_down) self.lgthZFinishDepth.SetValue(self.object.z_finish_depth) self.lgthZThruDepth.SetValue(self.object.z_thru_depth) SpeedOpDlg.SetFromDataRaw(self) def SetPictureByWindow(self, w): if w == self.lgthClearanceHeight: DepthOpDlg.SetPictureByName( self, "drill clearance height" if self.drill_pictures else "clearance height") elif w == self.lgthRapidDownToHeight: DepthOpDlg.SetPictureByName( self, "drill rapid down height" if self.drill_pictures else "rapid down height") elif w == self.lgthStartDepth: DepthOpDlg.SetPictureByName( self, "drill start depth" if self.drill_pictures else "start depth") elif w == self.lgthFinalDepth: DepthOpDlg.SetPictureByName( self, "drill final depth" if self.drill_pictures else "final depth") elif w == self.lgthStepDown: DepthOpDlg.SetPictureByName( self, "drill step down" if self.drill_pictures else "step down") elif w == self.lgthZFinishDepth: DepthOpDlg.SetPictureByName( self, "drill z finish depth" if self.drill_pictures else "z finish depth") elif w == self.lgthZThruDepth: DepthOpDlg.SetPictureByName( self, "drill z thru depth" if self.drill_pictures else "z thru depth") else: SpeedOpDlg.SetPictureByWindow(self, w) def SetPictureByName(self, name): self.SetPictureByNameAndFolder(name, 'depthop')
class FromAndToDlg(HDialog): def __init__(self, fromp, to, ncopies, title): HDialog.__init__(self, title) self.ignore_event_functions = True sizerMain = wx.BoxSizer(wx.VERTICAL) self.ncopies = ncopies self.fromp = fromp self.to = to if ncopies: self.txt_num_copies = wx.TextCtrl(self, wx.ID_ANY, str(ncopies)) self.AddLabelAndControl(sizerMain, 'Number of Copies', self.txt_num_copies) sizerPos = wx.BoxSizer(wx.VERTICAL) sizerMain.Add(sizerPos, 0, wx.EXPAND) self.btnFrom = wx.Button(self, label='Select') self.AddLabelAndControl(sizerPos, 'Position to move from', self.btnFrom) self.fromx = LengthCtrl(self) self.AddLabelAndControl(sizerPos, 'X', self.fromx) self.fromy = LengthCtrl(self) self.AddLabelAndControl(sizerPos, 'Y', self.fromy) self.fromz = LengthCtrl(self) self.AddLabelAndControl(sizerPos, 'Z', self.fromz) self.fromx.SetValue(fromp.x) self.fromy.SetValue(fromp.y) self.fromz.SetValue(fromp.z) sizerPos2 = wx.BoxSizer(wx.VERTICAL) sizerMain.Add(sizerPos2, 0, wx.EXPAND) self.btnTo = wx.Button(self, label='Select') self.AddLabelAndControl(sizerPos, 'Position to move to', self.btnTo) self.tox = LengthCtrl(self) self.AddLabelAndControl(sizerPos, 'X', self.tox) self.toy = LengthCtrl(self) self.AddLabelAndControl(sizerPos, 'Y', self.toy) self.toz = LengthCtrl(self) self.AddLabelAndControl(sizerPos, 'Z', self.toz) self.tox.SetValue(to.x) self.toy.SetValue(to.y) self.toz.SetValue(to.z) self.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain) self.SetSizer(sizerMain) sizerMain.SetSizeHints(self) sizerMain.Fit(self) if ncopies: self.txt_num_copies.SetFocus() else: self.fromx.SetFocus() self.Bind(wx.EVT_BUTTON, self.OnPickFrom, self.btnFrom) self.Bind(wx.EVT_BUTTON, self.OnPickTo, self.btnTo) self.ignore_event_functions = False def OnPickFrom(self, event): self.EndModal(self.btnFrom.GetId()) def OnPickTo(self, event): self.EndModal(self.btnTo.GetId()) def GetAllValues(self): self.fromp.x = self.fromx.GetValue() self.fromp.y = self.fromy.GetValue() self.fromp.z = self.fromz.GetValue() self.to.x = self.tox.GetValue() self.to.y = self.toy.GetValue() self.to.z = self.toz.GetValue() ncopies = None if self.ncopies: ncopies = int(self.txt_num_copies.GetValue()) return self.fromp, self.to, ncopies