def __init__(self, parent, app, reprap): self.model = None self.parent = parent self.app = app self.reprap = reprap self.logger = self.app.logger self.appsettings = app.settings self.settings = app.settings.manualctl wx.Window.__init__(self, parent, wx.ID_ANY, size=(-1, -1), style=wx.SIMPLE_BORDER) path = os.path.join(self.settings.cmdfolder, "images", "axis.png") bmp = wx.BitmapFromImage(wx.Image(path, wx.BITMAP_TYPE_PNG), -1) self.axes = ImageMap(self, bmp) self.axes.setHotSpots(self.onImageClick, imageMap) sizerMoveFrame = wx.GridBagSizer() sizerMoveFrame.AddSpacer((20, 20), pos=(0,0)) sizerMoveFrame.Add(self.axes, pos=(1,1), span=(1,4)) sizerMoveFrame.AddSpacer((10, 10), pos=(2,0)) self.font12bold = wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) self.font12 = wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) t = wx.StaticText(self, wx.ID_ANY, "mm/min", style=wx.ALIGN_LEFT, size=(160, -1)) t.SetFont(self.font12bold) sizerMoveFrame.Add(t, pos=(3,3)) t = wx.StaticText(self, wx.ID_ANY, "XY Speed:", style=wx.ALIGN_RIGHT, size=(160, -1)) t.SetFont(self.font12) sizerMoveFrame.Add(t, pos=(4,2)) self.tXYSpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.xyspeed), size=(80, -1), style=wx.TE_RIGHT) self.tXYSpeed.SetFont(self.font12) sizerMoveFrame.Add(self.tXYSpeed, pos=(4,3)) self.tXYSpeed.Bind(wx.EVT_KILL_FOCUS, self.evtXYSpeedKillFocus) sizerMoveFrame.AddSpacer((10, 10), pos=(5,0)) t = wx.StaticText(self, wx.ID_ANY, "Z Speed:", style=wx.ALIGN_RIGHT, size=(160, -1)) t.SetFont(self.font12) sizerMoveFrame.Add(t, pos=(6,2)) self.tZSpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.zspeed), size=(80, -1), style=wx.TE_RIGHT) self.tZSpeed.SetFont(self.font12) sizerMoveFrame.Add(self.tZSpeed, pos=(6,3)) self.tZSpeed.Bind(wx.EVT_KILL_FOCUS, self.evtZSpeedKillFocus) self.SetSizer(sizerMoveFrame) self.Layout() self.Fit()
#Load image map, first from wiki try: imageconf = bot.get_wiki_yaml('conf/imagelist') bot.log('Loaded imagelist from wiki') except Exception as e: bot.log("Couldn't load imagelist from wiki: " + str(sys.exc_info()[0])) imageconf = None # Fall back to local file if not imageconf: imageconf = yaml.load(open('imagelist.yaml')) shutil.copy('imagelist.yaml','imagelist.%d.yaml' % (time.time())) bot.log('Loaded imagelist from file') imagemap = ImageMap(imageconf, bot.config['bot']['animated_extensions'], bot.config['bot']['switchable_extensions']) markdown = imagemap.get_formatted() # Update the image map on the wiki try: try: curmd = bot.get_wiki('imagelist') except praw.errors.NotFound: curmd = None if(curmd != markdown): bot.write_wiki('imagelist', markdown, 'Updating image list') bot.log("Wrote updated imagelist to wiki") except Exception as e: bot.log("Couldn't update wiki page: " + str(sys.exc_info()[0]))
class MoveAxis(wx.Window): def __init__(self, parent, app, reprap): self.model = None self.parent = parent self.app = app self.reprap = reprap self.logger = self.app.logger self.appsettings = app.settings self.settings = app.settings.manualctl wx.Window.__init__(self, parent, wx.ID_ANY, size=(-1, -1), style=wx.SIMPLE_BORDER) path = os.path.join(self.settings.cmdfolder, "images", "axis.png") bmp = wx.BitmapFromImage(wx.Image(path, wx.BITMAP_TYPE_PNG), -1) self.axes = ImageMap(self, bmp) self.axes.setHotSpots(self.onImageClick, imageMap) sizerMoveFrame = wx.GridBagSizer() sizerMoveFrame.AddSpacer((20, 20), pos=(0,0)) sizerMoveFrame.Add(self.axes, pos=(1,1), span=(1,4)) sizerMoveFrame.AddSpacer((10, 10), pos=(2,0)) self.font12bold = wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) self.font12 = wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) t = wx.StaticText(self, wx.ID_ANY, "mm/min", style=wx.ALIGN_LEFT, size=(160, -1)) t.SetFont(self.font12bold) sizerMoveFrame.Add(t, pos=(3,3)) t = wx.StaticText(self, wx.ID_ANY, "XY Speed:", style=wx.ALIGN_RIGHT, size=(160, -1)) t.SetFont(self.font12) sizerMoveFrame.Add(t, pos=(4,2)) self.tXYSpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.xyspeed), size=(80, -1), style=wx.TE_RIGHT) self.tXYSpeed.SetFont(self.font12) sizerMoveFrame.Add(self.tXYSpeed, pos=(4,3)) self.tXYSpeed.Bind(wx.EVT_KILL_FOCUS, self.evtXYSpeedKillFocus) sizerMoveFrame.AddSpacer((10, 10), pos=(5,0)) t = wx.StaticText(self, wx.ID_ANY, "Z Speed:", style=wx.ALIGN_RIGHT, size=(160, -1)) t.SetFont(self.font12) sizerMoveFrame.Add(t, pos=(6,2)) self.tZSpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.zspeed), size=(80, -1), style=wx.TE_RIGHT) self.tZSpeed.SetFont(self.font12) sizerMoveFrame.Add(self.tZSpeed, pos=(6,3)) self.tZSpeed.Bind(wx.EVT_KILL_FOCUS, self.evtZSpeedKillFocus) self.SetSizer(sizerMoveFrame) self.Layout() self.Fit() def onImageClick(self, label): if label in dispatch.keys(): cmd = dispatch[label] if cmd.startswith("G1 "): if "X" in label or "Y" in label: try: v = float(self.tXYSpeed.GetValue()) except: self.logger.LogError("Invalid value for XY Speed: %s" % self.tXYSpeed.GetValue()) v = 0.0 speed = " F%.3f" % v elif "Z" in label: try: v = float(self.tZSpeed.GetValue()) except: self.logger.LogError("Invalid value for Z Speed: %s" % self.tZSpeed.GetValue()) v = 0.0 speed = " F%.3f" % v else: speed = "" self.reprap.send_now("G91") self.reprap.send_now(cmd + speed) self.reprap.send_now("G90") else: self.reprap.send_now(cmd) else: self.logger.LogError("unknown label: (%s)" % label) def evtXYSpeedKillFocus(self, evt): try: float(self.tXYSpeed.GetValue()) except: self.logger.LogError("Invalid value for XY Speed: %s" % self.tXYSpeed.GetValue()) def evtZSpeedKillFocus(self, evt): try: float(self.tZSpeed.GetValue()) except: self.logger.LogError("Invalid value for Z Speed: %s" % self.tZSpeed.GetValue())
def __init__(self, parent, reprap, prtName): self.model = None self.parent = parent self.log = self.parent.log self.images = parent.images self.settings = self.parent.settings self.reprap = reprap self.prtName = prtName self.currentTool = 1 wx.Window.__init__(self, parent, wx.ID_ANY, size=(-1, -1), style=wx.SIMPLE_BORDER) self.axesXY = ImageMap(self, self.images.pngControl_xy) self.axesXY.SetToolTip("Move X/Y axes") self.axesXY.setHotSpots(self.onImageClick, imageMapXY) self.axisZ = ImageMap(self, self.images.pngControl_z) self.axisZ.SetToolTip("Move Z axis") self.axisZ.setHotSpots(self.onImageClick, imageMapZ) self.axisE = ImageMap(self, self.images.pngControl_e) self.axisE.SetToolTip("Extrude/Retract") self.axisE.setHotSpots(self.onImageClick, imageMapE) self.stopMotors = ImageMap(self, self.images.pngStopmotors) self.stopMotors.SetToolTip("Stop all motors") self.stopMotors.setHotSpots(self.onImageClick, imageMapStopM) szWindow = wx.BoxSizer(wx.VERTICAL) szManualCtl = wx.BoxSizer(wx.HORIZONTAL) szManualCtl.AddSpacer(20) szManualCtl.Add(self.axesXY) szManualCtl.AddSpacer(10) szManualCtl.Add(self.axisZ) szManualCtl.AddSpacer(10) sz = wx.BoxSizer(wx.VERTICAL) if self.settings.nextruders > 1: sz.AddSpacer(10) self.chTool = wx.Choice( self, wx.ID_ANY, choices=[ "Tool %d" % i for i in range(self.settings.nextruders) ]) self.Bind(wx.EVT_CHOICE, self.onToolChoice, self.chTool) sz.Add(self.chTool) self.chTool.SetSelection(0) sz.Add(self.axisE) self.cbCold = wx.CheckBox(self, wx.ID_ANY, "Cold") self.cbCold.SetToolTip("Allow cold extrusion") sz.Add(self.cbCold, 1, wx.ALIGN_CENTER_HORIZONTAL, 1) self.cbCold.SetValue(False) self.Bind(wx.EVT_CHECKBOX, self.onCbCold, self.cbCold) if self.settings.nextruders == 1: sz.AddSpacer(33) sz.Add(self.stopMotors) szManualCtl.Add(sz) szManualCtl.AddSpacer(10) self.font12bold = wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) self.font12 = wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) self.tXYSpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.xyspeed), size=(80, -1), style=wx.TE_RIGHT) self.tXYSpeed.SetToolTip("Set speed of X/Y movements") self.tXYSpeed.SetFont(self.font12) htc = self.tXYSpeed.GetSize()[1] sizerT = wx.BoxSizer(wx.VERTICAL) t = wx.StaticText(self, wx.ID_ANY, "XY Speed:") t.SetFont(self.font12bold) htt = t.GetSize()[1] sizerT.AddSpacer(20 + htt + 4) sizerT.Add(t, 1, wx.ALIGN_RIGHT, 0) sizerT.AddSpacer(htc + 10 - htt + 4) #t = wx.StaticText(self, wx.ID_ANY, "Z Speed:", style=wx.ALIGN_RIGHT, size=(110, -1)) t = wx.StaticText(self, wx.ID_ANY, "Z Speed:") t.SetFont(self.font12bold) sizerT.Add(t, 0, wx.ALIGN_RIGHT, 0) sizerT.AddSpacer(htc + 10 - htt + 4) t = wx.StaticText(self, wx.ID_ANY, "E Speed:") t.SetFont(self.font12bold) sizerT.Add(t, 1, wx.ALIGN_RIGHT, 1) sizerT.AddSpacer(htc + 20 + 4) t = wx.StaticText(self, wx.ID_ANY, "E Length:") t.SetFont(self.font12bold) sizerT.Add(t, 1, wx.ALIGN_RIGHT, 1) szManualCtl.Add(sizerT) szManualCtl.AddSpacer(10) sizerTC = wx.BoxSizer(wx.VERTICAL) t = wx.StaticText(self, wx.ID_ANY, "mm/min", style=wx.ALIGN_LEFT, size=(80, -1)) t.SetFont(self.font12bold) sizerTC.AddSpacer(20) sizerTC.Add(t) sizerTC.Add(self.tXYSpeed) sizerTC.AddSpacer(10) self.tXYSpeed.Bind(wx.EVT_KILL_FOCUS, self.evtXYSpeedKillFocus) self.tZSpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.zspeed), size=(80, -1), style=wx.TE_RIGHT) self.tZSpeed.SetToolTip("Set speed of Z movements") self.tZSpeed.SetFont(self.font12) sizerTC.Add(self.tZSpeed) sizerTC.AddSpacer(10) self.tZSpeed.Bind(wx.EVT_KILL_FOCUS, self.evtZSpeedKillFocus) self.tESpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.espeed), size=(80, -1), style=wx.TE_RIGHT) self.tESpeed.SetToolTip("Set speed of Extrusion/Retraction") self.tESpeed.SetFont(self.font12) sizerTC.Add(self.tESpeed) t = wx.StaticText(self, wx.ID_ANY, "mm", style=wx.ALIGN_LEFT, size=(80, -1)) t.SetFont(self.font12bold) sizerTC.AddSpacer(20) sizerTC.Add(t) self.tEDist = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.edistance), size=(80, -1), style=wx.TE_RIGHT) self.tEDist.SetToolTip("Length of Extrusion/Retraction") self.tEDist.SetFont(self.font12) sizerTC.Add(self.tEDist) szManualCtl.Add(sizerTC) szManualCtl.AddSpacer(10) szWindow.Add(szManualCtl) szSpeed = wx.BoxSizer(wx.HORIZONTAL) self.bFanSpeed = wx.BitmapButton(self, wx.ID_ANY, self.images.pngFan, size=BUTTONDIM, style=wx.NO_BORDER) self.bFanSpeed.SetToolTip("Control Fan Speed") self.Bind(wx.EVT_BUTTON, self.doBFanSpeed, self.bFanSpeed) self.slFanSpeed = wx.Slider(self, wx.ID_ANY, value=0, size=(180, -1), minValue=0, maxValue=255, style=wx.SL_HORIZONTAL | wx.SL_VALUE_LABEL) self.slFanSpeed.SetToolTip("Choose fan speed") self.bPrintSpeed = wx.BitmapButton(self, wx.ID_ANY, self.images.pngPrintspeed, size=BUTTONDIM, style=wx.NO_BORDER) self.bPrintSpeed.SetToolTip("Apply Print Speed Multiplier") self.Bind(wx.EVT_BUTTON, self.doBPrintSpeed, self.bPrintSpeed) self.slPrintSpeed = wx.Slider(self, wx.ID_ANY, value=100, size=(180, -1), minValue=50, maxValue=200, style=wx.SL_HORIZONTAL | wx.SL_VALUE_LABEL) self.slPrintSpeed.SetToolTip("Choose print speed multiplier") szSpeed.Add(self.bFanSpeed) szSpeed.Add(self.slFanSpeed, 0, wx.ALIGN_CENTER_VERTICAL, 1) szSpeed.AddSpacer(20) szSpeed.Add(self.bPrintSpeed) szSpeed.Add(self.slPrintSpeed, 0, wx.ALIGN_CENTER_VERTICAL, 1) if self.settings.speedquery is not None: self.bQuery = wx.BitmapButton(self, wx.ID_ANY, self.images.pngSpeedquery, size=BUTTONDIM, style=wx.NO_BORDER) self.bQuery.SetToolTip( "Query the printer for Print and Fan Speeds") self.Bind(wx.EVT_BUTTON, self.doBQuery, self.bQuery) szSpeed.AddSpacer(20) szSpeed.Add(self.bQuery) szWindow.AddSpacer(10) szWindow.Add(szSpeed, 0, wx.ALIGN_CENTER_HORIZONTAL, 1) self.SetSizer(szWindow) self.Layout() self.Fit() self.reprap.registerSpeedHandler(self.updateSpeed) self.reprap.registerToolHandler(self.updateTool)
class ManualCtl(wx.Window): def __init__(self, parent, reprap, prtName): self.model = None self.parent = parent self.log = self.parent.log self.images = parent.images self.settings = self.parent.settings self.reprap = reprap self.prtName = prtName self.currentTool = 1 wx.Window.__init__(self, parent, wx.ID_ANY, size=(-1, -1), style=wx.SIMPLE_BORDER) self.axesXY = ImageMap(self, self.images.pngControl_xy) self.axesXY.SetToolTip("Move X/Y axes") self.axesXY.setHotSpots(self.onImageClick, imageMapXY) self.axisZ = ImageMap(self, self.images.pngControl_z) self.axisZ.SetToolTip("Move Z axis") self.axisZ.setHotSpots(self.onImageClick, imageMapZ) self.axisE = ImageMap(self, self.images.pngControl_e) self.axisE.SetToolTip("Extrude/Retract") self.axisE.setHotSpots(self.onImageClick, imageMapE) self.stopMotors = ImageMap(self, self.images.pngStopmotors) self.stopMotors.SetToolTip("Stop all motors") self.stopMotors.setHotSpots(self.onImageClick, imageMapStopM) szWindow = wx.BoxSizer(wx.VERTICAL) szManualCtl = wx.BoxSizer(wx.HORIZONTAL) szManualCtl.AddSpacer(20) szManualCtl.Add(self.axesXY) szManualCtl.AddSpacer(10) szManualCtl.Add(self.axisZ) szManualCtl.AddSpacer(10) sz = wx.BoxSizer(wx.VERTICAL) if self.settings.nextruders > 1: sz.AddSpacer(10) self.chTool = wx.Choice( self, wx.ID_ANY, choices=[ "Tool %d" % i for i in range(self.settings.nextruders) ]) self.Bind(wx.EVT_CHOICE, self.onToolChoice, self.chTool) sz.Add(self.chTool) self.chTool.SetSelection(0) sz.Add(self.axisE) self.cbCold = wx.CheckBox(self, wx.ID_ANY, "Cold") self.cbCold.SetToolTip("Allow cold extrusion") sz.Add(self.cbCold, 1, wx.ALIGN_CENTER_HORIZONTAL, 1) self.cbCold.SetValue(False) self.Bind(wx.EVT_CHECKBOX, self.onCbCold, self.cbCold) if self.settings.nextruders == 1: sz.AddSpacer(33) sz.Add(self.stopMotors) szManualCtl.Add(sz) szManualCtl.AddSpacer(10) self.font12bold = wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) self.font12 = wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) self.tXYSpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.xyspeed), size=(80, -1), style=wx.TE_RIGHT) self.tXYSpeed.SetToolTip("Set speed of X/Y movements") self.tXYSpeed.SetFont(self.font12) htc = self.tXYSpeed.GetSize()[1] sizerT = wx.BoxSizer(wx.VERTICAL) t = wx.StaticText(self, wx.ID_ANY, "XY Speed:") t.SetFont(self.font12bold) htt = t.GetSize()[1] sizerT.AddSpacer(20 + htt + 4) sizerT.Add(t, 1, wx.ALIGN_RIGHT, 0) sizerT.AddSpacer(htc + 10 - htt + 4) #t = wx.StaticText(self, wx.ID_ANY, "Z Speed:", style=wx.ALIGN_RIGHT, size=(110, -1)) t = wx.StaticText(self, wx.ID_ANY, "Z Speed:") t.SetFont(self.font12bold) sizerT.Add(t, 0, wx.ALIGN_RIGHT, 0) sizerT.AddSpacer(htc + 10 - htt + 4) t = wx.StaticText(self, wx.ID_ANY, "E Speed:") t.SetFont(self.font12bold) sizerT.Add(t, 1, wx.ALIGN_RIGHT, 1) sizerT.AddSpacer(htc + 20 + 4) t = wx.StaticText(self, wx.ID_ANY, "E Length:") t.SetFont(self.font12bold) sizerT.Add(t, 1, wx.ALIGN_RIGHT, 1) szManualCtl.Add(sizerT) szManualCtl.AddSpacer(10) sizerTC = wx.BoxSizer(wx.VERTICAL) t = wx.StaticText(self, wx.ID_ANY, "mm/min", style=wx.ALIGN_LEFT, size=(80, -1)) t.SetFont(self.font12bold) sizerTC.AddSpacer(20) sizerTC.Add(t) sizerTC.Add(self.tXYSpeed) sizerTC.AddSpacer(10) self.tXYSpeed.Bind(wx.EVT_KILL_FOCUS, self.evtXYSpeedKillFocus) self.tZSpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.zspeed), size=(80, -1), style=wx.TE_RIGHT) self.tZSpeed.SetToolTip("Set speed of Z movements") self.tZSpeed.SetFont(self.font12) sizerTC.Add(self.tZSpeed) sizerTC.AddSpacer(10) self.tZSpeed.Bind(wx.EVT_KILL_FOCUS, self.evtZSpeedKillFocus) self.tESpeed = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.espeed), size=(80, -1), style=wx.TE_RIGHT) self.tESpeed.SetToolTip("Set speed of Extrusion/Retraction") self.tESpeed.SetFont(self.font12) sizerTC.Add(self.tESpeed) t = wx.StaticText(self, wx.ID_ANY, "mm", style=wx.ALIGN_LEFT, size=(80, -1)) t.SetFont(self.font12bold) sizerTC.AddSpacer(20) sizerTC.Add(t) self.tEDist = wx.TextCtrl(self, wx.ID_ANY, str(self.settings.edistance), size=(80, -1), style=wx.TE_RIGHT) self.tEDist.SetToolTip("Length of Extrusion/Retraction") self.tEDist.SetFont(self.font12) sizerTC.Add(self.tEDist) szManualCtl.Add(sizerTC) szManualCtl.AddSpacer(10) szWindow.Add(szManualCtl) szSpeed = wx.BoxSizer(wx.HORIZONTAL) self.bFanSpeed = wx.BitmapButton(self, wx.ID_ANY, self.images.pngFan, size=BUTTONDIM, style=wx.NO_BORDER) self.bFanSpeed.SetToolTip("Control Fan Speed") self.Bind(wx.EVT_BUTTON, self.doBFanSpeed, self.bFanSpeed) self.slFanSpeed = wx.Slider(self, wx.ID_ANY, value=0, size=(180, -1), minValue=0, maxValue=255, style=wx.SL_HORIZONTAL | wx.SL_VALUE_LABEL) self.slFanSpeed.SetToolTip("Choose fan speed") self.bPrintSpeed = wx.BitmapButton(self, wx.ID_ANY, self.images.pngPrintspeed, size=BUTTONDIM, style=wx.NO_BORDER) self.bPrintSpeed.SetToolTip("Apply Print Speed Multiplier") self.Bind(wx.EVT_BUTTON, self.doBPrintSpeed, self.bPrintSpeed) self.slPrintSpeed = wx.Slider(self, wx.ID_ANY, value=100, size=(180, -1), minValue=50, maxValue=200, style=wx.SL_HORIZONTAL | wx.SL_VALUE_LABEL) self.slPrintSpeed.SetToolTip("Choose print speed multiplier") szSpeed.Add(self.bFanSpeed) szSpeed.Add(self.slFanSpeed, 0, wx.ALIGN_CENTER_VERTICAL, 1) szSpeed.AddSpacer(20) szSpeed.Add(self.bPrintSpeed) szSpeed.Add(self.slPrintSpeed, 0, wx.ALIGN_CENTER_VERTICAL, 1) if self.settings.speedquery is not None: self.bQuery = wx.BitmapButton(self, wx.ID_ANY, self.images.pngSpeedquery, size=BUTTONDIM, style=wx.NO_BORDER) self.bQuery.SetToolTip( "Query the printer for Print and Fan Speeds") self.Bind(wx.EVT_BUTTON, self.doBQuery, self.bQuery) szSpeed.AddSpacer(20) szSpeed.Add(self.bQuery) szWindow.AddSpacer(10) szWindow.Add(szSpeed, 0, wx.ALIGN_CENTER_HORIZONTAL, 1) self.SetSizer(szWindow) self.Layout() self.Fit() self.reprap.registerSpeedHandler(self.updateSpeed) self.reprap.registerToolHandler(self.updateTool) def doBFanSpeed(self, evt): self.reprap.sendNow("M106 S%d" % self.slFanSpeed.GetValue()) def doBPrintSpeed(self, evt): self.reprap.sendNow("M220 S%d" % self.slPrintSpeed.GetValue()) def doBQuery(self, evt): self.reprap.sendNow(self.settings.speedquery) def updateSpeed(self, fan, feed, flow): self.slFanSpeed.SetValue(int(fan)) self.slPrintSpeed.SetValue(int(feed)) def updateTool(self, tool): print "update tool: ", tool def onToolChoice(self, evt): t = self.chTool.GetSelection() if t == wx.NOT_FOUND: return self.currentTool = t + 1 self.reprap.sendNow("T%d" % self.currentTool) def onCbCold(self, evt): if self.cbCold.GetValue(): self.reprap.sendNow("M302 S0") else: self.reprap.sendNow("M302 S170") def onImageClick(self, label): if label in dispatch.keys(): cmd = dispatch[label] if cmd.startswith("G1 "): if "X" in label or "Y" in label: try: v = float(self.tXYSpeed.GetValue()) except: self.log("Invalid value for XY Speed: %s" % self.tXYSpeed.GetValue()) v = 0.0 speed = " F%.3f" % v elif "Z" in label: try: v = float(self.tZSpeed.GetValue()) except: self.log("Invalid value for Z Speed: %s" % self.tZSpeed.GetValue()) v = 0.0 speed = " F%.3f" % v else: speed = "" if self.settings.moveabsolute: self.reprap.sendNow("G91") self.reprap.sendNow(cmd + speed) if self.settings.moveabsolute: self.reprap.sendNow("G90") elif cmd in ["Extrude", "Retract"]: try: v = float(self.tESpeed.GetValue()) except: self.log("Invalid value for E Speed: %s" % self.tESpeed.GetValue()) v = 0.0 speed = " F%.3f" % v try: d = float(self.tEDist.GetValue()) except: self.log("Invalid value for E Distance: %s" % self.tEDist.GetValue()) d = 0.0 if cmd == "Retract": d = -d dist = " E%.3f" % d if self.settings.extrudeabsolute: if self.settings.useM82: self.reprap.sendNow("M83") else: self.reprap.sendNow("G91") self.reprap.sendNow("G1" + dist + speed) if self.settings.extrudeabsolute: if self.settings.useM82: self.reprap.sendNow("M82") else: self.reprap.sendNow("G90") else: self.reprap.sendNow(cmd) def evtXYSpeedKillFocus(self, evt): try: float(self.tXYSpeed.GetValue()) except: self.log("Invalid value for XY Speed: %s" % self.tXYSpeed.GetValue()) def evtZSpeedKillFocus(self, evt): try: float(self.tZSpeed.GetValue()) except: self.log("Invalid value for Z Speed: %s" % self.tZSpeed.GetValue())
#Load image map, first from wiki try: imageconf = bot.get_wiki_yaml('conf/imagelist') bot.log('Loaded imagelist from wiki') except Exception as e: bot.log("Couldn't load imagelist from wiki: " + str(sys.exc_info()[0])) imageconf = None # Fall back to local file if not imageconf: imageconf = yaml.load(open('imagelist.yaml')) shutil.copy('imagelist.yaml','imagelist.%d.yaml' % (time.time())) bot.log('Loaded imagelist from file') imagemap = ImageMap(imageconf, bot.config['bot']['animated_extensions'], bot.config['bot']['switchable_extensions']) markdown = imagemap.get_formatted() # Update the image map on the wiki try: try: curmd = bot.get_wiki('imagelist') except prawcore.exceptions.NotFound: curmd = None if(curmd != markdown): bot.write_wiki('imagelist', markdown, 'Updating image list') bot.log("Wrote updated imagelist to wiki") except Exception as e: bot.log("Couldn't update wiki page: " + str(sys.exc_info()[0]))