Commit fa6a3cd7 authored by Chillance's avatar Chillance

Added a simple Graph class to be used in Pronterface.

parent ae7b6f5c
#!/usr/bin/python
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import wx, random
from bufferedcanvas import *
class Graph(BufferedCanvas):
'''A class to show a Graph with Pronterface.'''
def __init__(self, parent, id, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
# Forcing a no full repaint to stop flickering
style = style | wx.NO_FULL_REPAINT_ON_RESIZE
#call super function
#super(Graph, self).__init__(parent, id, pos, size, style)
BufferedCanvas.__init__(self, parent, id)
self.SetSize(wx.Size(170, 100))
self.extruder1temps = [0]
self.extruder1targettemps = [0]
self.extruder2temps = [0]
self.extruder2targettemps = [0]
self.bedtemps = [0]
self.bedtargettemps = [0]
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.updateTemperatures, self.timer)
self.maxyvalue = 250
self.ybars = 5
self.xbars = 6 # One bar per 10 second
self.xsteps = 60 # Covering One minute in the graph
self.y_offset = 1 # This is to show the line even when value is 0 and maxyvalue
self._lastyvalue = 0
#self.sizer = wx.BoxSizer(wx.HORIZONTAL)
#self.sizer.Add(wx.Button(self, -1, "Button1", (0,0)))
#self.SetSizer(self.sizer)
def OnPaint(self, evt):
dc = wx.PaintDC(self)
gc = wx.GraphicsContext.Create(dc)
def Destroy(self):
#call the super method
super(wx.Panel, self).Destroy()
def updateTemperatures(self, event):
self.AddBedTemperature(self.bedtemps[-1])
self.AddBedTargetTemperature(self.bedtargettemps[-1])
self.AddExtruder1Temperature(self.extruder1temps[-1])
self.AddExtruder1TargetTemperature(self.extruder1targettemps[-1])
#self.AddExtruder2Temperature(self.extruder2temps[-1])
#self.AddExtruder2TargetTemperature(self.extruder2targettemps[-1])
self.Refresh()
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)
#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.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.DrawLines(wx.Point(0,0), wx.Point(50,10))
#path = gc.CreatePath()
#path.MoveToPoint(0.0, 0.0)
#path.AddLineToPoint(0.0, 100.0)
#path.AddLineToPoint(100.0, 0.0)
#path.AddCircle( 50.0, 50.0, 50.0 )
#path.CloseSubpath()
#gc.DrawPath(path)
#gc.StrokePath(path)
font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)
gc.SetFont(font, wx.Colour(23,44,44))
dc.SetPen(wx.Pen(wx.Colour(225,225,225), 1))
for x in range(self.xbars):
dc.DrawLine(x*(float(self.width)/self.xbars), 0, x*(float(self.width)/self.xbars), self.height)
dc.SetPen(wx.Pen(wx.Colour(225,225,225), 1))
for y in range(self.ybars):
y_pos = y*(float(self.height)/self.ybars)
dc.DrawLine(0,y_pos, self.width,y_pos)
gc.DrawText(unicode(int(self.maxyvalue - (y * (self.maxyvalue/self.ybars)))), 1, y_pos - (font.GetPointSize() / 2))
if self.timer.IsRunning() == False:
font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD)
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.DrawLines([[20,30], [10,53]])
#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):
dc.SetPen(wx.Pen(wx.Colour(r,g,b,a), 1))
x_add = float(self.width)/self.xsteps
x_pos = float(0.0)
lastxvalue = float(0.0)
for temperature in (temperature_list):
y_pos = int((float(self.height-self.y_offset)/self.maxyvalue)*temperature) + self.y_offset
if (x_pos > 0.0): # One need 2 points to draw a line.
dc.DrawLine(lastxvalue,self.height-self._lastyvalue, x_pos, self.height-y_pos)
lastxvalue = x_pos
x_pos = float(x_pos) + x_add
self._lastyvalue = y_pos
if len(text) > 0:
font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD)
#font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
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))
#gc.DrawText(text, self.width - (font.GetPixelSize().GetWidth() * ((len(text) * text_xoffset + 1) + 1)), self.height - self._lastyvalue - (font.GetPointSize() / 2))
def drawbedtemp(self, dc, gc):
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)
def drawextruder1temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1temps, "Ex1",1, 0,155,255, 128)
def drawextruder1targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1targettemps, "Ex1 Target",2, 0,5,255, 128)
def drawextruder2temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder2temps, "Ex2",3, 55,55,0, 128)
def drawextruder2targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder2targettemps, "Ex2 Target",2, 55,55,0, 128)
def SetBedTemperature(self, value):
self.bedtemps.pop()
self.bedtemps.append(value)
def AddBedTemperature(self, value):
self.bedtemps.append(value)
if (len(self.bedtemps)-1) * float(self.width)/self.xsteps > self.width:
self.bedtemps.pop(0)
def SetBedTargetTemperature(self, value):
self.bedtargettemps.pop()
self.bedtargettemps.append(value)
def AddBedTargetTemperature(self, value):
self.bedtargettemps.append(value)
if (len(self.bedtargettemps)-1) * float(self.width)/self.xsteps > self.width:
self.bedtargettemps.pop(0)
def SetExtruder1Temperature(self, value):
self.extruder1temps.pop()
self.extruder1temps.append(value)
def AddExtruder1Temperature(self, value):
self.extruder1temps.append(value)
if (len(self.extruder1temps)-1) * float(self.width)/self.xsteps > self.width:
self.extruder1temps.pop(0)
def SetExtruder1TargetTemperature(self, value):
self.extruder1targettemps.pop()
self.extruder1targettemps.append(value)
def AddExtruder1TargetTemperature(self, value):
self.extruder1targettemps.append(value)
if (len(self.extruder1targettemps)-1) * float(self.width)/self.xsteps > self.width:
self.extruder1targettemps.pop(0)
def SetExtruder2Temperature(self, value):
self.extruder2temps.pop()
self.extruder2temps.append(value)
def AddExtruder2Temperature(self, value):
self.extruder2temps.append(value)
if (len(self.extruder2temps)-1) * float(self.width)/self.xsteps > self.width:
self.extruder2temps.pop(0)
def SetExtruder2TargetTemperature(self, value):
self.extruder2targettemps.pop(0)
self.extruder2targettemps.append(value)
def AddExtruder2TargetTemperature(self, value):
self.extruder2targettemps.append(value)
if (len(self.extruder2targettemps)-1) * float(self.width)/self.xsteps > self.width:
self.extruder2targettemps.pop(0)
def StartPlotting(self, time):
self.Refresh()
self.timer.Start(time)
def StopPlotting(self):
self.timer.Stop()
self.Refresh()
def draw(self, dc, w, h):
dc.Clear()
gc = wx.GraphicsContext.Create(dc)
self.width = w
self.height = h
self.drawgrid(dc, gc)
self.drawbedtemp(dc, gc)
self.drawbedtargettemp(dc, gc)
self.drawextruder1temp(dc, gc)
self.drawextruder1targettemp(dc, gc)
self.drawextruder2temp(dc, gc)
self.drawextruder2targettemp(dc, gc)
#!/usr/bin/env python #!/usr/bin/env python
# This file is part of the Printrun suite. # This file is part of the Printrun suite.
# #
# Printrun is free software: you can redistribute it and/or modify # Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# Printrun is distributed in the hope that it will be useful, # Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>. # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
...@@ -21,7 +21,7 @@ import os, gettext, Queue, re ...@@ -21,7 +21,7 @@ import os, gettext, Queue, re
if os.path.exists('/usr/share/pronterface/locale'): if os.path.exists('/usr/share/pronterface/locale'):
gettext.install('pronterface', '/usr/share/pronterface/locale', unicode=1) gettext.install('pronterface', '/usr/share/pronterface/locale', unicode=1)
else: else:
gettext.install('pronterface', './locale', unicode=1) gettext.install('pronterface', './locale', unicode=1)
try: try:
...@@ -35,7 +35,7 @@ try: ...@@ -35,7 +35,7 @@ try:
except: except:
pass pass
StringIO=cStringIO StringIO=cStringIO
thread=threading.Thread thread=threading.Thread
winsize=(800,500) winsize=(800,500)
if os.name=="nt": if os.name=="nt":
...@@ -48,6 +48,7 @@ if os.name=="nt": ...@@ -48,6 +48,7 @@ if os.name=="nt":
from xybuttons import XYButtons from xybuttons import XYButtons
from zbuttons import ZButtons from zbuttons import ZButtons
from graph import Graph
import pronsole import pronsole
def dosify(name): def dosify(name):
...@@ -119,7 +120,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -119,7 +120,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
customdict={} customdict={}
try: try:
execfile("custombtn.txt",customdict) execfile("custombtn.txt",customdict)
if len(customdict["btns"]): if len(customdict["btns"]):
if not len(self.custombuttons): if not len(self.custombuttons):
try: try:
self.custombuttons = customdict["btns"] self.custombuttons = customdict["btns"]
...@@ -134,7 +135,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -134,7 +135,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
else: else:
print _("Note!!! You have specified custom buttons in both custombtn.txt and .pronsolerc") print _("Note!!! You have specified custom buttons in both custombtn.txt and .pronsolerc")
print _("Ignoring custombtn.txt. Remove all current buttons to revert to custombtn.txt") print _("Ignoring custombtn.txt. Remove all current buttons to revert to custombtn.txt")
except: except:
pass pass
self.popmenu() self.popmenu()
...@@ -152,19 +153,19 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -152,19 +153,19 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.cur_button=None self.cur_button=None
self.hsetpoint=0.0 self.hsetpoint=0.0
self.bsetpoint=0.0 self.bsetpoint=0.0
def startcb(self): def startcb(self):
self.starttime=time.time() self.starttime=time.time()
print "Print Started at: " +time.strftime('%H:%M:%S',time.localtime(self.starttime)) print "Print Started at: " +time.strftime('%H:%M:%S',time.localtime(self.starttime))
def endcb(self): def endcb(self):
if(self.p.queueindex==0): if(self.p.queueindex==0):
print "Print ended at: " +time.strftime('%H:%M:%S',time.localtime(time.time())) print "Print ended at: " +time.strftime('%H:%M:%S',time.localtime(time.time()))
print "and took: "+time.strftime('%H:%M:%S', time.gmtime(int(time.time()-self.starttime+self.extra_print_time))) #+str(int(time.time()-self.starttime)/60)+" minutes "+str(int(time.time()-self.starttime)%60)+" seconds." print "and took: "+time.strftime('%H:%M:%S', time.gmtime(int(time.time()-self.starttime+self.extra_print_time))) #+str(int(time.time()-self.starttime)/60)+" minutes "+str(int(time.time()-self.starttime)%60)+" seconds."
wx.CallAfter(self.pausebtn.Disable) wx.CallAfter(self.pausebtn.Disable)
wx.CallAfter(self.printbtn.SetLabel,_("Print")) wx.CallAfter(self.printbtn.SetLabel,_("Print"))
def online(self): def online(self):
print _("Printer is now online.") print _("Printer is now online.")
self.connectbtn.SetLabel(_("Disconnect")) self.connectbtn.SetLabel(_("Disconnect"))
...@@ -179,8 +180,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -179,8 +180,8 @@ 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):
...@@ -198,7 +199,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -198,7 +199,7 @@ 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)
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__=="".__class__ or l.__class__==u"".__class__) or (not len(l)):
...@@ -206,7 +207,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -206,7 +207,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
pronsole.pronsole.do_extrude(self,l) pronsole.pronsole.do_extrude(self,l)
except: except:
raise raise
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__=="".__class__ or l.__class__==u"".__class__) or (not len(l)):
...@@ -214,7 +215,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -214,7 +215,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
pronsole.pronsole.do_extrude(self,l) pronsole.pronsole.do_extrude(self,l)
except: except:
pass pass
def do_settemp(self,l=""): def do_settemp(self,l=""):
try: try:
if not (l.__class__=="".__class__ or l.__class__==u"".__class__) or (not len(l)): if not (l.__class__=="".__class__ or l.__class__==u"".__class__) or (not len(l)):
...@@ -229,7 +230,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -229,7 +230,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
print _("Setting hotend temperature to %f degrees Celsius.") % f print _("Setting hotend temperature to %f degrees Celsius.") % f
self.hsetpoint=f self.hsetpoint=f
self.hottgauge.SetTarget(int(f)) self.hottgauge.SetTarget(int(f))
if f>0: self.graph.SetExtruder1TargetTemperature(int(f))
if f>0:
wx.CallAfter(self.htemp.SetValue,l) wx.CallAfter(self.htemp.SetValue,l)
self.set("last_temperature",str(f)) self.set("last_temperature",str(f))
wx.CallAfter(self.settoff.SetBackgroundColour,"") wx.CallAfter(self.settoff.SetBackgroundColour,"")
...@@ -249,8 +251,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -249,8 +251,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
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 Exception,x: except Exception,x:
print _("You must enter a temperature. (%s)") % (repr(x),) print _("You must enter a temperature. (%s)" % (repr(x),))
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__=="".__class__ or l.__class__==u"".__class__) or (not len(l)):
...@@ -265,7 +267,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -265,7 +267,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
print _("Setting bed temperature to %f degrees Celsius.") % f print _("Setting bed temperature to %f degrees Celsius.") % f
self.bsetpoint=f self.bsetpoint=f
self.bedtgauge.SetTarget(int(f)) self.bedtgauge.SetTarget(int(f))
if f>0: self.graph.SetBedTargetTemperature(int(f))
if f>0:
wx.CallAfter(self.btemp.SetValue,l) wx.CallAfter(self.btemp.SetValue,l)
self.set("last_bed_temperature",str(f)) self.set("last_bed_temperature",str(f))
wx.CallAfter(self.setboff.SetBackgroundColour,"") wx.CallAfter(self.setboff.SetBackgroundColour,"")
...@@ -286,15 +289,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -286,15 +289,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
print _("You cannot set negative temperatures. To turn the bed off entirely, set its temperature to 0.") print _("You cannot set negative temperatures. To turn the bed off entirely, set its temperature to 0.")
except: except:
print _("You must enter a temperature.") print _("You must enter a temperature.")
def end_macro(self): def end_macro(self):
pronsole.pronsole.end_macro(self) pronsole.pronsole.end_macro(self)
self.update_macros_menu() self.update_macros_menu()
def delete_macro(self,macro_name): def delete_macro(self,macro_name):
pronsole.pronsole.delete_macro(self,macro_name) pronsole.pronsole.delete_macro(self,macro_name)
self.update_macros_menu() self.update_macros_menu()
def start_macro(self,macro_name,old_macro_definition=""): def start_macro(self,macro_name,old_macro_definition=""):
if not self.processing_rc: if not self.processing_rc:
def cb(definition): def cb(definition):
...@@ -312,7 +315,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -312,7 +315,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
macroed(macro_name,old_macro_definition,cb) macroed(macro_name,old_macro_definition,cb)
else: else:
pronsole.pronsole.start_macro(self,macro_name,old_macro_definition) pronsole.pronsole.start_macro(self,macro_name,old_macro_definition)
def catchprint(self,l): def catchprint(self,l):
if self.capture_skip_newline and len(l) and not len(l.strip("\n\r")): if self.capture_skip_newline and len(l) and not len(l.strip("\n\r")):
self.capture_skip_newline = False self.capture_skip_newline = False
...@@ -323,7 +326,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -323,7 +326,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.capture_skip_newline = True self.capture_skip_newline = True
return return
wx.CallAfter(self.logbox.AppendText,l) wx.CallAfter(self.logbox.AppendText,l)
def scanserial(self): def scanserial(self):
"""scan for available ports. return a list of device names.""" """scan for available ports. return a list of device names."""
baselist=[] baselist=[]
...@@ -337,14 +340,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -337,14 +340,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
except: except:
pass pass
return baselist+glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') +glob.glob("/dev/tty.*")+glob.glob("/dev/cu.*")+glob.glob("/dev/rfcomm*") return baselist+glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') +glob.glob("/dev/tty.*")+glob.glob("/dev/cu.*")+glob.glob("/dev/rfcomm*")
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.")
def popmenu(self): def popmenu(self):
self.menustrip = wx.MenuBar() self.menustrip = wx.MenuBar()
# File menu # File menu
...@@ -355,14 +358,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -355,14 +358,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.Bind(wx.EVT_MENU, self.project, m.Append(-1,_("Projector"),_(" Project slices"))) self.Bind(wx.EVT_MENU, self.project, m.Append(-1,_("Projector"),_(" Project slices")))
self.Bind(wx.EVT_MENU, self.OnExit, m.Append(wx.ID_EXIT,_("E&xit"),_(" Closes the Window"))) self.Bind(wx.EVT_MENU, self.OnExit, m.Append(wx.ID_EXIT,_("E&xit"),_(" Closes the Window")))
self.menustrip.Append(m,_("&File")) self.menustrip.Append(m,_("&File"))
# Settings menu # Settings menu
m = wx.Menu() m = wx.Menu()
self.macros_menu = wx.Menu() self.macros_menu = wx.Menu()
m.AppendSubMenu(self.macros_menu, _("&Macros")) 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, 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"))) self.Bind(wx.EVT_MENU, lambda x:threading.Thread(target=lambda :self.do_skein("set")).start(), m.Append(-1,_("Slicing Settings"),_(" Adjust slicing settings")))
#try: #try:
# from SkeinforgeQuickEditDialog import SkeinforgeQuickEditDialog # from SkeinforgeQuickEditDialog import SkeinforgeQuickEditDialog
...@@ -373,18 +376,18 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -373,18 +376,18 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.menustrip.Append(m,_("&Settings")) self.menustrip.Append(m,_("&Settings"))
self.update_macros_menu() self.update_macros_menu()
self.SetMenuBar(self.menustrip) self.SetMenuBar(self.menustrip)
def doneediting(self,gcode): def doneediting(self,gcode):
f=open(self.filename,"w") f=open(self.filename,"w")
f.write("\n".join(gcode)) f.write("\n".join(gcode))
f.close() f.close()
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):
dialog = wx.Dialog(self,-1,_("Enter macro name"),size=(260,85)) dialog = wx.Dialog(self,-1,_("Enter macro name"),size=(260,85))
panel = wx.Panel(dialog,-1) panel = wx.Panel(dialog,-1)
...@@ -408,7 +411,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -408,7 +411,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.edit_macro,macro) wx.CallAfter(self.edit_macro,macro)
dialog.Destroy() dialog.Destroy()
return macro return macro
def edit_macro(self,macro): def edit_macro(self,macro):
if macro == "": return self.new_macro() if macro == "": return self.new_macro()
if self.macros.has_key(macro): if self.macros.has_key(macro):
...@@ -423,7 +426,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -423,7 +426,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
old_def = "" old_def = ""
self.start_macro(macro,old_def) self.start_macro(macro,old_def)
return macro return macro
def update_macros_menu(self): def update_macros_menu(self):
if not hasattr(self,"macros_menu"): if not hasattr(self,"macros_menu"):
return # too early, menu not yet built return # too early, menu not yet built
...@@ -439,7 +442,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -439,7 +442,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def OnExit(self, event): def OnExit(self, event):
self.Close() self.Close()
def rescanports(self,event=None): def rescanports(self,event=None):
scan=self.scanserial() scan=self.scanserial()
portslist=list(scan) portslist=list(scan)
...@@ -454,13 +457,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -454,13 +457,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.serialport.SetValue(portslist[0]) self.serialport.SetValue(portslist[0])
except: except:
pass pass
def popwindow(self): def popwindow(self):
# this list will contain all controls that should be only enabled # this list will contain all controls that should be only enabled
# when we're connected to a printer # when we're connected to a printer
self.printerControls = [] self.printerControls = []
#sizer layout: topsizer is a column sizer containing two sections #sizer layout: topsizer is a column sizer containing two sections
#upper section contains the mini view buttons #upper section contains the mini view buttons
#lower section contains the rest of the window - manual controls, console, visualizations #lower section contains the rest of the window - manual controls, console, visualizations
...@@ -468,7 +471,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -468,7 +471,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
uts=self.uppertopsizer=wx.BoxSizer(wx.HORIZONTAL) uts=self.uppertopsizer=wx.BoxSizer(wx.HORIZONTAL)
self.rescanbtn=wx.Button(self.panel,-1,_("Port")) self.rescanbtn=wx.Button(self.panel,-1,_("Port"))
self.rescanbtn.Bind(wx.EVT_BUTTON,self.rescanports) self.rescanbtn.Bind(wx.EVT_BUTTON,self.rescanports)
uts.Add(self.rescanbtn,0,wx.TOP|wx.LEFT,0) uts.Add(self.rescanbtn,0,wx.TOP|wx.LEFT,0)
self.serialport = wx.ComboBox(self.panel, -1, self.serialport = wx.ComboBox(self.panel, -1,
choices=self.scanserial(), choices=self.scanserial(),
...@@ -494,18 +497,18 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -494,18 +497,18 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
uts.Add(self.resetbtn) uts.Add(self.resetbtn)
self.minibtn=wx.Button(self.panel,-1,_("Mini mode")) self.minibtn=wx.Button(self.panel,-1,_("Mini mode"))
self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview) self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview)
uts.Add((25,-1)) uts.Add((25,-1))
self.monitorbox=wx.CheckBox(self.panel,-1,_("Monitor Printer")) self.monitorbox=wx.CheckBox(self.panel,-1,_("Monitor Printer"))
uts.Add(self.monitorbox,0,wx.ALIGN_CENTER) uts.Add(self.monitorbox,0,wx.ALIGN_CENTER)
self.monitorbox.Bind(wx.EVT_CHECKBOX,self.setmonitor) self.monitorbox.Bind(wx.EVT_CHECKBOX,self.setmonitor)
uts.Add((15,-1),flag=wx.EXPAND) uts.Add((15,-1),flag=wx.EXPAND)
uts.Add(self.minibtn,0,wx.ALIGN_CENTER) uts.Add(self.minibtn,0,wx.ALIGN_CENTER)
#SECOND ROW #SECOND ROW
ubs=self.upperbottomsizer=wx.BoxSizer(wx.HORIZONTAL) ubs=self.upperbottomsizer=wx.BoxSizer(wx.HORIZONTAL)
self.loadbtn=wx.Button(self.panel,-1,_("Load file")) self.loadbtn=wx.Button(self.panel,-1,_("Load file"))
self.loadbtn.Bind(wx.EVT_BUTTON,self.loadfile) self.loadbtn.Bind(wx.EVT_BUTTON,self.loadfile)
ubs.Add(self.loadbtn) ubs.Add(self.loadbtn)
...@@ -539,7 +542,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -539,7 +542,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#self.printerControls.append(self.sendbtn) #self.printerControls.append(self.sendbtn)
lbrs.Add(self.sendbtn) lbrs.Add(self.sendbtn)
lrs.Add(lbrs,0,wx.EXPAND) lrs.Add(lbrs,0,wx.EXPAND)
#left pane #left pane
lls=self.lowerlsizer=wx.GridBagSizer() lls=self.lowerlsizer=wx.GridBagSizer()
lls.Add(wx.StaticText(self.panel,-1,_("mm/min")),pos=(0,4),span=(1,4)) lls.Add(wx.StaticText(self.panel,-1,_("mm/min")),pos=(0,4),span=(1,4))
...@@ -549,15 +552,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -549,15 +552,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lls.Add(wx.StaticText(self.panel,-1,_("Z:")),pos=(1,6),span=(1,1), flag=wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL) lls.Add(wx.StaticText(self.panel,-1,_("Z:")),pos=(1,6),span=(1,1), 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))
lls.Add(self.zfeedc,pos=(1,7),span=(1,3)) lls.Add(self.zfeedc,pos=(1,7),span=(1,3))
#lls.Add((200,375)) #lls.Add((200,375))
self.xyb = XYButtons(self.panel, self.moveXY, self.homeButtonClicked) self.xyb = XYButtons(self.panel, self.moveXY, self.homeButtonClicked)
lls.Add(self.xyb, pos=(2,0), span=(1,6), flag=wx.ALIGN_CENTER) lls.Add(self.xyb, pos=(2,0), span=(1,6), flag=wx.ALIGN_CENTER)
self.zb = ZButtons(self.panel, self.moveZ) self.zb = ZButtons(self.panel, self.moveZ)
lls.Add(self.zb, pos=(2,7), span=(1,2), flag=wx.ALIGN_CENTER) lls.Add(self.zb, pos=(2,7), span=(1,2), flag=wx.ALIGN_CENTER)
wx.CallAfter(self.xyb.SetFocus) wx.CallAfter(self.xyb.SetFocus)
for i in self.cpbuttons: for i in self.cpbuttons:
btn=wx.Button(self.panel,-1,i[0])#) btn=wx.Button(self.panel,-1,i[0])#)
btn.SetBackgroundColour(i[3]) btn.SetBackgroundColour(i[3])
...@@ -567,16 +570,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -567,16 +570,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.btndict[i[1]]=btn self.btndict[i[1]]=btn
self.printerControls.append(btn) self.printerControls.append(btn)
lls.Add(btn,pos=i[2],span=i[4]) lls.Add(btn,pos=i[2],span=i[4])
lls.Add(wx.StaticText(self.panel,-1,_("Heater:")),pos=(3,0),span=(1,1),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) lls.Add(wx.StaticText(self.panel,-1,_("Heater:")),pos=(3,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])] 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)) self.settoff=wx.Button(self.panel,-1,_("Off"),size=(36,-1))
self.settoff.Bind(wx.EVT_BUTTON,lambda e:self.do_settemp("off")) self.settoff.Bind(wx.EVT_BUTTON,lambda e:self.do_settemp("off"))
self.printerControls.append(self.settoff) self.printerControls.append(self.settoff)
lls.Add(self.settoff,pos=(3,1),span=(1,1)) 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,
...@@ -588,34 +591,34 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -588,34 +591,34 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
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=(4,0),span=(1,1),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) lls.Add(wx.StaticText(self.panel,-1,_("Bed:")),pos=(4,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])] 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)) self.setboff=wx.Button(self.panel,-1,_("Off"),size=(36,-1))
self.setboff.Bind(wx.EVT_BUTTON,lambda e:self.do_bedtemp("off")) self.setboff.Bind(wx.EVT_BUTTON,lambda e:self.do_bedtemp("off"))
self.printerControls.append(self.setboff) self.printerControls.append(self.setboff)
lls.Add(self.setboff,pos=(4,1),span=(1,1)) 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=(80,-1)) choices=btemp_choices,style=wx.CB_DROPDOWN, size=(80,-1))
self.btemp.Bind(wx.EVT_COMBOBOX,self.btemp_change) self.btemp.Bind(wx.EVT_COMBOBOX,self.btemp_change)
lls.Add(self.btemp,pos=(4,2),span=(1,2)) lls.Add(self.btemp,pos=(4,2),span=(1,2))
self.setbbtn=wx.Button(self.panel,-1,_("Set"),size=(38,-1)) self.setbbtn=wx.Button(self.panel,-1,_("Set"),size=(38,-1))
self.setbbtn.Bind(wx.EVT_BUTTON,self.do_bedtemp) self.setbbtn.Bind(wx.EVT_BUTTON,self.do_bedtemp)
self.printerControls.append(self.setbbtn) self.printerControls.append(self.setbbtn)
lls.Add(self.setbbtn,pos=(4,4),span=(1,1)) lls.Add(self.setbbtn,pos=(4,4),span=(1,1))
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)
...@@ -626,34 +629,34 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -626,34 +629,34 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if( '(' not in self.btemp.Value): if( '(' not in self.btemp.Value):
self.btemp.SetValue(self.btemp.Value + ' (user)') self.btemp.SetValue(self.btemp.Value + ' (user)')
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)) #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,5),span=(1,3)) lls.Add(self.tempdisp,pos=(4,5),span=(1,3))
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.SetBackgroundColour((225,200,200))
self.edist.SetForegroundColour("black") self.edist.SetForegroundColour("black")
lls.Add(self.edist,pos=(5,2),span=(1,1)) lls.Add(self.edist,pos=(5,2),span=(1,1))
lls.Add(wx.StaticText(self.panel,-1,_("mm")),pos=(5,3),span=(1,2)) lls.Add(wx.StaticText(self.panel,-1,_("mm")),pos=(5,3),span=(1,1))
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.SetBackgroundColour((225,200,200)) self.efeedc.SetBackgroundColour((225,200,200))
self.efeedc.SetForegroundColour("black") self.efeedc.SetForegroundColour("black")
self.efeedc.Bind(wx.EVT_SPINCTRL,self.setfeeds) self.efeedc.Bind(wx.EVT_SPINCTRL,self.setfeeds)
lls.Add(self.efeedc,pos=(6,2),span=(1,1)) lls.Add(self.efeedc,pos=(6,2),span=(1,1))
lls.Add(wx.StaticText(self.panel,-1,_("mm/min")),pos=(6,3),span=(1,2)) lls.Add(wx.StaticText(self.panel,-1,_("mm/min")),pos=(6,3),span=(1,1))
self.xyfeedc.Bind(wx.EVT_SPINCTRL,self.setfeeds) self.xyfeedc.Bind(wx.EVT_SPINCTRL,self.setfeeds)
self.zfeedc.Bind(wx.EVT_SPINCTRL,self.setfeeds) self.zfeedc.Bind(wx.EVT_SPINCTRL,self.setfeeds)
self.zfeedc.SetBackgroundColour((180,255,180)) self.zfeedc.SetBackgroundColour((180,255,180))
self.zfeedc.SetForegroundColour("black") 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=(300,24),title=_("Heater:"),maxval=230) self.hottgauge=TempGauge(self.panel,size=(200,24),title=_("Heater:"),maxval=230)
lls.Add(self.hottgauge,pos=(7,0),span=(1,8)) lls.Add(self.hottgauge,pos=(7,0),span=(1,4))
self.bedtgauge=TempGauge(self.panel,size=(300,24),title=_("Bed:"),maxval=130) self.bedtgauge=TempGauge(self.panel,size=(200,24),title=_("Bed:"),maxval=130)
lls.Add(self.bedtgauge,pos=(8,0),span=(1,8)) lls.Add(self.bedtgauge,pos=(8,0),span=(1,4))
#def scroll_setpoint(e): #def scroll_setpoint(e):
# if e.GetWheelRotation()>0: # if e.GetWheelRotation()>0:
# self.do_settemp(str(self.hsetpoint+1)) # self.do_settemp(str(self.hsetpoint+1))
...@@ -661,6 +664,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -661,6 +664,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
# self.do_settemp(str(max(0,self.hsetpoint-1))) # self.do_settemp(str(max(0,self.hsetpoint-1)))
#self.tgauge.Bind(wx.EVT_MOUSEWHEEL,scroll_setpoint) #self.tgauge.Bind(wx.EVT_MOUSEWHEEL,scroll_setpoint)
self.graph = Graph(self.panel, wx.ID_ANY)
lls.Add(self.graph, pos=(5, 4), span=(4,4), flag=wx.ALIGN_LEFT)
self.gviz=gviz.gviz(self.panel,(300,300), self.gviz=gviz.gviz(self.panel,(300,300),
build_dimensions=self.build_dimensions_list, build_dimensions=self.build_dimensions_list,
grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2), grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2),
...@@ -681,11 +687,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -681,11 +687,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
vcs.Add(self.gviz,1,flag=wx.SHAPED) vcs.Add(self.gviz,1,flag=wx.SHAPED)
cs=self.centersizer=wx.GridBagSizer() cs=self.centersizer=wx.GridBagSizer()
vcs.Add(cs,0,flag=wx.EXPAND) vcs.Add(cs,0,flag=wx.EXPAND)
self.uppersizer=wx.BoxSizer(wx.VERTICAL) self.uppersizer=wx.BoxSizer(wx.VERTICAL)
self.uppersizer.Add(self.uppertopsizer) self.uppersizer.Add(self.uppertopsizer)
self.uppersizer.Add(self.upperbottomsizer) self.uppersizer.Add(self.upperbottomsizer)
self.lowersizer=wx.BoxSizer(wx.HORIZONTAL) self.lowersizer=wx.BoxSizer(wx.HORIZONTAL)
self.lowersizer.Add(lls) self.lowersizer.Add(lls)
self.lowersizer.Add(vcs,1,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL) self.lowersizer.Add(vcs,1,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL)
...@@ -698,29 +704,29 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -698,29 +704,29 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.status.SetStatusText(_("Not connected to printer.")) self.status.SetStatusText(_("Not connected to printer."))
self.panel.Bind(wx.EVT_MOUSE_EVENTS,self.editbutton) self.panel.Bind(wx.EVT_MOUSE_EVENTS,self.editbutton)
self.Bind(wx.EVT_CLOSE, self.kill) self.Bind(wx.EVT_CLOSE, self.kill)
self.topsizer.Layout() self.topsizer.Layout()
self.topsizer.Fit(self) self.topsizer.Fit(self)
# disable all printer controls until we connect to a printer # disable all printer controls until we connect to a printer
self.pausebtn.Disable() self.pausebtn.Disable()
for i in self.printerControls: for i in self.printerControls:
i.Disable() i.Disable()
#self.panel.Fit() #self.panel.Fit()
#uts.Layout() #uts.Layout()
self.cbuttons_reload() self.cbuttons_reload()
def plate(self,e): def plate(self,e):
import plater import plater
print "plate function activated" 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): def platecb(self,name):
print "plated: "+name print "plated: "+name
self.loadfile(None,name) self.loadfile(None,name)
def sdmenu(self,e): def sdmenu(self,e):
obj = e.GetEventObject() obj = e.GetEventObject()
popupmenu=wx.Menu() popupmenu=wx.Menu()
...@@ -731,7 +737,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -731,7 +737,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
item = popupmenu.Append(-1,_("SD Print")) item = popupmenu.Append(-1,_("SD Print"))
self.Bind(wx.EVT_MENU,self.sdprintfile,id=item.GetId()) self.Bind(wx.EVT_MENU,self.sdprintfile,id=item.GetId())
self.panel.PopupMenu(popupmenu, obj.GetPosition()) self.panel.PopupMenu(popupmenu, obj.GetPosition())
def htemp_change(self,event): def htemp_change(self,event):
if self.hsetpoint > 0: if self.hsetpoint > 0:
self.do_settemp("") self.do_settemp("")
...@@ -741,7 +747,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -741,7 +747,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if self.bsetpoint > 0: if self.bsetpoint > 0:
self.do_bedtemp("") self.do_bedtemp("")
wx.CallAfter(self.btemp.SetInsertionPoint,0) 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(True) self.gwindow.Show(True)
...@@ -761,23 +767,23 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -761,23 +767,23 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.settings._set("xy_feedrate",self.xyfeedc.GetValue()) self.settings._set("xy_feedrate",self.xyfeedc.GetValue())
except: except:
pass pass
def toggleview(self,e): def toggleview(self,e):
if(self.mini): if(self.mini):
self.mini=False self.mini=False
self.topsizer.Fit(self) self.topsizer.Fit(self)
#self.SetSize(winsize) #self.SetSize(winsize)
wx.CallAfter(self.minibtn.SetLabel, _("Mini mode")) wx.CallAfter(self.minibtn.SetLabel, _("Mini mode"))
else: else:
self.mini=True self.mini=True
self.uppersizer.Fit(self) self.uppersizer.Fit(self)
#self.SetSize(winssize) #self.SetSize(winssize)
wx.CallAfter(self.minibtn.SetLabel, _("Full mode")) wx.CallAfter(self.minibtn.SetLabel, _("Full mode"))
def cbuttons_reload(self): def cbuttons_reload(self):
allcbs = [] allcbs = []
ubs=self.upperbottomsizer ubs=self.upperbottomsizer
...@@ -829,10 +835,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -829,10 +835,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
else: else:
cs.Add(b,pos=((i-4)/3,(i-4)%3)) cs.Add(b,pos=((i-4)/3,(i-4)%3))
self.topsizer.Layout() self.topsizer.Layout()
def help_button(self): def help_button(self):
print _('Defines custom button. Usage: button <num> "title" [/c "colour"] command') print _('Defines custom button. Usage: button <num> "title" [/c "colour"] command')
def do_button(self,argstr): def do_button(self,argstr):
def nextarg(rest): def nextarg(rest):
rest=rest.lstrip() rest=rest.lstrip()
...@@ -865,7 +871,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -865,7 +871,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#except Exception,x: #except Exception,x:
# print "Bad syntax for button definition, see 'help button'" # print "Bad syntax for button definition, see 'help button'"
# print x # print x
def cbutton_save(self,n,bdef,new_n=None): def cbutton_save(self,n,bdef,new_n=None):
if new_n is None: new_n=n if new_n is None: new_n=n
...@@ -921,7 +927,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -921,7 +927,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#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]
wx.CallAfter(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
if dir<0: if dir<0:
...@@ -935,7 +941,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -935,7 +941,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#if self.custombuttons[-1] is None: #if self.custombuttons[-1] is None:
# del self.custombuttons[-1] # del self.custombuttons[-1]
self.cbuttons_reload() self.cbuttons_reload()
def editbutton(self,e): def editbutton(self,e):
if e.IsCommandEvent() or e.ButtonUp(wx.MOUSE_BTN_RIGHT): if e.IsCommandEvent() or e.ButtonUp(wx.MOUSE_BTN_RIGHT):
if e.IsCommandEvent(): if e.IsCommandEvent():
...@@ -967,7 +973,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -967,7 +973,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.dragpos = scrpos self.dragpos = scrpos
e.Skip() e.Skip()
return return
else: 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 if dx*dx+dy*dy < 5*5: # threshold to detect dragging for jittery mice
e.Skip() e.Skip()
...@@ -998,11 +1004,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -998,11 +1004,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.dragging.label = obj.s_label = obj.GetLabel() self.dragging.label = obj.s_label = obj.GetLabel()
self.dragging.bgc = obj.s_bgc = obj.GetBackgroundColour() self.dragging.bgc = obj.s_bgc = obj.GetBackgroundColour()
self.dragging.fgc = obj.s_fgc = obj.GetForegroundColour() self.dragging.fgc = obj.s_fgc = obj.GetForegroundColour()
else: else:
# dragging in progress # dragging in progress
self.dragging.SetPosition(self.panel.ScreenToClient(scrpos)) self.dragging.SetPosition(self.panel.ScreenToClient(scrpos))
wx.CallAfter(self.dragging.Refresh) wx.CallAfter(self.dragging.Refresh)
btns = self.custombuttonbuttons btns = self.custombuttonbuttons
dst = None dst = None
src = self.dragging.sourcebutton src = self.dragging.sourcebutton
drg = self.dragging drg = self.dragging
...@@ -1072,7 +1078,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1072,7 +1078,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
del self.dragpos del self.dragpos
else: else:
e.Skip() e.Skip()
def homeButtonClicked(self, corner): def homeButtonClicked(self, corner):
if corner == 0: # upper-left if corner == 0: # upper-left
self.onecmd('home X') self.onecmd('home X')
...@@ -1082,17 +1088,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1082,17 +1088,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.onecmd('home Z') self.onecmd('home Z')
if corner == 3: # lower-left if corner == 3: # lower-left
self.onecmd('home') self.onecmd('home')
def moveXY(self, x, y): def moveXY(self, x, y):
if x != 0: if x != 0:
self.onecmd('move X %s' % x) self.onecmd('move X %s' % x)
if y != 0: if y != 0:
self.onecmd('move Y %s' % y) self.onecmd('move Y %s' % y)
def moveZ(self, z): def moveZ(self, z):
if z != 0: if z != 0:
self.onecmd('move Z %s' % z) self.onecmd('move Z %s' % z)
def procbutton(self,e): def procbutton(self,e):
try: try:
if hasattr(e.GetEventObject(),"custombutton"): if hasattr(e.GetEventObject(),"custombutton"):
...@@ -1105,7 +1111,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1105,7 +1111,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
print _("event object missing") print _("event object missing")
self.cur_button=None self.cur_button=None
raise raise
def kill(self,e): def kill(self,e):
self.statuscheck=0 self.statuscheck=0
self.p.recvcb=None self.p.recvcb=None
...@@ -1119,7 +1125,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1119,7 +1125,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
except: except:
pass pass
self.Destroy() self.Destroy()
def do_monitor(self,l=""): def do_monitor(self,l=""):
if l.strip()=="": if l.strip()=="":
self.monitorbox.SetValue(not self.monitorbox.GetValue()) self.monitorbox.SetValue(not self.monitorbox.GetValue())
...@@ -1136,11 +1142,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1136,11 +1142,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
print _("Monitoring printer.") print _("Monitoring printer.")
else: else:
print _("Done monitoring.") print _("Done monitoring.")
def setmonitor(self,e): def setmonitor(self,e):
self.monitor=self.monitorbox.GetValue() self.monitor=self.monitorbox.GetValue()
if self.monitor:
self.graph.StartPlotting(1000)
else:
self.graph.StopPlotting()
def sendline(self,e): def sendline(self,e):
command=self.commandbox.GetValue() command=self.commandbox.GetValue()
if not len(command): if not len(command):
...@@ -1151,7 +1163,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1151,7 +1163,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def clearOutput(self,e): def clearOutput(self,e):
self.logbox.Clear() self.logbox.Clear()
def statuschecker(self): def statuschecker(self):
try: try:
while(self.statuscheck): while(self.statuscheck):
...@@ -1166,7 +1178,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1166,7 +1178,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.tempdisp.SetLabel,self.tempreport.strip().replace("ok ","")) wx.CallAfter(self.tempdisp.SetLabel,self.tempreport.strip().replace("ok ",""))
try: try:
self.hottgauge.SetValue(float(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1])) self.hottgauge.SetValue(float(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1]))
self.graph.SetExtruder1Temperature(float(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1]))
self.bedtgauge.SetValue(float(filter(lambda x:x.startswith("B:"),self.tempreport.split())[0].split(":")[1])) self.bedtgauge.SetValue(float(filter(lambda x:x.startswith("B:"),self.tempreport.split())[0].split(":")[1]))
self.graph.SetBedTemperature(float(filter(lambda x:x.startswith("B:"),self.tempreport.split())[0].split(":")[1]))
except: except:
pass pass
fractioncomplete = 0.0 fractioncomplete = 0.0
...@@ -1212,7 +1226,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1212,7 +1226,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
pass pass
if cout is None: if cout is None:
cout=cStringIO.StringIO() cout=cStringIO.StringIO()
sys.stdout=cout sys.stdout=cout
retval=None retval=None
try: try:
...@@ -1228,7 +1242,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1228,7 +1242,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.tempdisp.SetLabel,self.tempreport.strip().replace("ok ","")) wx.CallAfter(self.tempdisp.SetLabel,self.tempreport.strip().replace("ok ",""))
try: try:
self.hottgauge.SetValue(float(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1])) self.hottgauge.SetValue(float(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1]))
self.bedtgauge.SetValue(float(filter(lambda x:x.startswith("B:"),self.tempreport.split())[0].split(":")[1])) self.graph.SetExtruder1Temperature(float(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1]))
self.graph.SetBedTemperature(float(filter(lambda x:x.startswith("B:"),self.tempreport.split())[0].split(":")[1]))
except: except:
pass pass
tstring=l.rstrip() tstring=l.rstrip()
...@@ -1238,7 +1253,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1238,7 +1253,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#wx.CallAfter(self.logbox.AppendText,tstring+"\n") #wx.CallAfter(self.logbox.AppendText,tstring+"\n")
for i in self.recvlisteners: for i in self.recvlisteners:
i(l) i(l)
def listfiles(self,line): def listfiles(self,line):
if "Begin file list" in line: if "Begin file list" in line:
self.listing=1 self.listing=1
...@@ -1248,7 +1263,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1248,7 +1263,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.filesloaded) wx.CallAfter(self.filesloaded)
elif self.listing: elif self.listing:
self.sdfiles+=[line.replace("\n","").replace("\r","").lower()] self.sdfiles+=[line.replace("\n","").replace("\r","").lower()]
def waitforsdresponse(self,l): def waitforsdresponse(self,l):
if "file.open failed" in l: if "file.open failed" in l:
wx.CallAfter(self.status.SetStatusText,_("Opening file failed.")) wx.CallAfter(self.status.SetStatusText,_("Opening file failed."))
...@@ -1276,9 +1291,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1276,9 +1291,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.percentdone=100.0*int(vals[0])/int(vals[1]) self.percentdone=100.0*int(vals[0])/int(vals[1])
except: except:
pass pass
def filesloaded(self): def filesloaded(self):
dlg=wx.SingleChoiceDialog(self, _("Select the file to print"), _("Pick SD file"), self.sdfiles) dlg=wx.SingleChoiceDialog(self, _("Select the file to print"), _("Pick SD file"), self.sdfiles)
if(dlg.ShowModal()==wx.ID_OK): if(dlg.ShowModal()==wx.ID_OK):
...@@ -1286,7 +1301,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1286,7 +1301,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if len(target): if len(target):
self.recvlisteners+=[self.waitforsdresponse] self.recvlisteners+=[self.waitforsdresponse]
self.p.send_now("M23 "+target.lower()) self.p.send_now("M23 "+target.lower())
#print self.sdfiles #print self.sdfiles
pass pass
...@@ -1299,7 +1314,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1299,7 +1314,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.recvlisteners+=[self.listfiles] self.recvlisteners+=[self.listfiles]
self.p.send_now("M21") self.p.send_now("M21")
self.p.send_now("M20") self.p.send_now("M20")
def skein_func(self): def skein_func(self):
try: try:
import shlex import shlex
...@@ -1318,7 +1333,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1318,7 +1333,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
print _("Failed to execute slicing software: ") print _("Failed to execute slicing software: ")
self.stopsf=1 self.stopsf=1
traceback.print_exc(file=sys.stdout) traceback.print_exc(file=sys.stdout)
def skein_monitor(self): def skein_monitor(self):
while(not self.stopsf): while(not self.stopsf):
try: try:
...@@ -1334,7 +1349,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1334,7 +1349,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
of.close of.close
if self.p.online: if self.p.online:
wx.CallAfter(self.printbtn.Enable) wx.CallAfter(self.printbtn.Enable)
wx.CallAfter(self.status.SetStatusText,_("Loaded ")+self.filename+_(", %d lines") % (len(self.f),)) wx.CallAfter(self.status.SetStatusText,_("Loaded ")+self.filename+_(", %d lines") % (len(self.f),))
wx.CallAfter(self.pausebtn.Disable) wx.CallAfter(self.pausebtn.Disable)
wx.CallAfter(self.printbtn.SetLabel,_("Print")) wx.CallAfter(self.printbtn.SetLabel,_("Print"))
...@@ -1345,8 +1360,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1345,8 +1360,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.loadbtn.SetLabel,_("Load File")) wx.CallAfter(self.loadbtn.SetLabel,_("Load File"))
self.skeining=0 self.skeining=0
self.skeinp=None self.skeinp=None
def skein(self,filename): def skein(self,filename):
wx.CallAfter(self.loadbtn.SetLabel,_("Cancel")) wx.CallAfter(self.loadbtn.SetLabel,_("Cancel"))
print _("Slicing ") + filename print _("Slicing ") + filename
...@@ -1356,7 +1371,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1356,7 +1371,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.skeining=1 self.skeining=1
thread(target=self.skein_func).start() thread(target=self.skein_func).start()
thread(target=self.skein_monitor).start() thread(target=self.skein_monitor).start()
def loadfile(self,event,filename=None): def loadfile(self,event,filename=None):
if self.skeining and self.skeinp is not None: if self.skeining and self.skeinp is not None:
self.skeinp.terminate() self.skeinp.terminate()
...@@ -1397,7 +1412,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1397,7 +1412,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if self.p.online: if self.p.online:
wx.CallAfter(self.printbtn.Enable) wx.CallAfter(self.printbtn.Enable)
threading.Thread(target=self.loadviz).start() threading.Thread(target=self.loadviz).start()
def loadviz(self): def loadviz(self):
Xtot,Ytot,Ztot,Xmin,Xmax,Ymin,Ymax,Zmin,Zmax = pronsole.measurements(self.f) Xtot,Ytot,Ztot,Xmin,Xmax,Ymin,Ymax,Zmin,Zmax = pronsole.measurements(self.f)
print pronsole.totalelength(self.f), _("mm of filament used in this print\n") print pronsole.totalelength(self.f), _("mm of filament used in this print\n")
...@@ -1416,7 +1431,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1416,7 +1431,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#print "generated 3d view in %f s"%(time.time()-t0) #print "generated 3d view in %f s"%(time.time()-t0)
self.gviz.showall=1 self.gviz.showall=1
wx.CallAfter(self.gviz.Refresh) wx.CallAfter(self.gviz.Refresh)
def printfile(self,event): def printfile(self,event):
self.extra_print_time=0 self.extra_print_time=0
if self.paused: if self.paused:
...@@ -1427,7 +1442,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1427,7 +1442,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.p.send_now("M26 S0") self.p.send_now("M26 S0")
self.p.send_now("M24") self.p.send_now("M24")
return return
if self.f is None or not len(self.f): if self.f is None or not len(self.f):
wx.CallAfter(self.status.SetStatusText, _("No file loaded. Please use load first.")) wx.CallAfter(self.status.SetStatusText, _("No file loaded. Please use load first."))
return return
...@@ -1436,19 +1451,19 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1436,19 +1451,19 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
return return
self.on_startprint() self.on_startprint()
self.p.startprint(self.f) self.p.startprint(self.f)
def on_startprint(self): def on_startprint(self):
wx.CallAfter(self.pausebtn.SetLabel, _("Pause")) wx.CallAfter(self.pausebtn.SetLabel, _("Pause"))
wx.CallAfter(self.pausebtn.Enable) wx.CallAfter(self.pausebtn.Enable)
wx.CallAfter(self.printbtn.SetLabel, _("Restart")) wx.CallAfter(self.printbtn.SetLabel, _("Restart"))
def endupload(self): def endupload(self):
self.p.send_now("M29 ") self.p.send_now("M29 ")
wx.CallAfter(self.status.SetStatusText, _("File upload complete")) wx.CallAfter(self.status.SetStatusText, _("File upload complete"))
time.sleep(0.5) time.sleep(0.5)
self.p.clear=True self.p.clear=True
self.uploading=False self.uploading=False
def uploadtrigger(self,l): def uploadtrigger(self,l):
if "Writing to file" in l: if "Writing to file" in l:
self.uploading=True self.uploading=True
...@@ -1457,7 +1472,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1457,7 +1472,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.recvlisteners.remove(self.uploadtrigger) self.recvlisteners.remove(self.uploadtrigger)
elif "open failed, File" in l: elif "open failed, File" in l:
self.recvlisteners.remove(self.uploadtrigger) self.recvlisteners.remove(self.uploadtrigger)
def upload(self,event): def upload(self,event):
if not self.f or not len(self.f): if not self.f or not len(self.f):
return return
...@@ -1469,7 +1484,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1469,7 +1484,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.p.send_now("M28 "+str(dlg.GetValue())) self.p.send_now("M28 "+str(dlg.GetValue()))
self.recvlisteners+=[self.uploadtrigger] self.recvlisteners+=[self.uploadtrigger]
pass pass
def pause(self,event): def pause(self,event):
print _("Paused.") print _("Paused.")
if not self.paused: if not self.paused:
...@@ -1490,13 +1505,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1490,13 +1505,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
else: else:
self.p.resume() self.p.resume()
wx.CallAfter(self.pausebtn.SetLabel, _("Pause")) wx.CallAfter(self.pausebtn.SetLabel, _("Pause"))
def sdprintfile(self,event): def sdprintfile(self,event):
self.on_startprint() self.on_startprint()
threading.Thread(target=self.getfiles).start() threading.Thread(target=self.getfiles).start()
pass pass
def connect(self,event): def connect(self,event):
print _("Connecting...") print _("Connecting...")
port=None port=None
...@@ -1526,13 +1541,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1526,13 +1541,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if baud != self.settings.baudrate: if baud != self.settings.baudrate:
self.set("baudrate",str(baud)) self.set("baudrate",str(baud))
threading.Thread(target=self.statuschecker).start() threading.Thread(target=self.statuschecker).start()
def disconnect(self,event): def disconnect(self,event):
print _("Disconnected.") print _("Disconnected.")
self.p.disconnect() self.p.disconnect()
self.statuscheck=False self.statuscheck=False
self.connectbtn.SetLabel("Connect") self.connectbtn.SetLabel("Connect")
self.connectbtn.Bind(wx.EVT_BUTTON,self.connect) self.connectbtn.Bind(wx.EVT_BUTTON,self.connect)
...@@ -1544,7 +1559,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1544,7 +1559,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
# Disable XYButtons and ZButtons # Disable XYButtons and ZButtons
wx.CallAfter(self.xyb.disable) wx.CallAfter(self.xyb.disable)
wx.CallAfter(self.zb.disable) wx.CallAfter(self.zb.disable)
if self.paused: if self.paused:
self.p.paused=0 self.p.paused=0
self.p.printing=0 self.p.printing=0
...@@ -1553,8 +1568,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1553,8 +1568,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.paused=0 self.paused=0
if self.sdprinting: if self.sdprinting:
self.p.send_now("M26 S0") self.p.send_now("M26 S0")
def reset(self,event): def reset(self,event):
print _("Reset.") print _("Reset.")
dlg=wx.MessageDialog(self, _("Are you sure you want to reset the printer?"), _("Reset?"), wx.YES|wx.NO) dlg=wx.MessageDialog(self, _("Are you sure you want to reset the printer?"), _("Reset?"), wx.YES|wx.NO)
...@@ -1566,7 +1581,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1566,7 +1581,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.p.paused=0 self.p.paused=0
wx.CallAfter(self.pausebtn.SetLabel, _("Pause")) wx.CallAfter(self.pausebtn.SetLabel, _("Pause"))
self.paused=0 self.paused=0
def get_build_dimensions(self,bdim): def get_build_dimensions(self,bdim):
import re import re
# a string containing up to six numbers delimited by almost anything # a string containing up to six numbers delimited by almost anything
...@@ -1678,7 +1693,7 @@ class options(wx.Dialog): ...@@ -1678,7 +1693,7 @@ class options(wx.Dialog):
grid.Add(ctrls[k,0],0,wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT) grid.Add(ctrls[k,0],0,wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT)
grid.Add(ctrls[k,1],1,wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND) grid.Add(ctrls[k,1],1,wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND)
topsizer.Add(self.CreateSeparatedButtonSizer(wx.OK+wx.CANCEL),0,wx.EXPAND) topsizer.Add(self.CreateSeparatedButtonSizer(wx.OK+wx.CANCEL),0,wx.EXPAND)
self.SetSizer(topsizer) self.SetSizer(topsizer)
topsizer.Layout() topsizer.Layout()
topsizer.Fit(self) topsizer.Fit(self)
if self.ShowModal()==wx.ID_OK: if self.ShowModal()==wx.ID_OK:
...@@ -1686,7 +1701,7 @@ class options(wx.Dialog): ...@@ -1686,7 +1701,7 @@ class options(wx.Dialog):
if ctrls[k,1].GetValue() != str(v): if ctrls[k,1].GetValue() != str(v):
pronterface.set(k,str(ctrls[k,1].GetValue())) pronterface.set(k,str(ctrls[k,1].GetValue()))
self.Destroy() self.Destroy()
class ButtonEdit(wx.Dialog): class ButtonEdit(wx.Dialog):
"""Custom button edit dialog""" """Custom button edit dialog"""
def __init__(self,pronterface): def __init__(self,pronterface):
...@@ -1734,7 +1749,7 @@ class ButtonEdit(wx.Dialog): ...@@ -1734,7 +1749,7 @@ class ButtonEdit(wx.Dialog):
self.command.SetValue(macro) self.command.SetValue(macro)
if self.name.GetValue()=="": if self.name.GetValue()=="":
self.name.SetValue(macro) self.name.SetValue(macro)
class TempGauge(wx.Panel): class TempGauge(wx.Panel):
def __init__(self,parent,size=(200,22),title="",maxval=240,gaugeColour=None): def __init__(self,parent,size=(200,22),title="",maxval=240,gaugeColour=None):
wx.Panel.__init__(self,parent,-1,size=size) wx.Panel.__init__(self,parent,-1,size=size)
...@@ -1829,12 +1844,12 @@ class TempGauge(wx.Panel): ...@@ -1829,12 +1844,12 @@ class TempGauge(wx.Panel):
#gc.SetFont(gc.CreateFont(wx.Font(12,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD),wx.WHITE)) #gc.SetFont(gc.CreateFont(wx.Font(12,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD),wx.WHITE))
#gc.DrawText(text,29,-2) #gc.DrawText(text,29,-2)
gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD),wx.WHITE)) gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD),wx.WHITE))
gc.DrawText(self.title,x0+19,y0+1) gc.DrawText(self.title,x0+19,y0+4)
gc.DrawText(text, x0+153,y0+1) gc.DrawText(text, x0+133,y0+4)
gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD))) gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD)))
gc.DrawText(self.title,x0+18,y0+0) gc.DrawText(self.title,x0+18,y0+3)
gc.DrawText(text, x0+152,y0+0) gc.DrawText(text, x0+132,y0+3)
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