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