Coding style cleanup, pronterface.py, first 25%

master
Guillaume Seguin 2012-08-04 10:30:58 +02:00
parent 97e2b704dd
commit a052f0fb33
1 changed files with 124 additions and 125 deletions

View File

@ -204,13 +204,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if self.filename: if self.filename:
wx.CallAfter(self.printbtn.Enable) wx.CallAfter(self.printbtn.Enable)
def sentcb(self, line): def sentcb(self, line):
if("G1" in line): if "G1" in line:
if("Z" in line): if "Z" in line:
try: try:
layer = float(line.split("Z")[1].split()[0]) layer = float(line.split("Z")[1].split()[0])
if(layer!=self.curlayer): if layer != self.curlayer:
self.curlayer = layer self.curlayer = layer
self.gviz.hilight = [] self.gviz.hilight = []
threading.Thread(target = wx.CallAfter, args = (self.gviz.setlayer, layer)).start() threading.Thread(target = wx.CallAfter, args = (self.gviz.setlayer, layer)).start()
@ -222,8 +221,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
pass pass
#threading.Thread(target=self.gviz.addgcode,args=(line,1)).start() #threading.Thread(target=self.gviz.addgcode,args=(line,1)).start()
#self.gwindow.p.addgcode(line,hilight=1) #self.gwindow.p.addgcode(line,hilight=1)
if("M104" in line or "M109" in line): if "M104" in line or "M109" in line:
if("S" in line): if "S" in line:
try: try:
temp = float(line.split("S")[1].split("*")[0]) temp = float(line.split("S")[1].split("*")[0])
#self.hottgauge.SetTarget(temp) #self.hottgauge.SetTarget(temp)
@ -234,8 +233,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.sentlines.put_nowait(line) self.sentlines.put_nowait(line)
except: except:
pass pass
if("M140" in line): if "M140" in line:
if("S" in line): if "S" in line:
try: try:
temp = float(line.split("S")[1].split("*")[0]) temp = float(line.split("S")[1].split("*")[0])
#self.bedtgauge.SetTarget(temp) #self.bedtgauge.SetTarget(temp)
@ -249,7 +248,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def do_extrude(self, l = ""): def do_extrude(self, l = ""):
try: try:
if not (l.__class__=="".__class__ or l.__class__==u"".__class__) or (not len(l)): if not l.__class__ in (str, unicode) or not len(l):
l = str(self.edist.GetValue()) l = str(self.edist.GetValue())
pronsole.pronsole.do_extrude(self, l) pronsole.pronsole.do_extrude(self, l)
except: except:
@ -257,8 +256,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def do_reverse(self, l = ""): def do_reverse(self, l = ""):
try: try:
if not (l.__class__=="".__class__ or l.__class__==u"".__class__) or (not len(l)): if not l.__class__ in (str, unicode) or not len(l):
l=str(float(self.edist.GetValue())*-1.0) l = str(- float(self.edist.GetValue()))
pronsole.pronsole.do_extrude(self,l) pronsole.pronsole.do_extrude(self,l)
except: except:
pass pass
@ -305,7 +304,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def do_settemp(self, l = ""): def do_settemp(self, l = ""):
try: try:
if not (l.__class__=="".__class__ or l.__class__==u"".__class__) or not l: if not l.__class__ in (str, unicode) or not len(l):
l = str(self.htemp.GetValue().split()[0]) l = str(self.htemp.GetValue().split()[0])
l = l.lower().replace(",", ".") l = l.lower().replace(",", ".")
for i in self.temps.keys(): for i in self.temps.keys():
@ -327,7 +326,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def do_bedtemp(self, l = ""): def do_bedtemp(self, l = ""):
try: try:
if not (l.__class__=="".__class__ or l.__class__==u"".__class__) or (not len(l)): if not l.__class__ in (str, unicode) or not len(l):
l = str(self.btemp.GetValue().split()[0]) l = str(self.btemp.GetValue().split()[0])
l = l.lower().replace(",", ".") l = l.lower().replace(",", ".")
for i in self.bedtemps.keys(): for i in self.bedtemps.keys():
@ -399,7 +398,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
try: try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM")
i = 0 i = 0
while(1): while True:
baselist += [_winreg.EnumValue(key, i)[1]] baselist += [_winreg.EnumValue(key, i)[1]]
i += 1 i += 1
except: except:
@ -408,7 +407,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def project(self, event): def project(self, event):
import projectlayer import projectlayer
if(self.p.online): if self.p.online:
projectlayer.setframe(self, self.p).Show() projectlayer.setframe(self, self.p).Show()
else: else:
print _("Printer is not online.") print _("Printer is not online.")
@ -446,7 +445,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.loadfile, None, self.filename) wx.CallAfter(self.loadfile, None, self.filename)
def do_editgcode(self, e = None): def do_editgcode(self, e = None):
if(self.filename is not None): if self.filename is not None:
macroed(self.filename, self.f, self.doneediting, 1) macroed(self.filename, self.f, self.doneediting, 1)
def new_macro(self, e = None): def new_macro(self, e = None):