Commit 2173f1bc authored by Keegi's avatar Keegi

Merge pull request #94 from kliment/experimental

Experimental
parents 440a5ca5 8f3df9c2
import printcore,time,sys,os
def dosify(name):
return os.path.split(name)[1].split(".")[0][:8]+".g"
def blupload(printer,filename,path):
printer.send_now("M28 "+dosify(filename))
printer.startprint([i.replace("\n","") for i in open(path)])
try:
sys.stdout.write("Progress: 00.0%")
sys.stdout.flush()
while(printer.printing):
time.sleep(1)
sys.stdout.write("\b\b\b\b%02.1f%%" % (100*float(printer.queueindex)/len(printer.mainqueue),) )
sys.stdout.flush()
printer.send_now("M29 "+dosify(filename))
print "Done uploading, disconnecting with a 5 second timeout in case the printer has something important to say."
printer.disconnect()
time.sleep(5)
print "Upload complete. Goodbye!"
except:
print "Abort, disconnecting with a 5 second timeout in case the printer has something important to say."
printer.disconnect()
if __name__ == '__main__':
#print "Usage: python blupload.py filename.gcode"
filename="../prusamendel/sellsx_export.gcode"
tfilename=filename
if len(sys.argv)>1:
filename=sys.argv[1]
tfilename=os.path.basename(sys.argv[1])
print "Uploading: "+filename," as "+dosify(tfilename)
p=printcore.printcore('/dev/ttyUSB0',115200)
p.loud=False
time.sleep(2)
blupload(p,tfilename,filename)
else:
print "Usage: python blupload.py filename.gcode"
...@@ -147,9 +147,9 @@ class Settings: ...@@ -147,9 +147,9 @@ class Settings:
self.port = "" self.port = ""
self.baudrate = 115200 self.baudrate = 115200
self.temperature_pla = 185 self.temperature_pla = 185
self.temperature_abs = 230.0 self.temperature_abs = 230
self.bedtemp_pla = 60.0 self.bedtemp_pla = 60
self.bedtemp_abs = 110.0 self.bedtemp_abs = 110
self.xy_feedrate = 3000 self.xy_feedrate = 3000
self.z_feedrate = 200 self.z_feedrate = 200
self.e_feedrate = 300 self.e_feedrate = 300
......
...@@ -117,6 +117,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -117,6 +117,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.starttime=0 self.starttime=0
self.curlayer=0 self.curlayer=0
self.cur_button=None self.cur_button=None
self.hsetpoint=0.0
self.bsetpoint=0.0
def startcb(self): def startcb(self):
self.starttime=time.time() self.starttime=time.time()
...@@ -184,14 +186,29 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -184,14 +186,29 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if self.p.online: if self.p.online:
self.p.send_now("M104 S"+l) self.p.send_now("M104 S"+l)
print _("Setting hotend temperature to "),f,_(" degrees Celsius.") print _("Setting hotend temperature to "),f,_(" degrees Celsius.")
self.htemp.SetValue(l) self.hsetpoint=f
self.set("last_temperature",str(f)) #self.tgauge.SetTarget(int(f))
if f>0:
self.htemp.SetValue(l)
self.set("last_temperature",str(f))
self.settoff.SetBackgroundColour("")
self.settoff.SetForegroundColour("")
self.settbtn.SetBackgroundColour("#FFAA66")
self.settbtn.SetForegroundColour("#660000")
self.htemp.SetBackgroundColour("#FFDABB")
else:
self.settoff.SetBackgroundColour("#0044CC")
self.settoff.SetForegroundColour("white")
self.settbtn.SetBackgroundColour("")
self.settbtn.SetForegroundColour("")
self.htemp.SetBackgroundColour("white")
self.htemp.Refresh()
else: else:
print _("Printer is not online.") print _("Printer is not online.")
else: else:
print _("You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0.") print _("You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0.")
except: except Exception,x:
print _("You must enter a temperature.") print _("You must enter a temperature. (%s)" % (repr(x),))
def do_bedtemp(self,l=""): def do_bedtemp(self,l=""):
try: try:
...@@ -205,8 +222,22 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -205,8 +222,22 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if self.p.online: if self.p.online:
self.p.send_now("M140 S"+l) self.p.send_now("M140 S"+l)
print _("Setting bed temperature to "),f,_(" degrees Celsius.") print _("Setting bed temperature to "),f,_(" degrees Celsius.")
self.btemp.SetValue(l) self.bsetpoint=f
self.set("last_bed_temperature",str(f)) if f>0:
self.btemp.SetValue(l)
self.set("last_bed_temperature",str(f))
self.setboff.SetBackgroundColour("")
self.setboff.SetForegroundColour("")
self.setbbtn.SetBackgroundColour("#FFAA66")
self.setbbtn.SetForegroundColour("#660000")
self.btemp.SetBackgroundColour("#FFDABB")
else:
self.setboff.SetBackgroundColour("#0044CC")
self.setboff.SetForegroundColour("white")
self.setbbtn.SetBackgroundColour("")
self.setbbtn.SetForegroundColour("")
self.btemp.SetBackgroundColour("white")
self.btemp.Refresh()
else: else:
print _("Printer is not online.") print _("Printer is not online.")
else: else:
...@@ -409,6 +440,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -409,6 +440,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
uts.Add(self.resetbtn) uts.Add(self.resetbtn)
self.minibtn=wx.Button(self.panel,-1,_("Mini mode"),pos=(690,0)) self.minibtn=wx.Button(self.panel,-1,_("Mini mode"),pos=(690,0))
self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview) self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview)
#self.tgauge=TempGauge(self.panel,size=(300,24))
#def scroll_setpoint(e):
# if e.GetWheelRotation()>0:
# self.do_settemp(str(self.hsetpoint+1))
# elif e.GetWheelRotation()<0:
# self.do_settemp(str(max(0,self.hsetpoint-1)))
#self.tgauge.Bind(wx.EVT_MOUSEWHEEL,scroll_setpoint)
uts.Add((10,-1)) uts.Add((10,-1))
self.monitorbox=wx.CheckBox(self.panel,-1,"",pos=(450,37)) self.monitorbox=wx.CheckBox(self.panel,-1,"",pos=(450,37))
uts.Add((15,-1)) uts.Add((15,-1))
...@@ -418,6 +457,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -418,6 +457,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
uts.Add((15,-1),flag=wx.EXPAND) uts.Add((15,-1),flag=wx.EXPAND)
uts.Add(self.minibtn) uts.Add(self.minibtn)
#uts.Add(self.tgauge)
#SECOND ROW #SECOND ROW
ubs=self.upperbottomsizer=wx.BoxSizer(wx.HORIZONTAL) ubs=self.upperbottomsizer=wx.BoxSizer(wx.HORIZONTAL)
...@@ -489,31 +529,50 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -489,31 +529,50 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lls.Add(wx.StaticText(self.panel,-1,_("Heater:"),pos=(0,343)),pos=(3,0),span=(1,1),flag=wx.ALIGN_CENTER) lls.Add(wx.StaticText(self.panel,-1,_("Heater:"),pos=(0,343)),pos=(3,0),span=(1,1),flag=wx.ALIGN_CENTER)
htemp_choices=[self.temps[i]+" ("+i+")" for i in sorted(self.temps.keys(),key=lambda x:self.temps[x])] 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),pos=(45,335))
self.settoff.Bind(wx.EVT_BUTTON,lambda e:self.do_settemp("off"))
self.printerControls.append(self.settoff)
lls.Add(self.settoff,pos=(3,1),span=(1,1))
if self.settings.last_temperature not in map(float,self.temps.values()): if self.settings.last_temperature not in map(float,self.temps.values()):
htemp_choices = [str(self.settings.last_temperature)] + htemp_choices htemp_choices = [str(self.settings.last_temperature)] + htemp_choices
self.htemp=wx.ComboBox(self.panel, -1, self.htemp=wx.ComboBox(self.panel, -1,
choices=htemp_choices,style=wx.CB_DROPDOWN, size=(90,25),pos=(45,337)) choices=htemp_choices,style=wx.CB_DROPDOWN, size=(80,25),pos=(45,337))
self.htemp.Bind(wx.EVT_COMBOBOX,self.htemp_change)
lls.Add(self.htemp,pos=(3,2),span=(1,2))
lls.Add(self.htemp,pos=(3,1),span=(1,3)) self.settbtn=wx.Button(self.panel,-1,_("Set"),size=(36,-1),pos=(125,335))
self.settbtn=wx.Button(self.panel,-1,_("Set"),size=(38,-1),pos=(135,335))
self.settbtn.Bind(wx.EVT_BUTTON,self.do_settemp) self.settbtn.Bind(wx.EVT_BUTTON,self.do_settemp)
self.printerControls.append(self.settbtn) self.printerControls.append(self.settbtn)
lls.Add(self.settbtn,pos=(3,4),span=(1,1)) lls.Add(self.settbtn,pos=(3,4),span=(1,1))
lls.Add(wx.StaticText(self.panel,-1,_("Bed:"),pos=(0,343)),pos=(4,0),span=(1,1),flag=wx.ALIGN_CENTER) lls.Add(wx.StaticText(self.panel,-1,_("Bed:"),pos=(0,343)),pos=(4,0),span=(1,1),flag=wx.ALIGN_CENTER)
btemp_choices=[self.bedtemps[i]+" ("+i+")" for i in sorted(self.bedtemps.keys(),key=lambda x:self.temps[x])] 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),pos=(135,335))
self.setboff.Bind(wx.EVT_BUTTON,lambda e:self.do_bedtemp("off"))
self.printerControls.append(self.setboff)
lls.Add(self.setboff,pos=(4,1),span=(1,1))
if self.settings.last_bed_temperature not in map(float,self.bedtemps.values()): if self.settings.last_bed_temperature not in map(float,self.bedtemps.values()):
btemp_choices = [str(self.settings.last_bed_temperature)] + btemp_choices btemp_choices = [str(self.settings.last_bed_temperature)] + btemp_choices
self.btemp=wx.ComboBox(self.panel, -1, self.btemp=wx.ComboBox(self.panel, -1,
choices=btemp_choices,style=wx.CB_DROPDOWN, size=(90,25),pos=(45,367)) choices=btemp_choices,style=wx.CB_DROPDOWN, size=(80,25),pos=(135,367))
self.btemp.Bind(wx.EVT_COMBOBOX,self.btemp_change)
lls.Add(self.btemp,pos=(4,2),span=(1,2))
self.setbbtn=wx.Button(self.panel,-1,_("Set"),size=(38,-1),pos=(135,365))
self.setbbtn.Bind(wx.EVT_BUTTON,self.do_bedtemp)
self.printerControls.append(self.setbbtn)
lls.Add(self.setbbtn,pos=(4,4),span=(1,2))
self.btemp.SetValue(str(self.settings.last_bed_temperature)) self.btemp.SetValue(str(self.settings.last_bed_temperature))
self.htemp.SetValue(str(self.settings.last_temperature)) self.htemp.SetValue(str(self.settings.last_temperature))
## added for an error where only the bed would get (pla) or (abs). ## added for an error where only the bed would get (pla) or (abs).
#This ensures, if last temp is a default pla or abs, it will be marked so. #This ensures, if last temp is a default pla or abs, it will be marked so.
# if it is not, then a (user) remark is added. This denotes a manual entry # if it is not, then a (user) remark is added. This denotes a manual entry
for i in btemp_choices: for i in btemp_choices:
if i.split()[0] == str(self.settings.last_bed_temperature).split('.')[0] or i.split()[0] == str(self.settings.last_bed_temperature): if i.split()[0] == str(self.settings.last_bed_temperature).split('.')[0] or i.split()[0] == str(self.settings.last_bed_temperature):
self.btemp.SetValue(i) self.btemp.SetValue(i)
...@@ -526,12 +585,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -526,12 +585,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if( '(' not in self.htemp.Value): if( '(' not in self.htemp.Value):
self.htemp.SetValue(self.htemp.Value + ' (user)') self.htemp.SetValue(self.htemp.Value + ' (user)')
#lls.Add(self.btemp,pos=(4,1),span=(1,3))
lls.Add(self.btemp,pos=(4,1),span=(1,3)) #lls.Add(self.setbbtn,pos=(4,4),span=(1,2))
self.setbbtn=wx.Button(self.panel,-1,_("Set"),size=(38,-1),pos=(135,365))
self.setbbtn.Bind(wx.EVT_BUTTON,self.do_bedtemp)
self.printerControls.append(self.setbbtn)
lls.Add(self.setbbtn,pos=(4,4),span=(1,2))
self.tempdisp=wx.StaticText(self.panel,-1,"") self.tempdisp=wx.StaticText(self.panel,-1,"")
lls.Add(self.tempdisp,pos=(4,6),span=(1,3)) lls.Add(self.tempdisp,pos=(4,6),span=(1,3))
...@@ -593,6 +648,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -593,6 +648,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#uts.Layout() #uts.Layout()
self.cbuttons_reload() self.cbuttons_reload()
def htemp_change(self,event):
if self.hsetpoint > 0:
self.do_settemp("")
wx.CallAfter(self.htemp.SetInsertionPoint,0)
def btemp_change(self,event):
if self.bsetpoint > 0:
self.do_bedtemp("")
wx.CallAfter(self.btemp.SetInsertionPoint,0)
def showwin(self,event): def showwin(self,event):
if(self.f is not None): if(self.f is not None):
self.gwindow.Show() self.gwindow.Show()
...@@ -642,28 +707,39 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -642,28 +707,39 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#sizer.Remove(button) #sizer.Remove(button)
button.Destroy() button.Destroy()
self.custombuttonbuttons=[] self.custombuttonbuttons=[]
newbuttonbuttonindex = len(self.custombuttons)
while newbuttonbuttonindex>0 and self.custombuttons[newbuttonbuttonindex-1] is None:
newbuttonbuttonindex -= 1
while len(self.custombuttons) < 13: while len(self.custombuttons) < 13:
self.custombuttons.append(None) self.custombuttons.append(None)
for i in xrange(len(self.custombuttons)): for i in xrange(len(self.custombuttons)):
btndef = self.custombuttons[i] btndef = self.custombuttons[i]
try: try:
b=wx.Button(self.panel,-1,btndef[0]) b=wx.Button(self.panel,-1,btndef[0])
b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef[1]))
if len(btndef)>2: if len(btndef)>2:
b.SetBackgroundColour(btndef[2]) b.SetBackgroundColour(btndef[2])
rr,gg,bb=b.GetBackgroundColour().Get() rr,gg,bb=b.GetBackgroundColour().Get()
if 0.3*rr+0.59*gg+0.11*bb < 60: if 0.3*rr+0.59*gg+0.11*bb < 60:
b.SetForegroundColour("#ffffff") b.SetForegroundColour("#ffffff")
except: except:
b=wx.StaticText(self.panel,-1,"",size=(72,20),style=wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER if i == newbuttonbuttonindex:
#b.Freeze() self.newbuttonbutton=b=wx.Button(self.panel,-1,"+",size=(19,18))
b.Disable() #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.StaticText(self.panel,-1,"",size=(72,22),style=wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER
#b.Freeze()
b.Disable()
b.custombutton=i b.custombutton=i
b.properties=btndef b.properties=btndef
if btndef is not None: if btndef is not None:
b.Bind(wx.EVT_BUTTON,self.procbutton) b.Bind(wx.EVT_BUTTON,self.procbutton)
b.Bind(wx.EVT_MOUSE_EVENTS,self.editbutton) b.Bind(wx.EVT_MOUSE_EVENTS,self.editbutton)
else: #else:
b.Bind(wx.EVT_BUTTON,lambda e:e.Skip()) # b.Bind(wx.EVT_BUTTON,lambda e:e.Skip())
self.custombuttonbuttons.append(b) self.custombuttonbuttons.append(b)
if i<4: if i<4:
ubs.Add(b) ubs.Add(b)
...@@ -761,7 +837,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -761,7 +837,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.cbutton_save(n,None) self.cbutton_save(n,None)
#while len(self.custombuttons) and self.custombuttons[-1] is None: #while len(self.custombuttons) and self.custombuttons[-1] is None:
# del self.custombuttons[-1] # del self.custombuttons[-1]
self.cbuttons_reload() wx.CallAfter(self.cbuttons_reload)
def cbutton_order(self,e,button,dir): def cbutton_order(self,e,button,dir):
n = button.custombutton n = button.custombutton
...@@ -815,7 +891,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -815,7 +891,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
return return
if not hasattr(self,"dragging"): if not hasattr(self,"dragging"):
# init dragging of the custom button # init dragging of the custom button
if hasattr(obj,"custombutton"): 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")
self.newbuttonbutton.SetSize(obj.GetSize())
if self.upperbottomsizer.GetItem(self.newbuttonbutton) is not None:
self.upperbottomsizer.SetItemMinSize(self.newbuttonbutton,obj.GetSize())
self.topsizer.Layout()
self.dragging = wx.Button(self.panel,-1,obj.GetLabel()) self.dragging = wx.Button(self.panel,-1,obj.GetLabel())
self.dragging.SetBackgroundColour(obj.GetBackgroundColour()) self.dragging.SetBackgroundColour(obj.GetBackgroundColour())
self.dragging.SetForegroundColour(obj.GetForegroundColour()) self.dragging.SetForegroundColour(obj.GetForegroundColour())
...@@ -998,6 +1081,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -998,6 +1081,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
pass pass
string+=(self.tempreport.replace("\r","").replace("T",_("Hotend")).replace("B",_("Bed")).replace("\n","").replace("ok ",""))+" " string+=(self.tempreport.replace("\r","").replace("T",_("Hotend")).replace("B",_("Bed")).replace("\n","").replace("ok ",""))+" "
wx.CallAfter(self.tempdisp.SetLabel,self.tempreport.strip().replace("ok ","")) wx.CallAfter(self.tempdisp.SetLabel,self.tempreport.strip().replace("ok ",""))
#try:
# self.tgauge.SetValue(int(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1]))
#except:
# pass
if self.sdprinting: if self.sdprinting:
string+= _(" SD printing:%04.2f %%") % (self.percentdone,) string+= _(" SD printing:%04.2f %%") % (self.percentdone,)
if self.p.printing: if self.p.printing:
...@@ -1035,6 +1122,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1035,6 +1122,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if "T:" in l: if "T:" in l:
self.tempreport=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.tgauge.SetValue(int(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1]))
#except:
# pass
tstring=l.rstrip() tstring=l.rstrip()
#print tstring #print tstring
if(tstring!="ok"): if(tstring!="ok"):
...@@ -1497,6 +1588,89 @@ class ButtonEdit(wx.Dialog): ...@@ -1497,6 +1588,89 @@ class ButtonEdit(wx.Dialog):
if self.name.GetValue()=="": if self.name.GetValue()=="":
self.name.SetValue(macro) self.name.SetValue(macro)
class TempGauge(wx.Panel):
def __init__(self,parent,size=(200,22)):
wx.Panel.__init__(self,parent,-1,size=size)
self.Bind(wx.EVT_PAINT,self.paint)
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.width,self.height=size
self.value=0
self.setpoint=0
self.recalc()
def recalc(self):
self.max=max(int(self.setpoint*1.05),240)
self.scale=float(self.width-2)/float(self.max)
self.ypt=int(self.scale*max(self.setpoint,40))
def SetValue(self,value):
self.value=value
wx.CallAfter(self.Refresh)
def SetTarget(self,value):
self.setpoint=value
self.recalc()
wx.CallAfter(self.Refresh)
def paint(self,ev):
x0,y0,x1,y1,xE,yE = 1,1,self.ypt+1,1,self.width+1-2,20
dc=wx.PaintDC(self)
dc.SetBackground(wx.Brush((255,255,255)))
dc.Clear()
cold,medium,hot = wx.Colour(0,167,223),wx.Colour(239,233,119),wx.Colour(210,50.100)
gauge1,gauge2 = wx.Colour(255,255,210),wx.Colour(234,82,0)
shadow1,shadow2 = wx.Colour(110,110,110),wx.Colour(255,255,255)
gc = wx.GraphicsContext.Create(dc)
# draw shadow first
# corners
gc.SetBrush(gc.CreateRadialGradientBrush(xE-7,9,xE-7,9,8,shadow1,shadow2))
gc.DrawRectangle(xE-7,1,8,8)
gc.SetBrush(gc.CreateRadialGradientBrush(xE-7,17,xE-7,17,8,shadow1,shadow2))
gc.DrawRectangle(xE-7,17,8,8)
gc.SetBrush(gc.CreateRadialGradientBrush(x0+6,17,x0+6,17,8,shadow1,shadow2))
gc.DrawRectangle(0,17,x0+6,8)
# edges
gc.SetBrush(gc.CreateLinearGradientBrush(xE-13,0,xE-6,0,shadow1,shadow2))
gc.DrawRectangle(xE-6,9,10,8)
gc.SetBrush(gc.CreateLinearGradientBrush(x0,yE-2,x0,yE+5,shadow1,shadow2))
gc.DrawRectangle(x0+6,yE-2,xE-12,7)
# draw gauge background
gc.SetBrush(gc.CreateLinearGradientBrush(x0,y0,x1+1,y1,cold,medium))
gc.DrawRoundedRectangle(x0,y0,x1+4,yE,6)
gc.SetBrush(gc.CreateLinearGradientBrush(x1-2,y1,xE,y1,medium,hot))
gc.DrawRoundedRectangle(x1-2,y1,xE-x1,yE,6)
# draw gauge
gc.SetBrush(gc.CreateLinearGradientBrush(x0,y0+3,x0,y0+15,gauge1,gauge2))
#gc.SetBrush(gc.CreateLinearGradientBrush(0,3,0,15,wx.Colour(255,255,255),wx.Colour(255,90,32)))
width=12
w1=y0+9-width/2
w2=w1+width
value=x0+max(10,min(self.width+1-2,int(self.value*self.scale)))
val_path = gc.CreatePath()
val_path.MoveToPoint(x0,w1)
val_path.AddLineToPoint(value,w1)
val_path.AddLineToPoint(value+2,w1+width/4)
val_path.AddLineToPoint(value+2,w2-width/4)
val_path.AddLineToPoint(value,w2)
#val_path.AddLineToPoint(value-4,10)
val_path.AddLineToPoint(x0,w2)
gc.DrawPath(val_path)
# draw setpoint markers
setpoint=x0+max(10,int(self.setpoint*self.scale))
gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0,0,0))))
setp_path = gc.CreatePath()
setp_path.MoveToPoint(setpoint-4,y0)
setp_path.AddLineToPoint(setpoint+4,y0)
setp_path.AddLineToPoint(setpoint,y0+5)
setp_path.MoveToPoint(setpoint-4,yE)
setp_path.AddLineToPoint(setpoint+4,yE)
setp_path.AddLineToPoint(setpoint,yE-5)
gc.DrawPath(setp_path)
# draw readout
text=u"T\u00B0 %u/%u"%(self.value,self.setpoint)
#gc.SetFont(gc.CreateFont(wx.Font(12,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD),wx.WHITE))
#gc.DrawText(text,29,-2)
gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD),wx.WHITE))
gc.DrawText(text,x0+31,y0+1)
gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD)))
gc.DrawText(text,x0+30,y0+0)
if __name__ == '__main__': if __name__ == '__main__':
app = wx.App(False) app = wx.App(False)
main = PronterWindow() main = PronterWindow()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment