diff --git a/README.cleanup b/README.cleanup index 55a4a8a..d1681e0 100644 --- a/README.cleanup +++ b/README.cleanup @@ -2,11 +2,19 @@ Some cleanup commands : To add a space after each comma : sed -e "s/\(\w\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py +sed -e "s/\(\w\),\(\"\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py +sed -e "s/\(\"\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py +sed -e "s/\(\"\),\(\"\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py +sed -e "s/\([)}\]]\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py +sed -e "s/\([)}\]]\),\([\[{(]\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py +sed -e "s/\(\w\),\([\[{(]\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py To add spaces around each = : sed -e "s/\(\w\)=\(\w\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py sed -e "s/\(\w\)=\(\"\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py sed -e "s/\(\w\)=\((\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py +sed -e "s/\(\w\)=\((\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py +sed -e "s/\(\w\)=\([\[{(]\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py To add spaces around each == : sed -e "s/\(\w\)==\(\w\)/\1 == \2/g" -i *.py printrun/*.py printrun/svg/*.py diff --git a/plater.py b/plater.py index 176d33c..a0715ce 100755 --- a/plater.py +++ b/plater.py @@ -443,7 +443,7 @@ class stlwin(wx.Frame): self.Refresh() #print time.time()-t - def load_stl_into_model(self, path, name, offset=[0, 0, 0], rotation = 0, scale=[1.0, 1.0, 1.0]): + def load_stl_into_model(self, path, name, offset = [0, 0, 0], rotation = 0, scale = [1.0, 1.0, 1.0]): newname = os.path.split(name.lower())[1] c = 1 while newname in self.models: diff --git a/printcore.py b/printcore.py index d0671df..359b6c4 100755 --- a/printcore.py +++ b/printcore.py @@ -289,7 +289,7 @@ class printcore(): self.clear = True return if self.resendfrom < self.lineno and self.resendfrom > -1: - self._send(self.sentlines[self.resendfrom],self.resendfrom, False) + self._send(self.sentlines[self.resendfrom], self.resendfrom, False) self.resendfrom += 1 return self.resendfrom = -1 @@ -364,7 +364,7 @@ if __name__ == '__main__': p = printcore(port, baud) p.loud = loud time.sleep(2) - gcode = [i.replace("\n","") for i in open(filename)] + gcode = [i.replace("\n", "") for i in open(filename)] p.startprint(gcode) try: diff --git a/printrun/calibrateextruder.py b/printrun/calibrateextruder.py index 3692543..9509203 100644 --- a/printrun/calibrateextruder.py +++ b/printrun/calibrateextruder.py @@ -86,9 +86,9 @@ help = u""" -t --temp Extrusion temperature in degrees Celsius (default: %d \xb0C, max %d \xb0C) -p --port Serial port the printer is connected to (default: %s) -h --help This cruft. -"""[1:-1].encode('utf-8')%(sys.argv[0],n, k,temp, tempmax, port if port else 'auto') +"""[1:-1].encode('utf-8')%(sys.argv[0], n, k, temp, tempmax, port if port else 'auto') try: - opts, args = getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help","length = ","steps = ","temp = ","port = "]) + opts, args = getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help", "length=", "steps=", "temp=", "port="]) except getopt.GetoptError, err: print str(err) print help diff --git a/printrun/gcview.py b/printrun/gcview.py index f97103f..6b0370e 100755 --- a/printrun/gcview.py +++ b/printrun/gcview.py @@ -290,7 +290,7 @@ class gcline(object): ] def glcolor(self, upper_limit = None, lower_limit = 0, max_feedrate = 0): if self.extrusion_ratio == 0: - return [255, 255, 255, 0,0, 0] + return [255, 255, 255, 0, 0, 0] else: blue_color = 0 green_color = 0 @@ -430,7 +430,7 @@ class gcview(object): else: self.lastf = cur[4] - r = gcline(x = cur[0], y = cur[1], z = cur[2],e = cur[3], f = cur[4], prev_gcline = self.prev, orgline = orgline) + r = gcline(x = cur[0], y = cur[1], z = cur[2], e = cur[3], f = cur[4], prev_gcline = self.prev, orgline = orgline) self.prev = r return r return None @@ -927,7 +927,7 @@ class GCFrame(wx.Frame): self.modelindex = 0 self.GLPanel1 = TestGlPanel(self, size) - def addfile(self, gcode=[]): + def addfile(self, gcode = []): self.models["GCODE"].gc.delete() self.models["GCODE"].gc = gcview(gcode, batch = self.models["GCODE"].batch) self.setlayerindex(None) diff --git a/printrun/graph.py b/printrun/graph.py index 4b1c105..0b9245c 100644 --- a/printrun/graph.py +++ b/printrun/graph.py @@ -78,21 +78,21 @@ class Graph(BufferedCanvas): def drawgrid(self, dc, gc): - #cold, medium, hot = wx.Colour(0, 167, 223),wx.Colour(239, 233, 119),wx.Colour(210, 50.100) - #col1 = wx.Colour(255, 0,0, 255) + #cold, medium, hot = wx.Colour(0, 167, 223), wx.Colour(239, 233, 119), wx.Colour(210, 50.100) + #col1 = wx.Colour(255, 0, 0, 255) #col2 = wx.Colour(255, 255, 255, 128) #b = gc.CreateLinearGradientBrush(0, 0, w, h, col1, col2) - gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 4)) + gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 4)) #gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(245, 245, 255, 252)))) #gc.SetBrush(b) gc.DrawRectangle(0, 0, self.width, self.height) #gc.SetBrush(wx.Brush(wx.Colour(245, 245, 255, 52))) - #gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0,0, 255)))) - #gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 4)) + #gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0, 255)))) + #gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 4)) #gc.DrawLines(wx.Point(0, 0), wx.Point(50, 10)) @@ -121,20 +121,20 @@ class Graph(BufferedCanvas): if self.timer.IsRunning() == False: font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD) - gc.SetFont(font, wx.Colour(3, 4,4)) + gc.SetFont(font, wx.Colour(3, 4, 4)) gc.DrawText("Graph offline", self.width/2 - (font.GetPointSize() * 3), self.height/2 - (font.GetPointSize() * 1)) #dc.DrawCircle(50, 50, 1) - #gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 1)) + #gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1)) #gc.DrawLines([[20, 30], [10, 53]]) - #dc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 1)) + #dc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1)) def drawtemperature(self, dc, gc, temperature_list, text, text_xoffset, r, g, b, a): if self.timer.IsRunning() == False: dc.SetPen(wx.Pen(wx.Colour(128, 128, 128, 128), 1)) else: - dc.SetPen(wx.Pen(wx.Colour(r, g,b, a), 1)) + dc.SetPen(wx.Pen(wx.Colour(r, g, b, a), 1)) x_add = float(self.width)/self.xsteps x_pos = float(0.0) @@ -155,7 +155,7 @@ class Graph(BufferedCanvas): if self.timer.IsRunning() == False: gc.SetFont(font, wx.Colour(128, 128, 128)) else: - gc.SetFont(font, wx.Colour(r, g,b)) + gc.SetFont(font, wx.Colour(r, g, b)) #gc.DrawText(text, self.width - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2)) gc.DrawText(text, x_pos - x_add - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2)) @@ -163,24 +163,24 @@ class Graph(BufferedCanvas): def drawbedtemp(self, dc, gc): - self.drawtemperature(dc, gc, self.bedtemps, "Bed",2, 255, 0,0, 128) + self.drawtemperature(dc, gc, self.bedtemps, "Bed", 2, 255, 0, 0, 128) def drawbedtargettemp(self, dc, gc): - self.drawtemperature(dc, gc, self.bedtargettemps, "Bed Target",2, 255, 120, 0, 128) + self.drawtemperature(dc, gc, self.bedtargettemps, "Bed Target", 2, 255, 120, 0, 128) def drawextruder0temp(self, dc, gc): - self.drawtemperature(dc, gc, self.extruder0temps, "Ex0",1, 0, 155, 255, 128) + self.drawtemperature(dc, gc, self.extruder0temps, "Ex0", 1, 0, 155, 255, 128) def drawextruder0targettemp(self, dc, gc): - self.drawtemperature(dc, gc, self.extruder0targettemps, "Ex0 Target",2, 0, 5,255, 128) + self.drawtemperature(dc, gc, self.extruder0targettemps, "Ex0 Target", 2, 0, 5, 255, 128) def drawextruder1temp(self, dc, gc): - self.drawtemperature(dc, gc, self.extruder1temps, "Ex1",3, 55, 55, 0, 128) + self.drawtemperature(dc, gc, self.extruder1temps, "Ex1", 3, 55, 55, 0, 128) def drawextruder1targettemp(self, dc, gc): - self.drawtemperature(dc, gc, self.extruder1targettemps, "Ex1 Target",2, 55, 55, 0, 128) + self.drawtemperature(dc, gc, self.extruder1targettemps, "Ex1 Target", 2, 55, 55, 0, 128) def SetBedTemperature(self, value): diff --git a/printrun/gviz.py b/printrun/gviz.py index e6933d7..837e66c 100755 --- a/printrun/gviz.py +++ b/printrun/gviz.py @@ -19,8 +19,8 @@ from printrun_utils import imagefile ID_ABOUT = 101 ID_EXIT = 110 class window(wx.Frame): - def __init__(self, f,size = (600, 600),build_dimensions=[200, 200, 100, 0,0, 0],grid = (10, 50),extrusion_width = 0.5): - wx.Frame.__init__(self, None, title = "Gcode view, shift to move view, mousewheel to set layer",size = (size[0],size[1])) + def __init__(self, f, size = (600, 600), build_dimensions = [200, 200, 100, 0, 0, 0], grid = (10, 50), extrusion_width = 0.5): + wx.Frame.__init__(self, None, title = "Gcode view, shift to move view, mousewheel to set layer", size = (size[0], size[1])) self.p = gviz(self, size = size, build_dimensions = build_dimensions, grid = grid, extrusion_width = extrusion_width) vbox = wx.BoxSizer(wx.VERTICAL) @@ -46,10 +46,10 @@ class window(wx.Frame): self.CreateStatusBar(1); self.SetStatusText("Layer number and Z position show here when you scroll"); - #self.bu = wx.Button(self.p,-1,"U",pos = (0, 100),size = (40, 140)) - #self.bd = wx.Button(self.p,-1,"D",pos = (0, 140),size = (40, 140)) - #self.bi = wx.Button(self.p,-1,"+",pos = (40, 100),size = (40, 140)) - #self.bo = wx.Button(self.p,-1,"-",pos = (40, 140),size = (40, 140)) + #self.bu = wx.Button(self.p,-1, "U", pos = (0, 100), size = (40, 140)) + #self.bd = wx.Button(self.p,-1, "D", pos = (0, 140), size = (40, 140)) + #self.bi = wx.Button(self.p,-1, "+", pos = (40, 100), size = (40, 140)) + #self.bo = wx.Button(self.p,-1, "-", pos = (40, 140), size = (40, 140)) #self.bs = wx.Button(self.p, -1, "Inject", pos = (85, 103), size = (50, 20)) #self.bu.SetToolTip(wx.ToolTip("Move up one layer")) @@ -66,7 +66,7 @@ class window(wx.Frame): s = time.time() #print time.time()-s - self.initpos=[0, 0] + self.initpos = [0, 0] self.p.Bind(wx.EVT_KEY_DOWN, self.key) #self.bu.Bind(wx.EVT_KEY_DOWN, self.key) #self.bd.Bind(wx.EVT_KEY_DOWN, self.key) @@ -79,9 +79,9 @@ class window(wx.Frame): self.Bind(wx.EVT_MOUSE_EVENTS, self.mouse) def resetview(self, event): - self.p.translate=[0.0, 0.0] + self.p.translate = [0.0, 0.0] self.p.scale = self.p.basescale - self.p.zoom(0, 0,1.0) + self.p.zoom(0, 0, 1.0) def mouse(self, event): if event.ButtonUp(wx.MOUSE_BTN_LEFT): @@ -89,10 +89,10 @@ class window(wx.Frame): self.initpos = None elif event.Dragging(): e = event.GetPositionTuple() - if self.initpos is None or not hasattr(self,"basetrans"): + if self.initpos is None or not hasattr(self, "basetrans"): self.initpos = e self.basetrans = self.p.translate - #print self.p.translate, e,self.initpos + #print self.p.translate, e, self.initpos self.p.translate = [ self.basetrans[0]+(e[0]-self.initpos[0]), self.basetrans[1]+(e[1]-self.initpos[1]) ] self.p.repaint() @@ -103,10 +103,10 @@ class window(wx.Frame): def key(self, event): # Keycode definitions - kup=[85, 315] # Up keys - kdo=[68, 317] # Down Keys - kzi=[388, 316, 61] # Zoom In Keys - kzo=[390, 314, 45] # Zoom Out Keys + kup = [85, 315] # Up keys + kdo = [68, 317] # Down Keys + kzi = [388, 316, 61] # Zoom In Keys + kzo = [390, 314, 45] # Zoom Out Keys x = event.GetKeyCode() #print "Key event - "+str(x) #if event.ShiftDown(): @@ -136,42 +136,42 @@ class window(wx.Frame): if z > 0: self.p.layerdown() elif z < 0: self.p.layerup() else: - if z > 0: self.p.zoom(event.GetX(),event.GetY(),1.2) - elif z < 0: self.p.zoom(event.GetX(),event.GetY(),1/1.2) + if z > 0: self.p.zoom(event.GetX(), event.GetY(), 1.2) + elif z < 0: self.p.zoom(event.GetX(), event.GetY(), 1/1.2) class gviz(wx.Panel): - def __init__(self, parent, size = (200, 200),build_dimensions=[200, 200, 100, 0,0, 0],grid = (10, 50),extrusion_width = 0.5): - wx.Panel.__init__(self, parent,-1, size = (size[0],size[1])) + def __init__(self, parent, size = (200, 200), build_dimensions = [200, 200, 100, 0, 0, 0], grid = (10, 50), extrusion_width = 0.5): + wx.Panel.__init__(self, parent,-1, size = (size[0], size[1])) self.parent = parent self.size = size self.build_dimensions = build_dimensions self.grid = grid - self.lastpos=[0, 0,0, 0,0, 0,0] + self.lastpos = [0, 0, 0, 0, 0, 0, 0] self.hilightpos = self.lastpos[:] self.Bind(wx.EVT_PAINT, self.paint) self.Bind(wx.EVT_SIZE, self.resize) - self.lines={} - self.pens={} - self.arcs={} - self.arcpens={} - self.layers=[] + self.lines = {} + self.pens = {} + self.arcs = {} + self.arcpens = {} + self.layers = [] self.layerindex = 0 self.filament_width = extrusion_width # set it to 0 to disable scaling lines with zoom - self.basescale=[min(float(size[0])/build_dimensions[0],float(size[1])/build_dimensions[1])]*2 + self.basescale = [min(float(size[0])/build_dimensions[0], float(size[1])/build_dimensions[1])]*2 self.scale = self.basescale penwidth = max(1.0, self.filament_width*((self.scale[0]+self.scale[1])/2.0)) - self.translate=[0.0, 0.0] - self.mainpen = wx.Pen(wx.Colour(0, 0,0),penwidth) - self.arcpen = wx.Pen(wx.Colour(255, 0,0),penwidth) - self.travelpen = wx.Pen(wx.Colour(10, 80, 80),penwidth) - self.hlpen = wx.Pen(wx.Colour(200, 50, 50),penwidth) - self.fades=[wx.Pen(wx.Colour(250-0.6**i*100, 250-0.6**i*100, 200-0.4**i*50),penwidth) for i in xrange(6)] - self.penslist=[self.mainpen, self.travelpen, self.hlpen]+self.fades + self.translate = [0.0, 0.0] + self.mainpen = wx.Pen(wx.Colour(0, 0, 0), penwidth) + self.arcpen = wx.Pen(wx.Colour(255, 0, 0), penwidth) + self.travelpen = wx.Pen(wx.Colour(10, 80, 80), penwidth) + self.hlpen = wx.Pen(wx.Colour(200, 50, 50), penwidth) + self.fades = [wx.Pen(wx.Colour(250-0.6**i*100, 250-0.6**i*100, 200-0.4**i*50), penwidth) for i in xrange(6)] + self.penslist = [self.mainpen, self.travelpen, self.hlpen]+self.fades self.showall = 0 - self.hilight=[] - self.hilightarcs=[] + self.hilight = [] + self.hilightarcs = [] self.dirty = 1 - self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1) + self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0], self.GetClientSize()[1],-1) def inject(self): #import pdb; pdb.set_trace() @@ -179,14 +179,14 @@ class gviz(wx.Panel): print "Layer "+str(self.layerindex +1)+" - Z = "+str(self.layers[self.layerindex])+" mm" def clear(self): - self.lastpos=[0, 0,0, 0,0, 0,0] - self.lines={} - self.pens={} - self.arcs={} - self.arcpens={} - self.layers=[] - self.hilight=[] - self.hilightarcs=[] + self.lastpos = [0, 0, 0, 0, 0, 0, 0] + self.lines = {} + self.pens = {} + self.arcs = {} + self.arcpens = {} + self.layers = [] + self.hilight = [] + self.hilightarcs = [] self.layerindex = 0 self.showall = 0 self.dirty = 1 @@ -195,7 +195,7 @@ class gviz(wx.Panel): if(self.layerindex+10): self.layerindex-=1 # Display layer info on statusbar (Jezmy) - self.parent.SetStatusText("Layer "+str(self.layerindex + 1)+" - Going Down - Z = "+str(self.layers[self.layerindex])+ " mm",0) + self.parent.SetStatusText("Layer "+str(self.layerindex + 1)+" - Going Down - Z = "+str(self.layers[self.layerindex])+ " mm", 0) self.repaint() self.Refresh() @@ -218,12 +218,12 @@ class gviz(wx.Panel): def resize(self, event): size = self.GetClientSize() - newsize = min(float(size[0])/self.size[0],float(size[1])/self.size[1]) + newsize = min(float(size[0])/self.size[0], float(size[1])/self.size[1]) self.size = self.GetClientSize() - wx.CallAfter(self.zoom, 0,0, newsize) + wx.CallAfter(self.zoom, 0, 0, newsize) - def zoom(self, x,y, factor): + def zoom(self, x, y, factor): self.scale = [s * factor for s in self.scale] self.translate = [ x - (x-self.translate[0]) * factor, @@ -237,7 +237,7 @@ class gviz(wx.Panel): def repaint(self): - self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1) + self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0], self.GetClientSize()[1],-1) dc = wx.MemoryDC() dc.SelectObject(self.blitmap) dc.SetBackground(wx.Brush((250, 250, 200))) @@ -246,17 +246,17 @@ class gviz(wx.Panel): for grid_unit in self.grid: if grid_unit > 0: for x in xrange(int(self.build_dimensions[0]/grid_unit)+1): - dc.DrawLine(self.translate[0]+x*self.scale[0]*grid_unit, self.translate[1],self.translate[0]+x*self.scale[0]*grid_unit, self.translate[1]+self.scale[1]*self.build_dimensions[1]) + dc.DrawLine(self.translate[0]+x*self.scale[0]*grid_unit, self.translate[1], self.translate[0]+x*self.scale[0]*grid_unit, self.translate[1]+self.scale[1]*self.build_dimensions[1]) for y in xrange(int(self.build_dimensions[1]/grid_unit)+1): - dc.DrawLine(self.translate[0],self.translate[1]+y*self.scale[1]*grid_unit, self.translate[0]+self.scale[0]*self.build_dimensions[0],self.translate[1]+y*self.scale[1]*grid_unit) - dc.SetPen(wx.Pen(wx.Colour(0, 0,0))) + dc.DrawLine(self.translate[0], self.translate[1]+y*self.scale[1]*grid_unit, self.translate[0]+self.scale[0]*self.build_dimensions[0], self.translate[1]+y*self.scale[1]*grid_unit) + dc.SetPen(wx.Pen(wx.Colour(0, 0, 0))) if not self.showall: self.size = self.GetSize() dc.SetBrush(wx.Brush((43, 144, 255))) - dc.DrawRectangle(self.size[0]-15, 0,15, self.size[1]) + dc.DrawRectangle(self.size[0]-15, 0, 15, self.size[1]) dc.SetBrush(wx.Brush((0, 255, 0))) if len(self.layers): - dc.DrawRectangle(self.size[0]-14,(1.0-(1.0*(self.layerindex+1))/len(self.layers))*self.size[1],13, self.size[1]-1) + dc.DrawRectangle(self.size[0]-14, (1.0-(1.0*(self.layerindex+1))/len(self.layers))*self.size[1], 13, self.size[1]-1) def _drawlines(lines, pens): def _scaler(x): @@ -282,14 +282,14 @@ class gviz(wx.Panel): dc.DrawArc(*scaled_arcs[i]) if self.showall: - l=[] + l = [] for i in self.layers: dc.DrawLineList(l, self.fades[0]) _drawlines(self.lines[i], self.pens[i]) _drawarcs(self.arcs[i], self.arcpens[i]) return if self.layerindex'+str(gPronterPtr.filename)+'\n' txt = txt+''+str(gPronterPtr.status.GetStatusText())+'\n' try: - temp = str(float(filter(lambda x:x.startswith("T:"),gPronterPtr.tempreport.split())[0].split(":")[1])) + temp = str(float(filter(lambda x:x.startswith("T:"), gPronterPtr.tempreport.split())[0].split(":")[1])) txt = txt+''+temp+'\n' except: txt = txt+'NA\n' pass try: - temp = str(float(filter(lambda x:x.startswith("B:"),gPronterPtr.tempreport.split())[0].split(":")[1])) + temp = str(float(filter(lambda x:x.startswith("B:"), gPronterPtr.tempreport.split())[0].split(":")[1])) txt = txt+''+temp+'\n' except: txt = txt+'NA\n' @@ -288,11 +288,11 @@ class WebInterface(object): pageText+="" pageText+='' - pageText+='X Home' - pageText+='Y Home' + pageText+='X Home' + pageText+='Y Home' pageText+='All Home' pageText+='Z Home' - pageText+='Y 100' + pageText+='Y 100' pageText+='Y 10' pageText+='Y 1' pageText+='Y .1' diff --git a/printrun/xybuttons.py b/printrun/xybuttons.py index fef3544..0f6865e 100644 --- a/printrun/xybuttons.py +++ b/printrun/xybuttons.py @@ -42,8 +42,8 @@ class XYButtons(BufferedCanvas): spacer = 7 def __init__(self, parent, moveCallback = None, cornerCallback = None, spacebarCallback = None, bgcolor = "#FFFFFF", ID=-1): - self.bg_bmp = wx.Image(imagefile("control_xy.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap() - self.keypad_bmp = wx.Image(imagefile("arrow_keys.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap() + self.bg_bmp = wx.Image(imagefile("control_xy.png"), wx.BITMAP_TYPE_PNG).ConvertToBitmap() + self.keypad_bmp = wx.Image(imagefile("arrow_keys.png"), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.keypad_idx = -1 self.quadrant = None self.concentric = None @@ -230,7 +230,7 @@ class XYButtons(BufferedCanvas): if self.enabled: # Brush and pen for grey overlay when mouse hovers over gc.SetPen(wx.Pen(wx.Colour(100, 100, 100, 172), 4)) - gc.SetBrush(wx.Brush(wx.Colour(0, 0,0, 128))) + gc.SetBrush(wx.Brush(wx.Colour(0, 0, 0, 128))) if self.concentric != None: if self.concentric < len(XYButtons.concentric_circle_radii): diff --git a/printrun/zbuttons.py b/printrun/zbuttons.py index 757c36b..1b79f40 100644 --- a/printrun/zbuttons.py +++ b/printrun/zbuttons.py @@ -33,7 +33,7 @@ class ZButtons(BufferedCanvas): } def __init__(self, parent, moveCallback = None, bgcolor = "#FFFFFF", ID=-1): - self.bg_bmp = wx.Image(imagefile("control_z.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap() + self.bg_bmp = wx.Image(imagefile("control_z.png"), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.range = None self.direction = None self.orderOfMagnitudeIdx = 0 # 0 means '1', 1 means '10', 2 means '100', etc. @@ -117,7 +117,7 @@ class ZButtons(BufferedCanvas): # Top 'layer' is the mouse-over highlights gc.SetPen(wx.Pen(wx.Colour(100, 100, 100, 172), 4)) - gc.SetBrush(wx.Brush(wx.Colour(0, 0,0, 128))) + gc.SetBrush(wx.Brush(wx.Colour(0, 0, 0, 128))) if self.range != None and self.direction != None: self.highlight(gc, self.range, self.direction) else: diff --git a/printrun/zscaper.py b/printrun/zscaper.py index 553c189..3fa5e9c 100644 --- a/printrun/zscaper.py +++ b/printrun/zscaper.py @@ -17,57 +17,57 @@ import wx, math from stltool import * a = wx.App() -def genscape(data=[[0, 1,0, 0],[1, 0,2, 0],[1, 0,0, 0],[0, 1,0, 1]],pscale = 1.0, bheight = 1.0, zscale = 1.0): +def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscale = 1.0, bheight = 1.0, zscale = 1.0): o = stl(None) datal = len(data) datah = len(data[0]) #create bottom: bmidpoint = (pscale*(datal-1)/2.0, pscale*(datah-1)/2.0) - #print range(datal),bmidpoint - for i in zip(range(datal+1)[:-1],range(datal+1)[1:])[:-1]: - #print (pscale*i[0],pscale*i[1]) - o.facets+=[[[0, 0,-1],[[0.0, pscale*i[0],0.0],[0.0, pscale*i[1],0.0],[bmidpoint[0],bmidpoint[1],0.0]]]] - o.facets+=[[[0, 0,-1],[[2.0*bmidpoint[1],pscale*i[1],0.0],[2.0*bmidpoint[1],pscale*i[0],0.0],[bmidpoint[0],bmidpoint[1],0.0]]]] - o.facets+=[genfacet([[0.0, pscale*i[0],data[i[0]][0]*zscale+bheight],[0.0, pscale*i[1],data[i[1]][0]*zscale+bheight],[0.0, pscale*i[1],0.0]])] - o.facets+=[genfacet([[2.0*bmidpoint[1],pscale*i[1],data[i[1]][datah-1]*zscale+bheight],[2.0*bmidpoint[1],pscale*i[0],data[i[0]][datah-1]*zscale+bheight],[2.0*bmidpoint[1],pscale*i[1],0.0]])] - o.facets+=[genfacet([[0.0, pscale*i[0],data[i[0]][0]*zscale+bheight],[0.0, pscale*i[1],0.0],[0.0, pscale*i[0],0.0]])] - o.facets+=[genfacet([[2.0*bmidpoint[1],pscale*i[1],0.0],[2.0*bmidpoint[1],pscale*i[0],data[i[0]][datah-1]*zscale+bheight],[2.0*bmidpoint[1],pscale*i[0],0.0]])] + #print range(datal), bmidpoint + for i in zip(range(datal+1)[:-1], range(datal+1)[1:])[:-1]: + #print (pscale*i[0], pscale*i[1]) + o.facets+=[[[0, 0,-1],[[0.0, pscale*i[0], 0.0],[0.0, pscale*i[1], 0.0],[bmidpoint[0], bmidpoint[1], 0.0]]]] + o.facets+=[[[0, 0,-1],[[2.0*bmidpoint[1], pscale*i[1], 0.0],[2.0*bmidpoint[1], pscale*i[0], 0.0],[bmidpoint[0], bmidpoint[1], 0.0]]]] + o.facets+=[genfacet([[0.0, pscale*i[0], data[i[0]][0]*zscale+bheight],[0.0, pscale*i[1], data[i[1]][0]*zscale+bheight],[0.0, pscale*i[1], 0.0]])] + o.facets+=[genfacet([[2.0*bmidpoint[1], pscale*i[1], data[i[1]][datah-1]*zscale+bheight],[2.0*bmidpoint[1], pscale*i[0], data[i[0]][datah-1]*zscale+bheight],[2.0*bmidpoint[1], pscale*i[1], 0.0]])] + o.facets+=[genfacet([[0.0, pscale*i[0], data[i[0]][0]*zscale+bheight],[0.0, pscale*i[1], 0.0],[0.0, pscale*i[0], 0.0]])] + o.facets+=[genfacet([[2.0*bmidpoint[1], pscale*i[1], 0.0],[2.0*bmidpoint[1], pscale*i[0], data[i[0]][datah-1]*zscale+bheight],[2.0*bmidpoint[1], pscale*i[0], 0.0]])] #print o.facets[-1] pass #print o.facets[-4:] - for i in zip(range(datah+1)[:-1],range(datah+1)[1:])[:-1]: - #print (pscale*i[0],pscale*i[1]) - o.facets+=[[[0, 0,-1],[[pscale*i[1],0.0, 0.0],[pscale*i[0],0.0, 0.0],[bmidpoint[0],bmidpoint[1],0.0]]]] - o.facets+=[[[0, 0,-1],[[pscale*i[0],2.0*bmidpoint[0],0.0],[pscale*i[1],2.0*bmidpoint[0],0.0],[bmidpoint[0],bmidpoint[1],0.0]]]] - o.facets+=[genfacet([[pscale*i[1],0.0, data[0][i[1]]*zscale+bheight],[pscale*i[0],0.0, data[0][i[0]]*zscale+bheight],[pscale*i[1],0.0, 0.0]])] + for i in zip(range(datah+1)[:-1], range(datah+1)[1:])[:-1]: + #print (pscale*i[0], pscale*i[1]) + o.facets+=[[[0, 0,-1],[[pscale*i[1], 0.0, 0.0],[pscale*i[0], 0.0, 0.0],[bmidpoint[0], bmidpoint[1], 0.0]]]] + o.facets+=[[[0, 0,-1],[[pscale*i[0], 2.0*bmidpoint[0], 0.0],[pscale*i[1], 2.0*bmidpoint[0], 0.0],[bmidpoint[0], bmidpoint[1], 0.0]]]] + o.facets+=[genfacet([[pscale*i[1], 0.0, data[0][i[1]]*zscale+bheight],[pscale*i[0], 0.0, data[0][i[0]]*zscale+bheight],[pscale*i[1], 0.0, 0.0]])] #break - o.facets+=[genfacet([[pscale*i[0],2.0*bmidpoint[0],data[datal-1][i[0]]*zscale+bheight],[pscale*i[1],2.0*bmidpoint[0],data[datal-1][i[1]]*zscale+bheight],[pscale*i[1],2.0*bmidpoint[0],0.0]])] - o.facets+=[genfacet([[pscale*i[1],0.0, 0.0],[pscale*i[0],0.0, data[0][i[0]]*zscale+bheight],[pscale*i[0],0.0, 0.0]])] - o.facets+=[genfacet([[pscale*i[0],2.0*bmidpoint[0],data[datal-1][i[0]]*zscale+bheight],[pscale*i[1],2.0*bmidpoint[0],0.0],[pscale*i[0],2.0*bmidpoint[0],0.0]])] + o.facets+=[genfacet([[pscale*i[0], 2.0*bmidpoint[0], data[datal-1][i[0]]*zscale+bheight],[pscale*i[1], 2.0*bmidpoint[0], data[datal-1][i[1]]*zscale+bheight],[pscale*i[1], 2.0*bmidpoint[0], 0.0]])] + o.facets+=[genfacet([[pscale*i[1], 0.0, 0.0],[pscale*i[0], 0.0, data[0][i[0]]*zscale+bheight],[pscale*i[0], 0.0, 0.0]])] + o.facets+=[genfacet([[pscale*i[0], 2.0*bmidpoint[0], data[datal-1][i[0]]*zscale+bheight],[pscale*i[1], 2.0*bmidpoint[0], 0.0],[pscale*i[0], 2.0*bmidpoint[0], 0.0]])] pass for i in xrange(datah-1): for j in xrange(datal-1): - o.facets+=[genfacet([[pscale*i, pscale*j, data[j][i]*zscale+bheight],[pscale*(i+1),pscale*(j),data[j][i+1]*zscale+bheight],[pscale*(i+1),pscale*(j+1),data[j+1][i+1]*zscale+bheight]])] - o.facets+=[genfacet([[pscale*(i),pscale*(j+1),data[j+1][i]*zscale+bheight],[pscale*i, pscale*j, data[j][i]*zscale+bheight],[pscale*(i+1),pscale*(j+1),data[j+1][i+1]*zscale+bheight]])] + o.facets+=[genfacet([[pscale*i, pscale*j, data[j][i]*zscale+bheight],[pscale*(i+1), pscale*(j), data[j][i+1]*zscale+bheight],[pscale*(i+1), pscale*(j+1), data[j+1][i+1]*zscale+bheight]])] + o.facets+=[genfacet([[pscale*(i), pscale*(j+1), data[j+1][i]*zscale+bheight],[pscale*i, pscale*j, data[j][i]*zscale+bheight],[pscale*(i+1), pscale*(j+1), data[j+1][i+1]*zscale+bheight]])] #print o.facets[-1] - facet=[[0, 0,0],[[0, 0,0],[0, 0,0],[0, 0,0]]] + facet = [[0, 0, 0],[[0, 0, 0],[0, 0, 0],[0, 0, 0]]] return o def zimage(name, out): i = wx.Image(name) s = i.GetSize() print len(map(ord, i.GetData()[::3])) b = map(ord, i.GetData()[::3]) - data=[] + data = [] for i in xrange(s[0]): data+=[b[i*s[1]:(i+1)*s[1]]] - #data=[i[::5] for i in data[::5]] + #data = [i[::5] for i in data[::5]] emitstl(out, genscape(data, zscale = 0.1).facets, name) """ class scapewin(wx.Frame): def __init__(self, size = (400, 530)): - wx.Frame.__init__(self, None, title = "Right-click to load an image",size = size) - self.SetIcon(wx.Icon("plater.ico",wx.BITMAP_TYPE_ICO)) + wx.Frame.__init__(self, None, title = "Right-click to load an image", size = size) + self.SetIcon(wx.Icon("plater.ico", wx.BITMAP_TYPE_ICO)) self.SetClientSize(size) self.panel = wx.Panel(self, size = size) @@ -80,5 +80,5 @@ if __name__ == '__main__': main.Show() app.MainLoop() """ - zimage("catposthtmap2.jpg","testobj.stl") + zimage("catposthtmap2.jpg", "testobj.stl") del a diff --git a/pronsole.py b/pronsole.py index 4ad4fbd..83ad89d 100755 --- a/pronsole.py +++ b/pronsole.py @@ -181,10 +181,10 @@ def estimate_duration(g): return "{0:d} layers, ".format(int(layercount)) + str(datetime.timedelta(seconds = int(totalduration))) class Settings: - #def _temperature_alias(self): return {"pla":210,"abs":230,"off":0} + #def _temperature_alias(self): return {"pla":210, "abs":230, "off":0} #def _temperature_validate(self, v): # if v < 0: raise ValueError("You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0.") - #def _bedtemperature_alias(self): return {"pla":60,"abs":110,"off":0} + #def _bedtemperature_alias(self): return {"pla":60, "abs":110, "off":0} def _baudrate_list(self): return ["2400", "9600", "19200", "38400", "57600", "115200"] def __init__(self): # defaults here. @@ -204,28 +204,28 @@ class Settings: def _set(self, key, value): try: - value = getattr(self,"_%s_alias"%key)()[value] + value = getattr(self, "_%s_alias"%key)()[value] except KeyError: pass except AttributeError: pass try: - getattr(self,"_%s_validate"%key)(value) + getattr(self, "_%s_validate"%key)(value) except AttributeError: pass setattr(self, key, type(getattr(self, key))(value)) try: - getattr(self,"_%s_cb"%key)(key, value) + getattr(self, "_%s_cb"%key)(key, value) except AttributeError: pass return value def _tabcomplete(self, key): try: - return getattr(self,"_%s_list"%key)() + return getattr(self, "_%s_list"%key)() except AttributeError: pass try: - return getattr(self,"_%s_alias"%key)().keys() + return getattr(self, "_%s_alias"%key)().keys() except AttributeError: pass return [] @@ -239,19 +239,19 @@ class pronsole(cmd.Cmd): self.completekey = None self.p = printcore.printcore() self.p.recvcb = self.recvcb - self.recvlisteners=[] + self.recvlisteners = [] self.prompt = "PC>" self.p.onlinecb = self.online self.f = None self.listing = 0 - self.sdfiles=[] + self.sdfiles = [] self.paused = False self.sdprinting = 0 - self.temps={"pla":"185","abs":"230","off":"0"} - self.bedtemps={"pla":"60","abs":"110","off":"0"} + self.temps = {"pla":"185", "abs":"230", "off":"0"} + self.bedtemps = {"pla":"60", "abs":"110", "off":"0"} self.percentdone = 0 self.tempreadings = "" - self.macros={} + self.macros = {} self.rc_loaded = False self.processing_rc = False self.processing_args = False @@ -284,18 +284,18 @@ class pronsole(cmd.Cmd): if not key.startswith("bed"): self.temps["pla"] = str(self.settings.temperature_pla) self.temps["abs"] = str(self.settings.temperature_abs) - print "Hotend temperature presets updated, pla:%s, abs:%s" % (self.temps["pla"],self.temps["abs"]) + print "Hotend temperature presets updated, pla:%s, abs:%s" % (self.temps["pla"], self.temps["abs"]) else: self.bedtemps["pla"] = str(self.settings.bedtemp_pla) self.bedtemps["abs"] = str(self.settings.bedtemp_abs) - print "Bed temperature presets updated, pla:%s, abs:%s" % (self.bedtemps["pla"],self.bedtemps["abs"]) + print "Bed temperature presets updated, pla:%s, abs:%s" % (self.bedtemps["pla"], self.bedtemps["abs"]) def scanserial(self): """scan for available ports. return a list of device names.""" - baselist=[] + baselist = [] if os.name == "nt": try: - key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") + key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM") i = 0 while(1): baselist+=[_winreg.EnumValue(key, i)[1]] @@ -343,8 +343,8 @@ class pronsole(cmd.Cmd): if self.cur_macro_def!="": self.macros[self.cur_macro_name] = self.cur_macro_def macro = self.compile_macro(self.cur_macro_name, self.cur_macro_def) - setattr(self.__class__,"do_"+self.cur_macro_name, lambda self, largs, macro = macro:macro(self,*largs.split())) - setattr(self.__class__,"help_"+self.cur_macro_name, lambda self, macro_name = self.cur_macro_name: self.subhelp_macro(macro_name)) + setattr(self.__class__, "do_"+self.cur_macro_name, lambda self, largs, macro = macro:macro(self,*largs.split())) + setattr(self.__class__, "help_"+self.cur_macro_name, lambda self, macro_name = self.cur_macro_name: self.subhelp_macro(macro_name)) if not self.processing_rc: print "Macro '"+self.cur_macro_name+"' defined" # save it @@ -385,7 +385,7 @@ class pronsole(cmd.Cmd): exec pycode return macro - def start_macro(self, macro_name, prev_definition = "",suppress_instructions = False): + def start_macro(self, macro_name, prev_definition = "", suppress_instructions = False): if not self.processing_rc and not suppress_instructions: print "Enter macro using indented lines, end with empty line" self.cur_macro_name = macro_name @@ -395,20 +395,20 @@ class pronsole(cmd.Cmd): def delete_macro(self, macro_name): if macro_name in self.macros.keys(): - delattr(self.__class__,"do_"+macro_name) + delattr(self.__class__, "do_"+macro_name) del self.macros[macro_name] print "Macro '"+macro_name+"' removed" if not self.processing_rc and not self.processing_args: - self.save_in_rc("macro "+macro_name,"") + self.save_in_rc("macro "+macro_name, "") else: print "Macro '"+macro_name+"' is not defined" def do_macro(self, args): if args.strip()=="": - self.print_topics("User-defined macros",self.macros.keys(),15, 80) + self.print_topics("User-defined macros", self.macros.keys(), 15, 80) return arglist = args.split(None, 1) macro_name = arglist[0] - if macro_name not in self.macros and hasattr(self.__class__,"do_"+macro_name): + if macro_name not in self.macros and hasattr(self.__class__, "do_"+macro_name): print "Name '"+macro_name+"' is being used by built-in command" return if len(arglist) == 2: @@ -453,11 +453,11 @@ class pronsole(cmd.Cmd): t = type(getattr(self.settings, var)) value = self.settings._set(var, str) if not self.processing_rc and not self.processing_args: - self.save_in_rc("set "+var,"set %s %s" % (var, value)) + self.save_in_rc("set "+var, "set %s %s" % (var, value)) except AttributeError: print "Unknown variable '%s'" % var except ValueError, ve: - print "Bad value for variable '%s', expecting %s (%s)" % (var, repr(t)[1:-1],ve.args[0]) + print "Bad value for variable '%s', expecting %s (%s)" % (var, repr(t)[1:-1], ve.args[0]) def do_set(self, argl): args = argl.split(None, 1) @@ -468,11 +468,11 @@ class pronsole(cmd.Cmd): value = getattr(self.settings, args[0]) if len(args) < 2: try: - print "%s = %s" % (args[0],getattr(self.settings, args[0])) + print "%s = %s" % (args[0], getattr(self.settings, args[0])) except AttributeError: print "Unknown variable '%s'" % args[0] return - self.set(args[0],args[1]) + self.set(args[0], args[1]) def help_set(self): print "Set variable: set " @@ -494,13 +494,13 @@ class pronsole(cmd.Cmd): def load_rc(self, rc_filename): self.processing_rc = True try: - rc = codecs.open(rc_filename,"r","utf-8") + rc = codecs.open(rc_filename, "r", "utf-8") self.rc_filename = os.path.abspath(rc_filename) for rc_cmd in rc: if not rc_cmd.lstrip().startswith("#"): self.onecmd(rc_cmd) rc.close() - if hasattr(self,"cur_macro_def"): + if hasattr(self, "cur_macro_def"): self.end_macro() self.rc_loaded = True finally: @@ -509,12 +509,12 @@ class pronsole(cmd.Cmd): def load_default_rc(self, rc_filename = ".pronsolerc"): try: try: - self.load_rc(os.path.join(os.path.expanduser("~"),rc_filename)) + self.load_rc(os.path.join(os.path.expanduser("~"), rc_filename)) except IOError: self.load_rc(rc_filename) except IOError: # make sure the filename is initialized - self.rc_filename = os.path.abspath(os.path.join(os.path.expanduser("~"),rc_filename)) + self.rc_filename = os.path.abspath(os.path.join(os.path.expanduser("~"), rc_filename)) def save_in_rc(self, key, definition): """ @@ -536,8 +536,8 @@ class pronsole(cmd.Cmd): if os.path.exists(self.rc_filename): import shutil shutil.copy(self.rc_filename, self.rc_filename+"~bak") - rci = codecs.open(self.rc_filename+"~bak","r","utf-8") - rco = codecs.open(self.rc_filename,"w","utf-8") + rci = codecs.open(self.rc_filename+"~bak", "r", "utf-8") + rco = codecs.open(self.rc_filename, "w", "utf-8") if rci is not None: overwriting = False for rc_cmd in rci: @@ -563,7 +563,7 @@ class pronsole(cmd.Cmd): #else: # print "Removed '"+key+"' from '"+self.rc_filename+"'" except Exception, e: - print "Saving failed for",key+":",str(e) + print "Saving failed for", key+":", str(e) finally: del rci, rco @@ -592,10 +592,10 @@ class pronsole(cmd.Cmd): print "No port specified - connecting to %s at %dbps" % (port, baud) if port != self.settings.port: self.settings.port = port - self.save_in_rc("set port","set port %s" % port) + self.save_in_rc("set port", "set port %s" % port) if baud != self.settings.baudrate: self.settings.baudrate = baud - self.save_in_rc("set baudrate","set baudrate %d" % baud) + self.save_in_rc("set baudrate", "set baudrate %d" % baud) self.p.connect(port, baud) def help_connect(self): @@ -630,9 +630,9 @@ class pronsole(cmd.Cmd): if not(os.path.exists(l)): print "File not found!" return - self.f=[i.replace("\n","").replace("\r","") for i in open(l)] + self.f = [i.replace("\n", "").replace("\r", "") for i in open(l)] self.filename = l - print "Loaded ",l,", ",len(self.f)," lines." + print "Loaded ", l, ", ", len(self.f)," lines." def complete_load(self, text, line, begidx, endidx): s = line.split() @@ -658,16 +658,16 @@ class pronsole(cmd.Cmd): if not self.p.online: print "Not connected to printer." return - self.f=[i.replace("\n","") for i in open(l.split()[0])] + self.f = [i.replace("\n", "") for i in open(l.split()[0])] self.filename = l.split()[0] - print "Loaded ",l,", ",len(self.f)," lines." + print "Loaded ", l, ", ", len(self.f)," lines." tname = "" if len(l.split())>1: tname = l.split()[1] else: print "please enter target name in 8.3 format." return - print "Uploading as ",tname + print "Uploading as ", tname print("Uploading "+self.filename) self.p.send_now("M28 "+tname) print("Press Ctrl-C to interrupt upload.") @@ -684,11 +684,11 @@ class pronsole(cmd.Cmd): self.sleep(0.2) self.p.clear = 1 self.listing = 0 - self.sdfiles=[] + self.sdfiles = [] self.recvlisteners+=[self.listfiles] self.p.send_now("M20") time.sleep(0.5) - print "\b\b\b\b\b100%. Upload completed. ",tname," should now be on the card." + print "\b\b\b\b\b100%. Upload completed. ", tname, " should now be on the card." return except: print "...interrupted!" @@ -697,7 +697,7 @@ class pronsole(cmd.Cmd): time.sleep(0.2) self.p.clear = 1 self.p.startprint([]) - print "A partial file named ",tname," may have been written to the sd card." + print "A partial file named ", tname, " may have been written to the sd card." def complete_upload(self, text, line, begidx, endidx): @@ -776,14 +776,14 @@ class pronsole(cmd.Cmd): self.listing = 0 self.recvlisteners.remove(self.listfiles) elif self.listing: - self.sdfiles+=[line.replace("\n","").replace("\r","").lower()] + self.sdfiles+=[line.replace("\n", "").replace("\r", "").lower()] def do_ls(self, l): if not self.p.online: print "Printer is not online. Try connect to it first." return self.listing = 2 - self.sdfiles=[] + self.sdfiles = [] self.recvlisteners+=[self.listfiles] self.p.send_now("M20") time.sleep(0.5) @@ -830,7 +830,7 @@ class pronsole(cmd.Cmd): print "Printer is not online. Try connect to it first." return self.listing = 2 - self.sdfiles=[] + self.sdfiles = [] self.recvlisteners+=[self.listfiles] self.p.send_now("M20") time.sleep(0.5) @@ -894,7 +894,7 @@ class pronsole(cmd.Cmd): def tempcb(self, l): if "T:" in l: - print l.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ","") + print l.replace("\r", "").replace("T", "Hotend").replace("B", "Bed").replace("\n", "").replace("ok ", "") def do_gettemp(self, l): if self.p.online: @@ -908,14 +908,14 @@ class pronsole(cmd.Cmd): def do_settemp(self, l): try: - l = l.lower().replace(",",".") + l = l.lower().replace(", ",".") for i in self.temps.keys(): l = l.replace(i, self.temps[i]) f = float(l) if f>=0: if self.p.online: self.p.send_now("M104 S"+l) - print "Setting hotend temperature to ",f," degrees Celsius." + print "Setting hotend temperature to ", f, " degrees Celsius." else: print "Printer is not online." else: @@ -934,14 +934,14 @@ class pronsole(cmd.Cmd): def do_bedtemp(self, l): try: - l = l.lower().replace(",",".") + l = l.lower().replace(", ",".") for i in self.bedtemps.keys(): l = l.replace(i, self.bedtemps[i]) f = float(l) if f>=0: if self.p.online: self.p.send_now("M140 S"+l) - print "Setting bed temperature to ",f," degrees Celsius." + print "Setting bed temperature to ", f, " degrees Celsius." else: print "Printer is not online." else: @@ -1000,14 +1000,14 @@ class pronsole(cmd.Cmd): def help_move(self): print "Move an axis. Specify the name of the axis and the amount. " - print "move X 10 will move the X axis forward by 10mm at ",self.settings.xy_feedrate,"mm/min (default XY speed)" + print "move X 10 will move the X axis forward by 10mm at ", self.settings.xy_feedrate, "mm/min (default XY speed)" print "move Y 10 5000 will move the Y axis forward by 10mm at 5000mm/min" - print "move Z -1 will move the Z axis down by 1mm at ",self.settings.z_feedrate,"mm/min (default Z speed)" + print "move Z -1 will move the Z axis down by 1mm at ", self.settings.z_feedrate, "mm/min (default Z speed)" print "Common amounts are in the tabcomplete list." def complete_move(self, text, line, begidx, endidx): if (len(line.split()) == 2 and line[-1] != " ") or (len(line.split()) == 1 and line[-1]==" "): - return [i for i in ["X ","Y ","Z ","E "] if i.lower().startswith(text)] + return [i for i in ["X ", "Y ", "Z ", "E "] if i.lower().startswith(text)] elif(len(line.split()) == 3 or (len(line.split()) == 2 and line[-1]==" ")): base = line.split()[-1] rlen = 0 @@ -1015,11 +1015,11 @@ class pronsole(cmd.Cmd): rlen = 1 if line[-1]==" ": base = "" - return [i[rlen:] for i in ["-100","-10","-1","-0.1","100","10","1","0.1","-50","-5","-0.5","50","5","0.5","-200","-20","-2","-0.2","200","20","2","0.2"] if i.startswith(base)] + return [i[rlen:] for i in ["-100", "-10", "-1", "-0.1", "100", "10", "1", "0.1", "-50", "-5", "-0.5", "50", "5", "0.5", "-200", "-20", "-2", "-0.2", "200", "20", "2", "0.2"] if i.startswith(base)] else: return [] - def do_extrude(self, l,override = None, overridefeed = 300): + def do_extrude(self, l, override = None, overridefeed = 300): length = 5#default extrusion length feed = self.settings.e_feedrate#default speed if not self.p.online: @@ -1079,7 +1079,7 @@ class pronsole(cmd.Cmd): feed = int(ls[1]) except: print "Invalid speed given." - self.do_extrude("",length*-1.0, feed) + self.do_extrude("", length*-1.0, feed) def help_reverse(self): print "Reverses the extruder, 5mm by default, or the number of mm given as a parameter" @@ -1116,12 +1116,12 @@ class pronsole(cmd.Cmd): if(self.sdprinting): self.p.send_now("M27") time.sleep(interval) - #print (self.tempreadings.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ","")) + #print (self.tempreadings.replace("\r", "").replace("T", "Hotend").replace("B", "Bed").replace("\n", "").replace("ok ", "")) if(self.p.printing): print "Print progress: ", 100*float(self.p.queueindex)/len(self.p.mainqueue), "%" if(self.sdprinting): - print "SD print progress: ", self.percentdone,"%" + print "SD print progress: ", self.percentdone, "%" except: print "Done monitoring." @@ -1134,7 +1134,7 @@ class pronsole(cmd.Cmd): print "monitor 2 - Reports temperature and SD print status (if SD printing) every 2 seconds" def expandcommand(self, c): - return c.replace("$python",sys.executable) + return c.replace("$python", sys.executable) def do_skein(self, l): l = l.split() @@ -1152,18 +1152,18 @@ class pronsole(cmd.Cmd): try: import shlex if(settings): - param = self.expandcommand(self.settings.sliceoptscommand).replace("\\","\\\\").encode() - print "Entering slicer settings: ",param + param = self.expandcommand(self.settings.sliceoptscommand).replace("\\", "\\\\").encode() + print "Entering slicer settings: ", param subprocess.call(shlex.split(param)) else: param = self.expandcommand(self.settings.slicecommand).encode() - print "Slicing: ",param - params=[i.replace("$s",l[0]).replace("$o",l[0].replace(".stl","_export.gcode").replace(".STL","_export.gcode")).encode() for i in shlex.split(param.replace("\\","\\\\").encode())] + print "Slicing: ", param + params = [i.replace("$s", l[0]).replace("$o", l[0].replace(".stl", "_export.gcode").replace(".STL", "_export.gcode")).encode() for i in shlex.split(param.replace("\\", "\\\\").encode())] subprocess.call(params) print "Loading sliced file." - self.do_load(l[0].replace(".stl","_export.gcode")) + self.do_load(l[0].replace(".stl", "_export.gcode")) except Exception, e: - print "Skeinforge execution failed: ",e + print "Skeinforge execution failed: ", e def complete_skein(self, text, line, begidx, endidx): s = line.split() @@ -1211,18 +1211,18 @@ class pronsole(cmd.Cmd): def parse_cmdline(self, args): import getopt - opts, args = getopt.getopt(args, "c:e:hw", ["conf = ","config = ","help","web","web-config = ", "web-auth-config = "]) + opts, args = getopt.getopt(args, "c:e:hw", ["conf = ", "config = ", "help", "web", "web-config = ", "web-auth-config = "]) for o, a in opts: #print repr((o, a)) - if o in ("-c","--conf","--config"): + if o in ("-c", "--conf", "--config"): self.load_rc(a) - elif o in ("-w","--web"): + elif o in ("-w", "--web"): self.webrequested = True elif o == "--web-config": self.web_config = a elif o == "--web-auth-config": self.web_auth_config = a - elif o in ("-h","--help"): + elif o in ("-h", "--help"): print "Usage: "+sys.argv[0]+' [-c filename [-c filename2 ... ] ] [-e "command" ...]' print " -c | --conf | --config - override startup .pronsolerc file" print " may chain config files, settings auto-save will go into last file in the chain" diff --git a/pronterface.py b/pronterface.py index 06fd5ae..82aa90b 100755 --- a/pronterface.py +++ b/pronterface.py @@ -99,14 +99,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.helpdict["preview_grid_step2"] = _("Coarse Grid Spacing (default: 50)") self.helpdict["bgcolor"] = _("Pronterface background color (default: #FFFFFF)") self.filename = filename - os.putenv("UBUNTU_MENUPROXY","0") - wx.Frame.__init__(self, None, title = _("Printer Interface"),size = size); - self.SetIcon(wx.Icon(pixmapfile("P-face.ico"),wx.BITMAP_TYPE_ICO)) + os.putenv("UBUNTU_MENUPROXY", "0") + wx.Frame.__init__(self, None, title = _("Printer Interface"), size = size); + self.SetIcon(wx.Icon(pixmapfile("P-face.ico"), wx.BITMAP_TYPE_ICO)) self.panel = wx.Panel(self,-1, size = size) self.statuscheck = False self.status_thread = None - self.capture_skip={} + self.capture_skip = {} self.capture_skip_newline = False self.tempreport = "" self.monitor = 0 @@ -118,28 +118,28 @@ class PronterWindow(wx.Frame, pronsole.pronsole): xcol = (245, 245, 108) ycol = (180, 180, 255) zcol = (180, 255, 180) - self.cpbuttons=[ - [_("Motors off"),("M84"),None,(250, 250, 250),0, _("Switch all motors off")], - [_("Check temp"),("M105"),(2, 5),(225, 200, 200),(1, 1), _("Check current hotend temperature")], - [_("Extrude"),("extrude"),(4, 0),(225, 200, 200),(1, 2), _("Advance extruder by set length")], - [_("Reverse"),("reverse"),(5, 0),(225, 200, 200),(1, 2), _("Reverse extruder by set length")], + self.cpbuttons = [ + [_("Motors off"), ("M84"), None, (250, 250, 250), 0, _("Switch all motors off")], + [_("Check temp"), ("M105"), (2, 5), (225, 200, 200), (1, 1), _("Check current hotend temperature")], + [_("Extrude"), ("extrude"), (4, 0), (225, 200, 200), (1, 2), _("Advance extruder by set length")], + [_("Reverse"), ("reverse"), (5, 0), (225, 200, 200), (1, 2), _("Reverse extruder by set length")], ] - self.custombuttons=[] - self.btndict={} + self.custombuttons = [] + self.btndict = {} self.parse_cmdline(sys.argv[1:]) self.build_dimensions_list = self.get_build_dimensions(self.settings.build_dimensions) self.panel.SetBackgroundColour(self.settings.bgcolor) - customdict={} + customdict = {} try: - execfile(configfile("custombtn.txt"),customdict) + execfile(configfile("custombtn.txt"), customdict) if len(customdict["btns"]): if not len(self.custombuttons): try: self.custombuttons = customdict["btns"] for n in xrange(len(self.custombuttons)): self.cbutton_save(n, self.custombuttons[n]) - os.rename("custombtn.txt","custombtn.old") - rco = open("custombtn.txt","w") + os.rename("custombtn.txt", "custombtn.old") + rco = open("custombtn.txt", "w") rco.write(_("# I moved all your custom buttons into .pronsolerc.\n# Please don't add them here any more.\n# Backup of your old buttons is in custombtn.old\n")) rco.close() except IOError, x: @@ -189,7 +189,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): print "Print Started at: " + format_time(self.starttime) def endcb(self): - if(self.p.queueindex == 0): + if self.p.queueindex == 0: print "Print ended at: " + format_time(time.time()) print_duration = int(time.time () - self.starttime + self.extra_print_time) print "and took: " + format_duration(print_duration) @@ -200,7 +200,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): if not param: return import shlex - pararray=[i.replace("$s",str(self.filename)).replace("$t", format_duration(print_duration)).encode() for i in shlex.split(param.replace("\\","\\\\").encode())] + pararray = [i.replace("$s", str(self.filename)).replace("$t", format_duration(print_duration)).encode() for i in shlex.split(param.replace("\\", "\\\\").encode())] self.finalp = subprocess.Popen(pararray, stderr = subprocess.STDOUT, stdout = subprocess.PIPE) def online(self): @@ -321,7 +321,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): try: if not l.__class__ in (str, unicode) or not len(l): l = str(self.htemp.GetValue().split()[0]) - l = l.lower().replace(",", ".") + l = l.lower().replace(", ", ".") for i in self.temps.keys(): l = l.replace(i, self.temps[i]) f = float(l) @@ -343,7 +343,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): try: if not l.__class__ in (str, unicode) or not len(l): l = str(self.btemp.GetValue().split()[0]) - l = l.lower().replace(",", ".") + l = l.lower().replace(", ", ".") for i in self.bedtemps.keys(): l = l.replace(i, self.bedtemps[i]) f = float(l) @@ -411,7 +411,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): baselist = [] if os.name == "nt": try: - key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") + key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM") i = 0 while True: baselist += [_winreg.EnumValue(key, i)[1]] @@ -445,7 +445,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.macros_menu = wx.Menu() m.AppendSubMenu(self.macros_menu, _("&Macros")) self.Bind(wx.EVT_MENU, self.new_macro, self.macros_menu.Append(-1, _("<&New...>"))) - self.Bind(wx.EVT_MENU, lambda *e:options(self), m.Append(-1, _("&Options"),_(" Options dialog"))) + self.Bind(wx.EVT_MENU, lambda *e:options(self), m.Append(-1, _("&Options"), _(" Options dialog"))) self.Bind(wx.EVT_MENU, lambda x: threading.Thread(target = lambda:self.do_skein("set")).start(), m.Append(-1, _("Slicing Settings"), _(" Adjust slicing settings"))) @@ -491,12 +491,12 @@ class PronterWindow(wx.Frame, pronsole.pronsole): if macro == "": return self.new_macro() if self.macros.has_key(macro): old_def = self.macros[macro] - elif len([c for c in macro.encode("ascii","replace") if not c.isalnum() and c != "_"]): + elif len([c for c in macro.encode("ascii", "replace") if not c.isalnum() and c != "_"]): print _("Macro name may contain only ASCII alphanumeric symbols and underscores") if self.webInterface: self.webInterface.AddLog("Macro name may contain only alphanumeric symbols and underscores") return - elif hasattr(self.__class__,"do_"+macro): + elif hasattr(self.__class__, "do_"+macro): print _("Name '%s' is being used by built-in command") % macro return else: @@ -505,7 +505,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): return macro def update_macros_menu(self): - if not hasattr(self,"macros_menu"): + if not hasattr(self, "macros_menu"): return # too early, menu not yet built try: while True: @@ -545,7 +545,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): #lower section contains the rest of the window - manual controls, console, visualizations #TOP ROW: uts = self.uppertopsizer = wx.BoxSizer(wx.HORIZONTAL) - self.rescanbtn = wx.Button(self.panel,-1, _("Port"),size = buttonSize) + self.rescanbtn = wx.Button(self.panel,-1, _("Port"), size = buttonSize) self.rescanbtn.SetToolTip(wx.ToolTip("Communication Settings\nClick to rescan ports")) self.rescanbtn.Bind(wx.EVT_BUTTON, self.rescanports) @@ -556,9 +556,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to")) self.rescanports() uts.Add(self.serialport) - uts.Add(wx.StaticText(self.panel,-1,"@"),0, wx.RIGHT|wx.ALIGN_CENTER, 0) + uts.Add(wx.StaticText(self.panel,-1, "@"), 0, wx.RIGHT|wx.ALIGN_CENTER, 0) self.baud = wx.ComboBox(self.panel, -1, - choices=["2400", "9600", "19200", "38400", "57600", "115200", "250000"], + choices = ["2400", "9600", "19200", "38400", "57600", "115200", "250000"], style = wx.CB_DROPDOWN, size = (100, 25)) self.baud.SetToolTip(wx.ToolTip("Select Baud rate for printer communication")) try: @@ -571,31 +571,31 @@ class PronterWindow(wx.Frame, pronsole.pronsole): uts.Add(self.connectbtn) self.connectbtn.SetToolTip(wx.ToolTip("Connect to the printer")) self.connectbtn.Bind(wx.EVT_BUTTON, self.connect) - self.resetbtn = wx.Button(self.panel,-1, _("Reset"),style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) + self.resetbtn = wx.Button(self.panel,-1, _("Reset"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) self.resetbtn.Bind(wx.EVT_BUTTON, self.reset) self.resetbtn.SetToolTip(wx.ToolTip("Reset the printer")) uts.Add(self.resetbtn) - #self.minibtn = wx.Button(self.panel,-1, _("Mini mode"),style = wx.BU_EXACTFIT) + #self.minibtn = wx.Button(self.panel,-1, _("Mini mode"), style = wx.BU_EXACTFIT) #self.minibtn.Bind(wx.EVT_BUTTON, self.toggleview) #uts.Add((25,-1)) - #uts.Add((15,-1),flag = wx.EXPAND) + #uts.Add((15,-1), flag = wx.EXPAND) #uts.Add(self.minibtn, 0, wx.ALIGN_CENTER) #SECOND ROW ubs = self.upperbottomsizer = uts#wx.BoxSizer(wx.HORIZONTAL) - self.loadbtn = wx.Button(self.panel,-1, _("Load file"),style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) + self.loadbtn = wx.Button(self.panel,-1, _("Load file"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) self.loadbtn.Bind(wx.EVT_BUTTON, self.loadfile) self.loadbtn.SetToolTip(wx.ToolTip("Load a 3D model file")) ubs.Add(self.loadbtn) - self.platebtn = wx.Button(self.panel,-1, _("Compose"),style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) + self.platebtn = wx.Button(self.panel,-1, _("Compose"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) self.platebtn.Bind(wx.EVT_BUTTON, self.plate) self.platebtn.SetToolTip(wx.ToolTip("Simple Plater System")) #self.printerControls.append(self.uploadbtn) ubs.Add(self.platebtn) - self.sdbtn = wx.Button(self.panel,-1, _("SD"),style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) + self.sdbtn = wx.Button(self.panel,-1, _("SD"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) self.sdbtn.Bind(wx.EVT_BUTTON, self.sdmenu) self.sdbtn.SetToolTip(wx.ToolTip("SD Card Printing")) self.printerControls.append(self.sdbtn) @@ -623,11 +623,11 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)")) self.commandbox.Bind(wx.EVT_TEXT_ENTER, self.sendline) self.commandbox.Bind(wx.EVT_CHAR, self.cbkey) - self.commandbox.history=[u""] + self.commandbox.history = [u""] self.commandbox.histindex = 1 #self.printerControls.append(self.commandbox) lbrs.Add(self.commandbox, 1) - self.sendbtn = wx.Button(self.panel,-1, _("Send"),style = wx.BU_EXACTFIT) + self.sendbtn = wx.Button(self.panel,-1, _("Send"), style = wx.BU_EXACTFIT) self.sendbtn.SetToolTip(wx.ToolTip("Send Command to Printer")) self.sendbtn.Bind(wx.EVT_BUTTON, self.sendline) #self.printerControls.append(self.sendbtn) @@ -637,22 +637,22 @@ class PronterWindow(wx.Frame, pronsole.pronsole): #left pane lls = self.lowerlsizer = wx.GridBagSizer() llts = wx.BoxSizer(wx.HORIZONTAL) - #lls.Add(wx.StaticText(self.panel,-1, _("mm/min")),pos = (0, 4),span = (1, 4)) - lls.Add(llts, pos = (0, 0),span = (1, 9)) + #lls.Add(wx.StaticText(self.panel,-1, _("mm/min")), pos = (0, 4), span = (1, 4)) + lls.Add(llts, pos = (0, 0), span = (1, 9)) #lls.Add((200, 375)) szbuttons = wx.GridBagSizer() self.xyb = XYButtons(self.panel, self.moveXY, self.homeButtonClicked, self.spacebarAction, self.settings.bgcolor) - szbuttons.Add(self.xyb, pos = (0, 1),flag = wx.ALIGN_CENTER) + szbuttons.Add(self.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER) self.zb = ZButtons(self.panel, self.moveZ, self.settings.bgcolor) - szbuttons.Add(self.zb, pos = (0, 2),flag = wx.ALIGN_CENTER) + szbuttons.Add(self.zb, pos = (0, 2), flag = wx.ALIGN_CENTER) #lls.Add(self.zb, pos = (2, 6), span = (1, 1), flag = wx.ALIGN_CENTER) wx.CallAfter(self.xyb.SetFocus) lls.Add(szbuttons, pos = (1, 0), span = (1, 8), flag = wx.ALIGN_CENTER) for i in self.cpbuttons: - btn = wx.Button(self.panel,-1, i[0],style = wx.BU_EXACTFIT) + btn = wx.Button(self.panel,-1, i[0], style = wx.BU_EXACTFIT) btn.SetToolTip(wx.ToolTip(i[5])) btn.SetBackgroundColour(i[3]) btn.SetForegroundColour("black") @@ -660,18 +660,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole): btn.Bind(wx.EVT_BUTTON, self.procbutton) self.btndict[i[1]]=btn self.printerControls.append(btn) - if(i[2]==None): - if(i[4]==0): + if i[2] == None: + if i[4] == 0: llts.Add(btn) else: - lls.Add(btn, pos = i[2],span = i[4]) + lls.Add(btn, pos = i[2], span = i[4]) - self.xyfeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.xy_feedrate),min = 0, max = 50000, size = (70,-1)) + self.xyfeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.xy_feedrate), min = 0, max = 50000, size = (70,-1)) self.xyfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for X & Y axes (mm/min)")) llts.Add(wx.StaticText(self.panel,-1, _("XY:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL) llts.Add(self.xyfeedc) llts.Add(wx.StaticText(self.panel,-1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL) - self.zfeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.z_feedrate),min = 0, max = 50000, size = (70,-1)) + self.zfeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.z_feedrate), min = 0, max = 50000, size = (70,-1)) self.zfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for Z axis (mm/min)")) llts.Add(self.zfeedc,) @@ -680,14 +680,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole): lls.Add(self.monitorbox, pos = (2, 6)) self.monitorbox.Bind(wx.EVT_CHECKBOX, self.setmonitor) - lls.Add(wx.StaticText(self.panel,-1, _("Heat:")),pos = (2, 0),span = (1, 1),flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) - htemp_choices=[self.temps[i]+" ("+i+")" for i in sorted(self.temps.keys(),key = lambda x:self.temps[x])] + lls.Add(wx.StaticText(self.panel,-1, _("Heat:")), pos = (2, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) + htemp_choices = [self.temps[i]+" ("+i+")" for i in sorted(self.temps.keys(), key = lambda x:self.temps[x])] - self.settoff = wx.Button(self.panel,-1, _("Off"),size = (36,-1),style = wx.BU_EXACTFIT) + self.settoff = wx.Button(self.panel,-1, _("Off"), size = (36,-1), style = wx.BU_EXACTFIT) self.settoff.SetToolTip(wx.ToolTip("Switch Hotend Off")) self.settoff.Bind(wx.EVT_BUTTON, lambda e:self.do_settemp("off")) self.printerControls.append(self.settoff) - lls.Add(self.settoff, pos = (2, 1),span = (1, 1)) + lls.Add(self.settoff, pos = (2, 1), span = (1, 1)) if self.settings.last_temperature not in map(float, self.temps.values()): htemp_choices = [str(self.settings.last_temperature)] + htemp_choices @@ -696,21 +696,21 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.htemp.SetToolTip(wx.ToolTip("Select Temperature for Hotend")) self.htemp.Bind(wx.EVT_COMBOBOX, self.htemp_change) - lls.Add(self.htemp, pos = (2, 2),span = (1, 2)) - self.settbtn = wx.Button(self.panel,-1, _("Set"),size = (38,-1),style = wx.BU_EXACTFIT) + lls.Add(self.htemp, pos = (2, 2), span = (1, 2)) + self.settbtn = wx.Button(self.panel,-1, _("Set"), size = (38,-1), style = wx.BU_EXACTFIT) self.settbtn.SetToolTip(wx.ToolTip("Switch Hotend On")) self.settbtn.Bind(wx.EVT_BUTTON, self.do_settemp) self.printerControls.append(self.settbtn) - lls.Add(self.settbtn, pos = (2, 4),span = (1, 1)) + lls.Add(self.settbtn, pos = (2, 4), span = (1, 1)) - lls.Add(wx.StaticText(self.panel,-1, _("Bed:")),pos = (3, 0),span = (1, 1),flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) - btemp_choices=[self.bedtemps[i]+" ("+i+")" for i in sorted(self.bedtemps.keys(),key = lambda x:self.temps[x])] + lls.Add(wx.StaticText(self.panel,-1, _("Bed:")), pos = (3, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) + btemp_choices = [self.bedtemps[i]+" ("+i+")" for i in sorted(self.bedtemps.keys(), key = lambda x:self.temps[x])] - self.setboff = wx.Button(self.panel,-1, _("Off"),size = (36,-1),style = wx.BU_EXACTFIT) + self.setboff = wx.Button(self.panel,-1, _("Off"), size = (36,-1), style = wx.BU_EXACTFIT) self.setboff.SetToolTip(wx.ToolTip("Switch Heated Bed Off")) self.setboff.Bind(wx.EVT_BUTTON, lambda e:self.do_bedtemp("off")) self.printerControls.append(self.setboff) - lls.Add(self.setboff, pos = (3, 1),span = (1, 1)) + lls.Add(self.setboff, pos = (3, 1), span = (1, 1)) if self.settings.last_bed_temperature not in map(float, self.bedtemps.values()): btemp_choices = [str(self.settings.last_bed_temperature)] + btemp_choices @@ -718,13 +718,13 @@ class PronterWindow(wx.Frame, pronsole.pronsole): choices = btemp_choices, style = wx.CB_DROPDOWN, size = (70,-1)) self.btemp.SetToolTip(wx.ToolTip("Select Temperature for Heated Bed")) self.btemp.Bind(wx.EVT_COMBOBOX, self.btemp_change) - lls.Add(self.btemp, pos = (3, 2),span = (1, 2)) + lls.Add(self.btemp, pos = (3, 2), span = (1, 2)) - self.setbbtn = wx.Button(self.panel,-1, _("Set"),size = (38,-1),style = wx.BU_EXACTFIT) + self.setbbtn = wx.Button(self.panel,-1, _("Set"), size = (38,-1), style = wx.BU_EXACTFIT) self.setbbtn.SetToolTip(wx.ToolTip("Switch Heated Bed On")) self.setbbtn.Bind(wx.EVT_BUTTON, self.do_bedtemp) self.printerControls.append(self.setbbtn) - lls.Add(self.setbbtn, pos = (3, 4),span = (1, 1)) + lls.Add(self.setbbtn, pos = (3, 4), span = (1, 1)) self.btemp.SetValue(str(self.settings.last_bed_temperature)) self.htemp.SetValue(str(self.settings.last_temperature)) @@ -745,33 +745,33 @@ class PronterWindow(wx.Frame, pronsole.pronsole): if( '(' not in self.htemp.Value): self.htemp.SetValue(self.htemp.Value + ' (user)') - #lls.Add(self.btemp, pos = (4, 1),span = (1, 3)) - #lls.Add(self.setbbtn, pos = (4, 4),span = (1, 2)) - self.tempdisp = wx.StaticText(self.panel,-1,"") + #lls.Add(self.btemp, pos = (4, 1), span = (1, 3)) + #lls.Add(self.setbbtn, pos = (4, 4), span = (1, 2)) + self.tempdisp = wx.StaticText(self.panel,-1, "") - self.edist = wx.SpinCtrl(self.panel,-1,"5",min = 0, max = 1000, size = (60,-1)) + self.edist = wx.SpinCtrl(self.panel,-1, "5", min = 0, max = 1000, size = (60,-1)) self.edist.SetBackgroundColour((225, 200, 200)) self.edist.SetForegroundColour("black") - lls.Add(self.edist, pos = (4, 2),span = (1, 2)) - lls.Add(wx.StaticText(self.panel,-1, _("mm")),pos = (4, 4),span = (1, 1)) + lls.Add(self.edist, pos = (4, 2), span = (1, 2)) + lls.Add(wx.StaticText(self.panel,-1, _("mm")), pos = (4, 4), span = (1, 1)) self.edist.SetToolTip(wx.ToolTip("Amount to Extrude or Retract (mm)")) - self.efeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.e_feedrate),min = 0, max = 50000, size = (60,-1)) + self.efeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.e_feedrate), min = 0, max = 50000, size = (60,-1)) self.efeedc.SetToolTip(wx.ToolTip("Extrude / Retract speed (mm/min)")) self.efeedc.SetBackgroundColour((225, 200, 200)) self.efeedc.SetForegroundColour("black") self.efeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds) - lls.Add(self.efeedc, pos = (5, 2),span = (1, 2)) - lls.Add(wx.StaticText(self.panel,-1, _("mm/\nmin")),pos = (5, 4),span = (1, 1)) + lls.Add(self.efeedc, pos = (5, 2), span = (1, 2)) + lls.Add(wx.StaticText(self.panel,-1, _("mm/\nmin")), pos = (5, 4), span = (1, 1)) self.xyfeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds) self.zfeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds) self.zfeedc.SetBackgroundColour((180, 255, 180)) self.zfeedc.SetForegroundColour("black") - # lls.Add((10, 0),pos = (0, 11),span = (1, 1)) + # lls.Add((10, 0), pos = (0, 11), span = (1, 1)) - #self.hottgauge = TempGauge(self.panel, size = (200, 24),title = _("Heater:"),maxval = 230) - #lls.Add(self.hottgauge, pos = (7, 0),span = (1, 4)) - #self.bedtgauge = TempGauge(self.panel, size = (200, 24),title = _("Bed:"),maxval = 130) - #lls.Add(self.bedtgauge, pos = (8, 0),span = (1, 4)) + #self.hottgauge = TempGauge(self.panel, size = (200, 24), title = _("Heater:"), maxval = 230) + #lls.Add(self.hottgauge, pos = (7, 0), span = (1, 4)) + #self.bedtgauge = TempGauge(self.panel, size = (200, 24), title = _("Bed:"), maxval = 130) + #lls.Add(self.bedtgauge, pos = (8, 0), span = (1, 4)) #def scroll_setpoint(e): # if e.GetWheelRotation()>0: # self.do_settemp(str(self.hsetpoint+1)) @@ -781,9 +781,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.graph = Graph(self.panel, wx.ID_ANY) lls.Add(self.graph, pos = (3, 5), span = (3, 3)) - lls.Add(self.tempdisp, pos = (6, 0),span = (1, 1)) + lls.Add(self.tempdisp, pos = (6, 0), span = (1, 1)) - self.gviz = gviz.gviz(self.panel,(300, 300), + self.gviz = gviz.gviz(self.panel, (300, 300), build_dimensions = self.build_dimensions_list, grid = (self.settings.preview_grid_step1, self.settings.preview_grid_step2), extrusion_width = self.settings.preview_extrusion_width) @@ -857,7 +857,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): def plate(self, e): import plater print "plate function activated" - plater.stlwin(size = (800, 580),callback = self.platecb, parent = self).Show() + plater.stlwin(size = (800, 580), callback = self.platecb, parent = self).Show() def platecb(self, name): print "plated: "+name @@ -893,15 +893,15 @@ class PronterWindow(wx.Frame, pronsole.pronsole): def setfeeds(self, e): self.feedrates_changed = True try: - self.settings._set("e_feedrate",self.efeedc.GetValue()) + self.settings._set("e_feedrate", self.efeedc.GetValue()) except: pass try: - self.settings._set("z_feedrate",self.zfeedc.GetValue()) + self.settings._set("z_feedrate", self.zfeedc.GetValue()) except: pass try: - self.settings._set("xy_feedrate",self.xyfeedc.GetValue()) + self.settings._set("xy_feedrate", self.xyfeedc.GetValue()) except: pass @@ -933,7 +933,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): for sizer, button in allcbs: #sizer.Remove(button) button.Destroy() - self.custombuttonbuttons=[] + self.custombuttonbuttons = [] newbuttonbuttonindex = len(self.custombuttons) while newbuttonbuttonindex>0 and self.custombuttons[newbuttonbuttonindex-1] is None: newbuttonbuttonindex -= 1 @@ -942,7 +942,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): for i in xrange(len(self.custombuttons)): btndef = self.custombuttons[i] try: - b = wx.Button(self.panel,-1, btndef[0],style = wx.BU_EXACTFIT) + b = wx.Button(self.panel,-1, btndef[0], style = wx.BU_EXACTFIT) b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef[1])) if len(btndef)>2: b.SetBackgroundColour(btndef[2]) @@ -951,14 +951,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole): b.SetForegroundColour("#ffffff") except: if i == newbuttonbuttonindex: - self.newbuttonbutton = b = wx.Button(self.panel,-1,"+",size = (19, 18),style = wx.BU_EXACTFIT) + self.newbuttonbutton = b = wx.Button(self.panel,-1, "+", size = (19, 18), style = wx.BU_EXACTFIT) #b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)) b.SetForegroundColour("#4444ff") b.SetToolTip(wx.ToolTip(_("click to add new custom button"))) b.Bind(wx.EVT_BUTTON, self.cbutton_edit) else: - b = wx.Button(self.panel,-1,".",size = (1, 1)) - #b = wx.StaticText(self.panel,-1,"",size = (72, 22),style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER + b = wx.Button(self.panel,-1, ".", size = (1, 1)) + #b = wx.StaticText(self.panel,-1, "", size = (72, 22), style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER b.Disable() #continue b.custombutton = i @@ -972,7 +972,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): #if i<4: # ubs.Add(b) #else: - cs.Add(b, pos = ((i)/4,(i)%4)) + cs.Add(b, pos = ((i)/4, (i)%4)) self.topsizer.Layout() def help_button(self): @@ -1022,15 +1022,15 @@ class PronterWindow(wx.Frame, pronsole.pronsole): elif len(bdef)>2: colour = bdef[2] if type(colour) not in (str, unicode): - #print type(colour),map(type, colour) + #print type(colour), map(type, colour) if type(colour) == tuple and tuple(map(type, colour)) == (int, int, int): colour = map(lambda x:x%256, colour) colour = wx.Colour(*colour).GetAsString(wx.C2S_NAME|wx.C2S_HTML_SYNTAX) else: colour = wx.Colour(colour).GetAsString(wx.C2S_NAME|wx.C2S_HTML_SYNTAX) - self.save_in_rc(("button %d" % n),'button %d "%s" /c "%s" %s' % (new_n, bdef[0],colour, bdef[1])) + self.save_in_rc(("button %d" % n),'button %d "%s" /c "%s" %s' % (new_n, bdef[0], colour, bdef[1])) else: - self.save_in_rc(("button %d" % n),'button %d "%s" %s' % (new_n, bdef[0],bdef[1])) + self.save_in_rc(("button %d" % n),'button %d "%s" %s' % (new_n, bdef[0], bdef[1])) def cbutton_edit(self, e, button = None): bedit = ButtonEdit(self) @@ -1055,7 +1055,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): if bedit.ShowModal() == wx.ID_OK: if n == len(self.custombuttons): self.custombuttons+=[None] - self.custombuttons[n]=[bedit.name.GetValue().strip(),bedit.command.GetValue().strip()] + self.custombuttons[n]=[bedit.name.GetValue().strip(), bedit.command.GetValue().strip()] if bedit.color.GetValue().strip()!="": self.custombuttons[n]+=[bedit.color.GetValue()] self.cbutton_save(n, self.custombuttons[n]) @@ -1077,7 +1077,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): if n+1 >= len(self.custombuttons): self.custombuttons+=[None] # pad # swap - self.custombuttons[n],self.custombuttons[n+1] = self.custombuttons[n+1],self.custombuttons[n] + self.custombuttons[n], self.custombuttons[n+1] = self.custombuttons[n+1], self.custombuttons[n] self.cbutton_save(n, self.custombuttons[n]) self.cbutton_save(n+1, self.custombuttons[n+1]) #if self.custombuttons[-1] is None: @@ -1092,18 +1092,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole): pos = e.GetPosition() popupmenu = wx.Menu() obj = e.GetEventObject() - if hasattr(obj,"custombutton"): + if hasattr(obj, "custombutton"): item = popupmenu.Append(-1, _("Edit custom button '%s'") % e.GetEventObject().GetLabelText()) - self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_edit(e, button),item) + self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_edit(e, button), item) item = popupmenu.Append(-1, _("Move left <<")) - self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_order(e, button,-1),item) + self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_order(e, button,-1), item) if obj.custombutton == 0: item.Enable(False) item = popupmenu.Append(-1, _("Move right >>")) - self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_order(e, button, 1),item) + self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_order(e, button, 1), item) if obj.custombutton == 63: item.Enable(False) pos = self.panel.ScreenToClient(e.GetEventObject().ClientToScreen(pos)) item = popupmenu.Append(-1, _("Remove custom button '%s'") % e.GetEventObject().GetLabelText()) - self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_remove(e, button),item) + self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_remove(e, button), item) else: item = popupmenu.Append(-1, _("Add custom button")) self.Bind(wx.EVT_MENU, self.cbutton_edit, item) @@ -1111,18 +1111,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole): elif e.Dragging() and e.ButtonIsDown(wx.MOUSE_BTN_LEFT): obj = e.GetEventObject() scrpos = obj.ClientToScreen(e.GetPosition()) - if not hasattr(self,"dragpos"): + if not hasattr(self, "dragpos"): self.dragpos = scrpos e.Skip() return else: - dx, dy = self.dragpos[0]-scrpos[0],self.dragpos[1]-scrpos[1] + dx, dy = self.dragpos[0]-scrpos[0], self.dragpos[1]-scrpos[1] if dx*dx+dy*dy < 5*5: # threshold to detect dragging for jittery mice e.Skip() return - if not hasattr(self,"dragging"): + if not hasattr(self, "dragging"): # init dragging of the custom button - if hasattr(obj,"custombutton") and obj.properties is not None: + if hasattr(obj, "custombutton") and obj.properties is not None: #self.newbuttonbutton.SetLabel("") #self.newbuttonbutton.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) #self.newbuttonbutton.SetForegroundColour("black") @@ -1142,7 +1142,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.upperbottomsizer.SetItemMinSize(b, obj.GetSize()) self.topsizer.Layout() # b.SetStyle(wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE+wx.SIMPLE_BORDER) - self.dragging = wx.Button(self.panel,-1, obj.GetLabel(),style = wx.BU_EXACTFIT) + self.dragging = wx.Button(self.panel,-1, obj.GetLabel(), style = wx.BU_EXACTFIT) self.dragging.SetBackgroundColour(obj.GetBackgroundColour()) self.dragging.SetForegroundColour(obj.GetForegroundColour()) self.dragging.sourcebutton = obj @@ -1201,7 +1201,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): src.SetForegroundColour(drg.fgc) src.SetLabel(drg.label) self.last_drag_dest = dst - elif hasattr(self,"dragging") and not e.ButtonIsDown(wx.MOUSE_BTN_LEFT): + elif hasattr(self, "dragging") and not e.ButtonIsDown(wx.MOUSE_BTN_LEFT): # dragging finished obj = e.GetEventObject() scrpos = obj.ClientToScreen(e.GetPosition()) @@ -1215,7 +1215,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): if dst is not None: src_i = src.custombutton dst_i = dst.custombutton - self.custombuttons[src_i],self.custombuttons[dst_i] = self.custombuttons[dst_i],self.custombuttons[src_i] + self.custombuttons[src_i], self.custombuttons[dst_i] = self.custombuttons[dst_i], self.custombuttons[src_i] self.cbutton_save(src_i, self.custombuttons[src_i]) self.cbutton_save(dst_i, self.custombuttons[dst_i]) while self.custombuttons[-1] is None: @@ -1280,10 +1280,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.status_thread = None self.p.recvcb = None self.p.disconnect() - if hasattr(self,"feedrates_changed"): - self.save_in_rc("set xy_feedrate","set xy_feedrate %d" % self.settings.xy_feedrate) - self.save_in_rc("set z_feedrate","set z_feedrate %d" % self.settings.z_feedrate) - self.save_in_rc("set e_feedrate","set e_feedrate %d" % self.settings.e_feedrate) + if hasattr(self, "feedrates_changed"): + self.save_in_rc("set xy_feedrate", "set xy_feedrate %d" % self.settings.xy_feedrate) + self.save_in_rc("set z_feedrate", "set z_feedrate %d" % self.settings.z_feedrate) + self.save_in_rc("set e_feedrate", "set e_feedrate %d" % self.settings.e_feedrate) try: self.gwindow.Destroy() except: @@ -1327,7 +1327,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): command = self.commandbox.GetValue() if not len(command): return - wx.CallAfter(self.logbox.AppendText,">>>"+command+"\n") + wx.CallAfter(self.logbox.AppendText, ">>>"+command+"\n") if self.webInterface: self.webInterface.AppendLog(">>>"+command+"\n") self.onecmd(str(command)) @@ -1341,7 +1341,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): def statuschecker(self): while self.statuscheck: string = "" - wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ","")) + wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", "")) try: #self.hottgauge.SetValue(parse_temperature_report(self.tempreport, "T:")) wx.CallAfter(self.graph.SetExtruder0Temperature, parse_temperature_report(self.tempreport, "T:")) @@ -1369,7 +1369,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): if(self.monitor and self.p.online): if self.sdprinting: self.p.send_now("M27") - if not hasattr(self,"auto_monitor_pattern"): + if not hasattr(self, "auto_monitor_pattern"): self.auto_monitor_pattern = re.compile(r"(ok\s+)?T:[\d\.]+(\s+B:[\d\.]+)?(\s+@:[\d\.]+)?\s*") self.capture_skip[self.auto_monitor_pattern] = self.capture_skip.setdefault(self.auto_monitor_pattern, 0) + 1 self.p.send_now("M105") @@ -1408,7 +1408,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): def recvcb(self, l): if "T:" in l: self.tempreport = l - wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ","")) + wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", "")) try: #self.hottgauge.SetValue(parse_temperature_report(self.tempreport, "T:")) wx.CallAfter(self.graph.SetExtruder0Temperature, parse_temperature_report(self.tempreport, "T:")) @@ -1432,7 +1432,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.recvlisteners.remove(self.listfiles) wx.CallAfter(self.filesloaded) elif self.listing: - self.sdfiles+=[line.replace("\n","").replace("\r","").lower()] + self.sdfiles+=[line.replace("\n", "").replace("\r", "").lower()] def waitforsdresponse(self, l): if "file.open failed" in l: @@ -1473,10 +1473,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole): def getfiles(self): if not self.p.online: - self.sdfiles=[] + self.sdfiles = [] return self.listing = 0 - self.sdfiles=[] + self.sdfiles = [] self.recvlisteners+=[self.listfiles] self.p.send_now("M21") self.p.send_now("M20") @@ -1485,10 +1485,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole): try: import shlex param = self.expandcommand(self.settings.slicecommand).encode() - print "Slicing: ",param + print "Slicing: ", param if self.webInterface: self.webInterface.AddLog("Slicing: "+param) - pararray=[i.replace("$s",self.filename).replace("$o",self.filename.replace(".stl","_export.gcode").replace(".STL","_export.gcode")).encode() for i in shlex.split(param.replace("\\","\\\\").encode())] + pararray = [i.replace("$s", self.filename).replace("$o", self.filename.replace(".stl", "_export.gcode").replace(".STL", "_export.gcode")).encode() for i in shlex.split(param.replace("\\", "\\\\").encode())] #print pararray self.skeinp = subprocess.Popen(pararray, stderr = subprocess.STDOUT, stdout = subprocess.PIPE) while True: @@ -1513,9 +1513,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): time.sleep(0.1) fn = self.filename try: - self.filename = self.filename.replace(".stl","_export.gcode").replace(".STL","_export.gcode").replace(".obj","_export.gcode").replace(".OBJ","_export.gcode") + self.filename = self.filename.replace(".stl", "_export.gcode").replace(".STL", "_export.gcode").replace(".obj", "_export.gcode").replace(".OBJ", "_export.gcode") of = open(self.filename) - self.f=[i.replace("\n","").replace("\r","") for i in of] + self.f = [i.replace("\n", "").replace("\r", "") for i in of] of.close() if self.p.online: wx.CallAfter(self.printbtn.Enable) @@ -1552,7 +1552,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): basedir = os.path.split(self.filename)[0] except: pass - dlg = wx.FileDialog(self, _("Open file to print"),basedir, style = wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) + dlg = wx.FileDialog(self, _("Open file to print"), basedir, style = wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) dlg.SetWildcard(_("OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*")) if(filename is not None or dlg.ShowModal() == wx.ID_OK): if filename is not None: @@ -1564,7 +1564,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): return path = os.path.split(name)[0] if path != self.settings.last_file_path: - self.set("last_file_path",path) + self.set("last_file_path", path) if name.lower().endswith(".stl"): self.skein(name) elif name.lower().endswith(".obj"): @@ -1572,7 +1572,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): else: self.filename = name of = open(self.filename) - self.f=[i.replace("\n","").replace("\r","") for i in of] + self.f = [i.replace("\n", "").replace("\r", "") for i in of] of.close() self.status.SetStatusText(_("Loaded %s, %d lines") % (name, len(self.f))) wx.CallAfter(self.printbtn.SetLabel, _("Print")) @@ -1709,9 +1709,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): self.p.connect(port, baud) self.statuscheck = True if port != self.settings.port: - self.set("port",port) + self.set("port", port) if baud != self.settings.baudrate: - self.set("baudrate",str(baud)) + self.set("baudrate", str(baud)) self.status_thread = threading.Thread(target = self.statuschecker) self.status_thread.start() if self.predisconnect_mainqueue: @@ -1786,9 +1786,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): # a string containing up to six numbers delimited by almost anything # first 0-3 numbers specify the build volume, no sign, always positive # remaining 0-3 numbers specify the coordinates of the "southwest" corner of the build platform - # "XXX,YYY" + # "XXX, YYY" # "XXXxYYY+xxx-yyy" - # "XXX,YYY,ZZZ+xxx+yyy-zzz" + # "XXX, YYY, ZZZ+xxx+yyy-zzz" # etc bdl = re.match( "[^\d+-]*(\d+)?" + # X build size diff --git a/setup.py b/setup.py index 8bc9040..af9f481 100755 --- a/setup.py +++ b/setup.py @@ -145,7 +145,7 @@ setup ( license = "GPLv3", data_files = data_files, packages = ["printrun", "printrun.svg"], - scripts = ["pronsole.py", "pronterface.py", "plater.py","printcore.py"], + scripts = ["pronsole.py", "pronterface.py", "plater.py", "printcore.py"], cmdclass = {"uninstall" : uninstall, "install" : install, "install_data" : install_data}