Commit db143e85 authored by Guillaume Seguin's avatar Guillaume Seguin

Split GUI

parent 3a8bb527
# 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/>.
try:
import wx
except:
print _("WX is not installed. This program requires WX to run.")
raise
global buttonSize
buttonSize = (70, 25) # Define sizes for the buttons on top rows
from printrun import gviz
from printrun.xybuttons import XYButtons
from printrun.zbuttons import ZButtons
from printrun.graph import Graph
class XYZControlsSizer(wx.GridBagSizer):
def __init__(self, root):
super(XYZControlsSizer, self).__init__()
self.xyb = XYButtons(root.panel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.settings.bgcolor)
self.Add(self.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER)
self.zb = ZButtons(root.panel, root.moveZ, root.settings.bgcolor)
self.Add(self.zb, pos = (0, 2), flag = wx.ALIGN_CENTER)
wx.CallAfter(self.xyb.SetFocus)
class LeftPane(wx.GridBagSizer):
def __init__(self, root):
super(LeftPane, self).__init__()
llts = wx.BoxSizer(wx.HORIZONTAL)
self.Add(llts, pos = (0, 0), span = (1, 9))
self.xyzsizer = XYZControlsSizer(root)
self.Add(self.xyzsizer, pos = (1, 0), span = (1, 8), flag = wx.ALIGN_CENTER)
for i in root.cpbuttons:
btn = wx.Button(root.panel,-1, i[0], style = wx.BU_EXACTFIT)
btn.SetToolTip(wx.ToolTip(i[5]))
btn.SetBackgroundColour(i[3])
btn.SetForegroundColour("black")
btn.properties = i
btn.Bind(wx.EVT_BUTTON, root.procbutton)
root.btndict[i[1]]=btn
root.printerControls.append(btn)
if i[2] == None:
if i[4] == 0:
llts.Add(btn)
else:
self.Add(btn, pos = i[2], span = i[4])
root.xyfeedc = wx.SpinCtrl(root.panel,-1, str(root.settings.xy_feedrate), min = 0, max = 50000, size = (70,-1))
root.xyfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for X & Y axes (mm/min)"))
llts.Add(wx.StaticText(root.panel,-1, _("XY:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
llts.Add(root.xyfeedc)
llts.Add(wx.StaticText(root.panel,-1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
root.zfeedc = wx.SpinCtrl(root.panel,-1, str(root.settings.z_feedrate), min = 0, max = 50000, size = (70,-1))
root.zfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for Z axis (mm/min)"))
llts.Add(root.zfeedc,)
root.monitorbox = wx.CheckBox(root.panel,-1, _("Watch"))
root.monitorbox.SetToolTip(wx.ToolTip("Monitor Temperatures in Graph"))
self.Add(root.monitorbox, pos = (2, 6))
root.monitorbox.Bind(wx.EVT_CHECKBOX, root.setmonitor)
self.Add(wx.StaticText(root.panel,-1, _("Heat:")), pos = (2, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
htemp_choices = [root.temps[i]+" ("+i+")" for i in sorted(root.temps.keys(), key = lambda x:root.temps[x])]
root.settoff = wx.Button(root.panel,-1, _("Off"), size = (36,-1), style = wx.BU_EXACTFIT)
root.settoff.SetToolTip(wx.ToolTip("Switch Hotend Off"))
root.settoff.Bind(wx.EVT_BUTTON, lambda e:root.do_settemp("off"))
root.printerControls.append(root.settoff)
self.Add(root.settoff, pos = (2, 1), span = (1, 1))
if root.settings.last_temperature not in map(float, root.temps.values()):
htemp_choices = [str(root.settings.last_temperature)] + htemp_choices
root.htemp = wx.ComboBox(root.panel, -1,
choices = htemp_choices, style = wx.CB_DROPDOWN, size = (70,-1))
root.htemp.SetToolTip(wx.ToolTip("Select Temperature for Hotend"))
root.htemp.Bind(wx.EVT_COMBOBOX, root.htemp_change)
self.Add(root.htemp, pos = (2, 2), span = (1, 2))
root.settbtn = wx.Button(root.panel,-1, _("Set"), size = (38,-1), style = wx.BU_EXACTFIT)
root.settbtn.SetToolTip(wx.ToolTip("Switch Hotend On"))
root.settbtn.Bind(wx.EVT_BUTTON, root.do_settemp)
root.printerControls.append(root.settbtn)
self.Add(root.settbtn, pos = (2, 4), span = (1, 1))
self.Add(wx.StaticText(root.panel,-1, _("Bed:")), pos = (3, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
btemp_choices = [root.bedtemps[i]+" ("+i+")" for i in sorted(root.bedtemps.keys(), key = lambda x:root.temps[x])]
root.setboff = wx.Button(root.panel,-1, _("Off"), size = (36,-1), style = wx.BU_EXACTFIT)
root.setboff.SetToolTip(wx.ToolTip("Switch Heated Bed Off"))
root.setboff.Bind(wx.EVT_BUTTON, lambda e:root.do_bedtemp("off"))
root.printerControls.append(root.setboff)
self.Add(root.setboff, pos = (3, 1), span = (1, 1))
if root.settings.last_bed_temperature not in map(float, root.bedtemps.values()):
btemp_choices = [str(root.settings.last_bed_temperature)] + btemp_choices
root.btemp = wx.ComboBox(root.panel, -1,
choices = btemp_choices, style = wx.CB_DROPDOWN, size = (70,-1))
root.btemp.SetToolTip(wx.ToolTip("Select Temperature for Heated Bed"))
root.btemp.Bind(wx.EVT_COMBOBOX, root.btemp_change)
self.Add(root.btemp, pos = (3, 2), span = (1, 2))
root.setbbtn = wx.Button(root.panel,-1, _("Set"), size = (38,-1), style = wx.BU_EXACTFIT)
root.setbbtn.SetToolTip(wx.ToolTip("Switch Heated Bed On"))
root.setbbtn.Bind(wx.EVT_BUTTON, root.do_bedtemp)
root.printerControls.append(root.setbbtn)
self.Add(root.setbbtn, pos = (3, 4), span = (1, 1))
root.btemp.SetValue(str(root.settings.last_bed_temperature))
root.htemp.SetValue(str(root.settings.last_temperature))
## 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.
# if it is not, then a (user) remark is added. This denotes a manual entry
for i in btemp_choices:
if i.split()[0] == str(root.settings.last_bed_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_bed_temperature):
root.btemp.SetValue(i)
for i in htemp_choices:
if i.split()[0] == str(root.settings.last_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_temperature) :
root.htemp.SetValue(i)
if( '(' not in root.btemp.Value):
root.btemp.SetValue(root.btemp.Value + ' (user)')
if( '(' not in root.htemp.Value):
root.htemp.SetValue(root.htemp.Value + ' (user)')
#self.Add(root.btemp, pos = (4, 1), span = (1, 3))
#self.Add(root.setbbtn, pos = (4, 4), span = (1, 2))
root.tempdisp = wx.StaticText(root.panel,-1, "")
root.edist = wx.SpinCtrl(root.panel,-1, "5", min = 0, max = 1000, size = (60,-1))
root.edist.SetBackgroundColour((225, 200, 200))
root.edist.SetForegroundColour("black")
self.Add(root.edist, pos = (4, 2), span = (1, 2))
self.Add(wx.StaticText(root.panel,-1, _("mm")), pos = (4, 4), span = (1, 1))
root.edist.SetToolTip(wx.ToolTip("Amount to Extrude or Retract (mm)"))
root.efeedc = wx.SpinCtrl(root.panel,-1, str(root.settings.e_feedrate), min = 0, max = 50000, size = (60,-1))
root.efeedc.SetToolTip(wx.ToolTip("Extrude / Retract speed (mm/min)"))
root.efeedc.SetBackgroundColour((225, 200, 200))
root.efeedc.SetForegroundColour("black")
root.efeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
self.Add(root.efeedc, pos = (5, 2), span = (1, 2))
self.Add(wx.StaticText(root.panel,-1, _("mm/\nmin")), pos = (5, 4), span = (1, 1))
root.xyfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
root.zfeedc.SetBackgroundColour((180, 255, 180))
root.zfeedc.SetForegroundColour("black")
# self.Add((10, 0), pos = (0, 11), span = (1, 1))
#root.hottgauge = TempGauge(root.panel, size = (200, 24), title = _("Heater:"), maxval = 230)
#self.Add(root.hottgauge, pos = (7, 0), span = (1, 4))
#root.bedtgauge = TempGauge(root.panel, size = (200, 24), title = _("Bed:"), maxval = 130)
#self.Add(root.bedtgauge, pos = (8, 0), span = (1, 4))
#def scroll_setpoint(e):
# if e.GetWheelRotation()>0:
# root.do_settemp(str(root.hsetpoint+1))
# elif e.GetWheelRotation()<0:
# root.do_settemp(str(max(0, root.hsetpoint-1)))
#root.tgauge.Bind(wx.EVT_MOUSEWHEEL, scroll_setpoint)
root.graph = Graph(root.panel, wx.ID_ANY)
self.Add(root.graph, pos = (3, 5), span = (3, 3))
self.Add(root.tempdisp, pos = (6, 0), span = (1, 9))
class VizPane(wx.BoxSizer):
def __init__(self, root):
super(VizPane, self).__init__(wx.VERTICAL)
root.gviz = gviz.gviz(root.panel, (300, 300),
build_dimensions = root.build_dimensions_list,
grid = (root.settings.preview_grid_step1, root.settings.preview_grid_step2),
extrusion_width = root.settings.preview_extrusion_width)
root.gviz.SetToolTip(wx.ToolTip("Click to examine / edit\n layers of loaded file"))
root.gviz.showall = 1
try:
raise ""
import printrun.stlview
root.gwindow = printrun.stlview.GCFrame(None, wx.ID_ANY, 'Gcode view, shift to move view, mousewheel to set layer', size = (600, 600))
except:
root.gwindow = gviz.window([],
build_dimensions = root.build_dimensions_list,
grid = (root.settings.preview_grid_step1, root.settings.preview_grid_step2),
extrusion_width = root.settings.preview_extrusion_width)
root.gviz.Bind(wx.EVT_LEFT_DOWN, root.showwin)
root.gwindow.Bind(wx.EVT_CLOSE, lambda x:root.gwindow.Hide())
self.Add(root.gviz, 1, flag = wx.SHAPED)
cs = root.centersizer = wx.GridBagSizer()
self.Add(cs, 0, flag = wx.EXPAND)
class LogPane(wx.BoxSizer):
def __init__(self, root):
super(LogPane, self).__init__(wx.VERTICAL)
root.lowerrsizer = self
root.logbox = wx.TextCtrl(root.panel, style = wx.TE_MULTILINE, size = (350,-1))
root.logbox.SetEditable(0)
self.Add(root.logbox, 1, wx.EXPAND)
lbrs = wx.BoxSizer(wx.HORIZONTAL)
root.commandbox = wx.TextCtrl(root.panel, style = wx.TE_PROCESS_ENTER)
root.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)"))
root.commandbox.Bind(wx.EVT_TEXT_ENTER, root.sendline)
root.commandbox.Bind(wx.EVT_CHAR, root.cbkey)
root.commandbox.history = [u""]
root.commandbox.histindex = 1
#root.printerControls.append(root.commandbox)
lbrs.Add(root.commandbox, 1)
root.sendbtn = wx.Button(root.panel,-1, _("Send"), style = wx.BU_EXACTFIT)
root.sendbtn.SetToolTip(wx.ToolTip("Send Command to Printer"))
root.sendbtn.Bind(wx.EVT_BUTTON, root.sendline)
#root.printerControls.append(root.sendbtn)
lbrs.Add(root.sendbtn)
self.Add(lbrs, 0, wx.EXPAND)
class MainToolbar(wx.BoxSizer):
def __init__(self, root):
super(MainToolbar, self).__init__(wx.HORIZONTAL)
root.rescanbtn = wx.Button(root.panel,-1, _("Port"), size = buttonSize)
root.rescanbtn.SetToolTip(wx.ToolTip("Communication Settings\nClick to rescan ports"))
root.rescanbtn.Bind(wx.EVT_BUTTON, root.rescanports)
self.Add(root.rescanbtn, 0, wx.TOP|wx.LEFT, 0)
root.serialport = wx.ComboBox(root.panel, -1,
choices = root.scanserial(),
style = wx.CB_DROPDOWN, size = (100, 25))
root.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to"))
root.rescanports()
self.Add(root.serialport)
self.Add(wx.StaticText(root.panel,-1, "@"), 0, wx.RIGHT|wx.ALIGN_CENTER, 0)
root.baud = wx.ComboBox(root.panel, -1,
choices = ["2400", "9600", "19200", "38400", "57600", "115200", "250000"],
style = wx.CB_DROPDOWN, size = (100, 25))
root.baud.SetToolTip(wx.ToolTip("Select Baud rate for printer communication"))
try:
root.baud.SetValue("115200")
root.baud.SetValue(str(root.settings.baudrate))
except:
pass
self.Add(root.baud)
root.connectbtn = wx.Button(root.panel,-1, _("Connect"), size = buttonSize)
root.connectbtn.SetToolTip(wx.ToolTip("Connect to the printer"))
root.connectbtn.Bind(wx.EVT_BUTTON, root.connect)
self.Add(root.connectbtn)
root.resetbtn = wx.Button(root.panel,-1, _("Reset"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
root.resetbtn.Bind(wx.EVT_BUTTON, root.reset)
root.resetbtn.SetToolTip(wx.ToolTip("Reset the printer"))
self.Add(root.resetbtn)
root.loadbtn = wx.Button(root.panel,-1, _("Load file"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
root.loadbtn.Bind(wx.EVT_BUTTON, root.loadfile)
root.loadbtn.SetToolTip(wx.ToolTip("Load a 3D model file"))
self.Add(root.loadbtn)
root.platebtn = wx.Button(root.panel,-1, _("Compose"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
root.platebtn.Bind(wx.EVT_BUTTON, root.plate)
root.platebtn.SetToolTip(wx.ToolTip("Simple Plater System"))
self.Add(root.platebtn)
root.sdbtn = wx.Button(root.panel,-1, _("SD"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
root.sdbtn.Bind(wx.EVT_BUTTON, root.sdmenu)
root.sdbtn.SetToolTip(wx.ToolTip("SD Card Printing"))
root.printerControls.append(root.sdbtn)
self.Add(root.sdbtn)
root.printbtn = wx.Button(root.panel,-1, _("Print"), size = buttonSize)
root.printbtn.Bind(wx.EVT_BUTTON, root.printfile)
root.printbtn.SetToolTip(wx.ToolTip("Start Printing Loaded File"))
root.printbtn.Disable()
self.Add(root.printbtn)
root.pausebtn = wx.Button(root.panel,-1, _("Pause"), size = buttonSize)
root.pausebtn.SetToolTip(wx.ToolTip("Pause Current Print"))
root.pausebtn.Bind(wx.EVT_BUTTON, root.pause)
self.Add(root.pausebtn)
root.recoverbtn = wx.Button(root.panel,-1, _("Recover"), size = buttonSize)
root.recoverbtn.SetToolTip(wx.ToolTip("Recover previous Print"))
root.recoverbtn.Bind(wx.EVT_BUTTON, root.recover)
self.Add(root.recoverbtn)
class MainWindow(wx.Frame):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
# this list will contain all controls that should be only enabled
# when we're connected to a printer
self.printerControls = []
def createGui(self):
self.mainsizer = wx.BoxSizer(wx.VERTICAL)
self.uppersizer = MainToolbar(self)
self.lowersizer = wx.BoxSizer(wx.HORIZONTAL)
self.lowersizer.Add(LeftPane(self))
self.lowersizer.Add(VizPane(self), 1, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL)
self.lowersizer.Add(LogPane(self), 0, wx.EXPAND)
self.mainsizer.Add(self.uppersizer)
self.mainsizer.Add(self.lowersizer, 1, wx.EXPAND)
self.panel.SetSizer(self.mainsizer)
self.status = self.CreateStatusBar()
self.status.SetStatusText(_("Not connected to printer."))
self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.Bind(wx.EVT_CLOSE, self.kill)
self.mainsizer.Layout()
self.mainsizer.Fit(self)
# disable all printer controls until we connect to a printer
self.pausebtn.Disable()
self.recoverbtn.Disable()
for i in self.printerControls:
i.Disable()
#self.panel.Fit()
self.cbuttons_reload()
......@@ -33,8 +33,6 @@ StringIO = cStringIO
winsize = (800, 500)
layerindex = 0
global buttonSize
buttonSize = (70, 25) # Define sizes for the buttons on top rows
if os.name == "nt":
winsize = (800, 530)
try:
......@@ -48,6 +46,7 @@ from printrun.xybuttons import XYButtons
from printrun.zbuttons import ZButtons
from printrun.graph import Graph
from printrun.printrun_utils import pixmapfile, configfile
from printrun.gui import MainWindow
import pronsole
def dosify(name):
......@@ -79,7 +78,7 @@ class Tee(object):
self.stdout.flush()
class PronterWindow(wx.Frame, pronsole.pronsole):
class PronterWindow(MainWindow, pronsole.pronsole):
def __init__(self, filename = None, size = winsize):
pronsole.pronsole.__init__(self)
self.settings.build_dimensions = '200x200x100+0+0+0' #default build dimensions are 200x200x100 with 0, 0, 0 in the corner of the bed
......@@ -100,7 +99,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.helpdict["bgcolor"] = _("Pronterface background color (default: #FFFFFF)")
self.filename = filename
os.putenv("UBUNTU_MENUPROXY", "0")
wx.Frame.__init__(self, None, title = _("Printer Interface"), size = size);
MainWindow.__init__(self, None, title = _("Printer Interface"), size = size);
self.SetIcon(wx.Icon(pixmapfile("P-face.ico"), wx.BITMAP_TYPE_ICO))
self.panel = wx.Panel(self,-1, size = size)
......@@ -151,7 +150,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
except:
pass
self.popmenu()
self.popwindow()
self.createGui()
self.t = Tee(self.catchprint)
self.stdout = sys.stdout
self.skeining = 0
......@@ -546,308 +545,6 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
except:
pass
def popwindow(self):
# this list will contain all controls that should be only enabled
# when we're connected to a printer
self.printerControls = []
#sizer layout: topsizer is a column sizer containing two sections
#upper section contains the mini view buttons
#lower section contains the rest of the window - manual controls, console, visualizations
#TOP ROW:
uts = self.uppertopsizer = wx.BoxSizer(wx.HORIZONTAL)
self.rescanbtn = wx.Button(self.panel,-1, _("Port"), size = buttonSize)
self.rescanbtn.SetToolTip(wx.ToolTip("Communication Settings\nClick to rescan ports"))
self.rescanbtn.Bind(wx.EVT_BUTTON, self.rescanports)
uts.Add(self.rescanbtn, 0, wx.TOP|wx.LEFT, 0)
self.serialport = wx.ComboBox(self.panel, -1,
choices = self.scanserial(),
style = wx.CB_DROPDOWN, size = (100, 25))
self.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to"))
self.rescanports()
uts.Add(self.serialport)
uts.Add(wx.StaticText(self.panel,-1, "@"), 0, wx.RIGHT|wx.ALIGN_CENTER, 0)
self.baud = wx.ComboBox(self.panel, -1,
choices = ["2400", "9600", "19200", "38400", "57600", "115200", "250000"],
style = wx.CB_DROPDOWN, size = (100, 25))
self.baud.SetToolTip(wx.ToolTip("Select Baud rate for printer communication"))
try:
self.baud.SetValue("115200")
self.baud.SetValue(str(self.settings.baudrate))
except:
pass
uts.Add(self.baud)
self.connectbtn = wx.Button(self.panel,-1, _("Connect"), size = buttonSize)
self.connectbtn.SetToolTip(wx.ToolTip("Connect to the printer"))
self.connectbtn.Bind(wx.EVT_BUTTON, self.connect)
uts.Add(self.connectbtn)
self.resetbtn = wx.Button(self.panel,-1, _("Reset"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
self.resetbtn.Bind(wx.EVT_BUTTON, self.reset)
self.resetbtn.SetToolTip(wx.ToolTip("Reset the printer"))
uts.Add(self.resetbtn)
#uts.Add((25,-1))
#uts.Add((15,-1), flag = wx.EXPAND)
#self.minibtn = wx.Button(self.panel,-1, _("Mini mode"), style = wx.BU_EXACTFIT)
#self.minibtn.Bind(wx.EVT_BUTTON, self.toggleview)
#uts.Add(self.minibtn, 0, wx.ALIGN_CENTER)
#SECOND ROW
ubs = self.upperbottomsizer = uts#wx.BoxSizer(wx.HORIZONTAL)
self.loadbtn = wx.Button(self.panel,-1, _("Load file"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
self.loadbtn.Bind(wx.EVT_BUTTON, self.loadfile)
self.loadbtn.SetToolTip(wx.ToolTip("Load a 3D model file"))
ubs.Add(self.loadbtn)
self.platebtn = wx.Button(self.panel,-1, _("Compose"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
self.platebtn.Bind(wx.EVT_BUTTON, self.plate)
self.platebtn.SetToolTip(wx.ToolTip("Simple Plater System"))
#self.printerControls.append(self.uploadbtn)
ubs.Add(self.platebtn)
self.sdbtn = wx.Button(self.panel,-1, _("SD"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
self.sdbtn.Bind(wx.EVT_BUTTON, self.sdmenu)
self.sdbtn.SetToolTip(wx.ToolTip("SD Card Printing"))
self.printerControls.append(self.sdbtn)
ubs.Add(self.sdbtn)
self.printbtn = wx.Button(self.panel,-1, _("Print"), size = buttonSize)
self.printbtn.Bind(wx.EVT_BUTTON, self.printfile)
self.printbtn.SetToolTip(wx.ToolTip("Start Printing Loaded File"))
self.printbtn.Disable()
ubs.Add(self.printbtn)
self.pausebtn = wx.Button(self.panel,-1, _("Pause"), size = buttonSize)
self.pausebtn.SetToolTip(wx.ToolTip("Pause Current Print"))
self.pausebtn.Bind(wx.EVT_BUTTON, self.pause)
ubs.Add(self.pausebtn)
self.recoverbtn = wx.Button(self.panel,-1, _("Recover"), size = buttonSize)
self.recoverbtn.SetToolTip(wx.ToolTip("Recover previous Print"))
self.recoverbtn.Bind(wx.EVT_BUTTON, self.recover)
ubs.Add(self.recoverbtn)
#Right full view
lrs = self.lowerrsizer = wx.BoxSizer(wx.VERTICAL)
self.logbox = wx.TextCtrl(self.panel, style = wx.TE_MULTILINE, size = (350,-1))
self.logbox.SetEditable(0)
lrs.Add(self.logbox, 1, wx.EXPAND)
lbrs = wx.BoxSizer(wx.HORIZONTAL)
self.commandbox = wx.TextCtrl(self.panel, style = wx.TE_PROCESS_ENTER)
self.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)"))
self.commandbox.Bind(wx.EVT_TEXT_ENTER, self.sendline)
self.commandbox.Bind(wx.EVT_CHAR, self.cbkey)
self.commandbox.history = [u""]
self.commandbox.histindex = 1
#self.printerControls.append(self.commandbox)
lbrs.Add(self.commandbox, 1)
self.sendbtn = wx.Button(self.panel,-1, _("Send"), style = wx.BU_EXACTFIT)
self.sendbtn.SetToolTip(wx.ToolTip("Send Command to Printer"))
self.sendbtn.Bind(wx.EVT_BUTTON, self.sendline)
#self.printerControls.append(self.sendbtn)
lbrs.Add(self.sendbtn)
lrs.Add(lbrs, 0, wx.EXPAND)
#left pane
lls = self.lowerlsizer = wx.GridBagSizer()
llts = wx.BoxSizer(wx.HORIZONTAL)
#lls.Add(wx.StaticText(self.panel,-1, _("mm/min")), pos = (0, 4), span = (1, 4))
lls.Add(llts, pos = (0, 0), span = (1, 9))
#lls.Add((200, 375))
szbuttons = wx.GridBagSizer()
self.xyb = XYButtons(self.panel, self.moveXY, self.homeButtonClicked, self.spacebarAction, self.settings.bgcolor)
szbuttons.Add(self.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER)
self.zb = ZButtons(self.panel, self.moveZ, self.settings.bgcolor)
szbuttons.Add(self.zb, pos = (0, 2), flag = wx.ALIGN_CENTER)
#lls.Add(self.zb, pos = (2, 6), span = (1, 1), flag = wx.ALIGN_CENTER)
wx.CallAfter(self.xyb.SetFocus)
lls.Add(szbuttons, pos = (1, 0), span = (1, 8), flag = wx.ALIGN_CENTER)
for i in self.cpbuttons:
btn = wx.Button(self.panel,-1, i[0], style = wx.BU_EXACTFIT)
btn.SetToolTip(wx.ToolTip(i[5]))
btn.SetBackgroundColour(i[3])
btn.SetForegroundColour("black")
btn.properties = i
btn.Bind(wx.EVT_BUTTON, self.procbutton)
self.btndict[i[1]]=btn
self.printerControls.append(btn)
if i[2] == None:
if i[4] == 0:
llts.Add(btn)
else:
lls.Add(btn, pos = i[2], span = i[4])
self.xyfeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.xy_feedrate), min = 0, max = 50000, size = (70,-1))
self.xyfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for X & Y axes (mm/min)"))
llts.Add(wx.StaticText(self.panel,-1, _("XY:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
llts.Add(self.xyfeedc)
llts.Add(wx.StaticText(self.panel,-1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
self.zfeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.z_feedrate), min = 0, max = 50000, size = (70,-1))
self.zfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for Z axis (mm/min)"))
llts.Add(self.zfeedc,)
self.monitorbox = wx.CheckBox(self.panel,-1, _("Watch"))
self.monitorbox.SetToolTip(wx.ToolTip("Monitor Temperatures in Graph"))
lls.Add(self.monitorbox, pos = (2, 6))
self.monitorbox.Bind(wx.EVT_CHECKBOX, self.setmonitor)
lls.Add(wx.StaticText(self.panel,-1, _("Heat:")), pos = (2, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
htemp_choices = [self.temps[i]+" ("+i+")" for i in sorted(self.temps.keys(), key = lambda x:self.temps[x])]
self.settoff = wx.Button(self.panel,-1, _("Off"), size = (36,-1), style = wx.BU_EXACTFIT)
self.settoff.SetToolTip(wx.ToolTip("Switch Hotend Off"))
self.settoff.Bind(wx.EVT_BUTTON, lambda e:self.do_settemp("off"))
self.printerControls.append(self.settoff)
lls.Add(self.settoff, pos = (2, 1), span = (1, 1))
if self.settings.last_temperature not in map(float, self.temps.values()):
htemp_choices = [str(self.settings.last_temperature)] + htemp_choices
self.htemp = wx.ComboBox(self.panel, -1,
choices = htemp_choices, style = wx.CB_DROPDOWN, size = (70,-1))
self.htemp.SetToolTip(wx.ToolTip("Select Temperature for Hotend"))
self.htemp.Bind(wx.EVT_COMBOBOX, self.htemp_change)
lls.Add(self.htemp, pos = (2, 2), span = (1, 2))
self.settbtn = wx.Button(self.panel,-1, _("Set"), size = (38,-1), style = wx.BU_EXACTFIT)
self.settbtn.SetToolTip(wx.ToolTip("Switch Hotend On"))
self.settbtn.Bind(wx.EVT_BUTTON, self.do_settemp)
self.printerControls.append(self.settbtn)
lls.Add(self.settbtn, pos = (2, 4), span = (1, 1))
lls.Add(wx.StaticText(self.panel,-1, _("Bed:")), pos = (3, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
btemp_choices = [self.bedtemps[i]+" ("+i+")" for i in sorted(self.bedtemps.keys(), key = lambda x:self.temps[x])]
self.setboff = wx.Button(self.panel,-1, _("Off"), size = (36,-1), style = wx.BU_EXACTFIT)
self.setboff.SetToolTip(wx.ToolTip("Switch Heated Bed Off"))
self.setboff.Bind(wx.EVT_BUTTON, lambda e:self.do_bedtemp("off"))
self.printerControls.append(self.setboff)
lls.Add(self.setboff, pos = (3, 1), span = (1, 1))
if self.settings.last_bed_temperature not in map(float, self.bedtemps.values()):
btemp_choices = [str(self.settings.last_bed_temperature)] + btemp_choices
self.btemp = wx.ComboBox(self.panel, -1,
choices = btemp_choices, style = wx.CB_DROPDOWN, size = (70,-1))
self.btemp.SetToolTip(wx.ToolTip("Select Temperature for Heated Bed"))
self.btemp.Bind(wx.EVT_COMBOBOX, self.btemp_change)
lls.Add(self.btemp, pos = (3, 2), span = (1, 2))
self.setbbtn = wx.Button(self.panel,-1, _("Set"), size = (38,-1), style = wx.BU_EXACTFIT)
self.setbbtn.SetToolTip(wx.ToolTip("Switch Heated Bed On"))
self.setbbtn.Bind(wx.EVT_BUTTON, self.do_bedtemp)
self.printerControls.append(self.setbbtn)
lls.Add(self.setbbtn, pos = (3, 4), span = (1, 1))
self.btemp.SetValue(str(self.settings.last_bed_temperature))
self.htemp.SetValue(str(self.settings.last_temperature))
## 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.
# if it is not, then a (user) remark is added. This denotes a manual entry
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):
self.btemp.SetValue(i)
for i in htemp_choices:
if i.split()[0] == str(self.settings.last_temperature).split('.')[0] or i.split()[0] == str(self.settings.last_temperature) :
self.htemp.SetValue(i)
if( '(' not in self.btemp.Value):
self.btemp.SetValue(self.btemp.Value + ' (user)')
if( '(' not in self.htemp.Value):
self.htemp.SetValue(self.htemp.Value + ' (user)')
#lls.Add(self.btemp, pos = (4, 1), span = (1, 3))
#lls.Add(self.setbbtn, pos = (4, 4), span = (1, 2))
self.tempdisp = wx.StaticText(self.panel,-1, "")
self.edist = wx.SpinCtrl(self.panel,-1, "5", min = 0, max = 1000, size = (60,-1))
self.edist.SetBackgroundColour((225, 200, 200))
self.edist.SetForegroundColour("black")
lls.Add(self.edist, pos = (4, 2), span = (1, 2))
lls.Add(wx.StaticText(self.panel,-1, _("mm")), pos = (4, 4), span = (1, 1))
self.edist.SetToolTip(wx.ToolTip("Amount to Extrude or Retract (mm)"))
self.efeedc = wx.SpinCtrl(self.panel,-1, str(self.settings.e_feedrate), min = 0, max = 50000, size = (60,-1))
self.efeedc.SetToolTip(wx.ToolTip("Extrude / Retract speed (mm/min)"))
self.efeedc.SetBackgroundColour((225, 200, 200))
self.efeedc.SetForegroundColour("black")
self.efeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds)
lls.Add(self.efeedc, pos = (5, 2), span = (1, 2))
lls.Add(wx.StaticText(self.panel,-1, _("mm/\nmin")), pos = (5, 4), span = (1, 1))
self.xyfeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds)
self.zfeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds)
self.zfeedc.SetBackgroundColour((180, 255, 180))
self.zfeedc.SetForegroundColour("black")
# lls.Add((10, 0), pos = (0, 11), span = (1, 1))
#self.hottgauge = TempGauge(self.panel, size = (200, 24), title = _("Heater:"), maxval = 230)
#lls.Add(self.hottgauge, pos = (7, 0), span = (1, 4))
#self.bedtgauge = TempGauge(self.panel, size = (200, 24), title = _("Bed:"), maxval = 130)
#lls.Add(self.bedtgauge, pos = (8, 0), span = (1, 4))
#def scroll_setpoint(e):
# if e.GetWheelRotation()>0:
# self.do_settemp(str(self.hsetpoint+1))
# elif e.GetWheelRotation()<0:
# self.do_settemp(str(max(0, self.hsetpoint-1)))
#self.tgauge.Bind(wx.EVT_MOUSEWHEEL, scroll_setpoint)
self.graph = Graph(self.panel, wx.ID_ANY)
lls.Add(self.graph, pos = (3, 5), span = (3, 3))
lls.Add(self.tempdisp, pos = (6, 0), span = (1, 9))
self.gviz = gviz.gviz(self.panel, (300, 300),
build_dimensions = self.build_dimensions_list,
grid = (self.settings.preview_grid_step1, self.settings.preview_grid_step2),
extrusion_width = self.settings.preview_extrusion_width)
self.gviz.SetToolTip(wx.ToolTip("Click to examine / edit\n layers of loaded file"))
self.gviz.showall = 1
try:
raise ""
import printrun.stlview
self.gwindow = printrun.stlview.GCFrame(None, wx.ID_ANY, 'Gcode view, shift to move view, mousewheel to set layer', size = (600, 600))
except:
self.gwindow = gviz.window([],
build_dimensions = self.build_dimensions_list,
grid = (self.settings.preview_grid_step1, self.settings.preview_grid_step2),
extrusion_width = self.settings.preview_extrusion_width)
self.gviz.Bind(wx.EVT_LEFT_DOWN, self.showwin)
self.gwindow.Bind(wx.EVT_CLOSE, lambda x:self.gwindow.Hide())
vcs = wx.BoxSizer(wx.VERTICAL)
vcs.Add(self.gviz, 1, flag = wx.SHAPED)
cs = self.centersizer = wx.GridBagSizer()
vcs.Add(cs, 0, flag = wx.EXPAND)
self.uppersizer = wx.BoxSizer(wx.VERTICAL)
self.uppersizer.Add(self.uppertopsizer)
#self.uppersizer.Add(self.upperbottomsizer)
self.lowersizer = wx.BoxSizer(wx.HORIZONTAL)
self.lowersizer.Add(lls)
self.lowersizer.Add(vcs, 1, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL)
self.lowersizer.Add(lrs, 0, wx.EXPAND)
self.topsizer = wx.BoxSizer(wx.VERTICAL)
self.topsizer.Add(self.uppersizer)
self.topsizer.Add(self.lowersizer, 1, wx.EXPAND)
self.panel.SetSizer(self.topsizer)
self.status = self.CreateStatusBar()
self.status.SetStatusText(_("Not connected to printer."))
self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.Bind(wx.EVT_CLOSE, self.kill)
self.topsizer.Layout()
self.topsizer.Fit(self)
# disable all printer controls until we connect to a printer
self.pausebtn.Disable()
self.recoverbtn.Disable()
for i in self.printerControls:
i.Disable()
#self.panel.Fit()
#uts.Layout()
self.cbuttons_reload()
def cbkey(self, e):
if e.GetKeyCode() == wx.WXK_UP:
if self.commandbox.histindex == len(self.commandbox.history):
......@@ -921,7 +618,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
def toggleview(self, e):
if(self.mini):
self.mini = False
self.topsizer.Fit(self)
self.mainsizer.Fit(self)
#self.SetSize(winsize)
wx.CallAfter(self.minibtn.SetLabel, _("Mini mode"))
......@@ -935,7 +632,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
def cbuttons_reload(self):
allcbs = []
ubs = self.upperbottomsizer
ubs = self.uppersizer
cs = self.centersizer
#for item in ubs.GetChildren():
# if hasattr(item.GetWindow(),"custombutton"):
......@@ -986,7 +683,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
# ubs.Add(b)
#else:
cs.Add(b, pos = ((i)/4, (i)%4))
self.topsizer.Layout()
self.mainsizer.Layout()
def help_button(self):
print _('Defines custom button. Usage: button <num> "title" [/c "colour"] command')
......@@ -1142,7 +839,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
#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.mainsizer.Layout()
for b in self.custombuttonbuttons:
#if b.IsFrozen(): b.Thaw()
if b.properties is None:
......@@ -1153,7 +850,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
b.SetSize(obj.GetSize())
if self.upperbottomsizer.GetItem(b) is not None:
self.upperbottomsizer.SetItemMinSize(b, obj.GetSize())
self.topsizer.Layout()
self.mainsizer.Layout()
# b.SetStyle(wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE+wx.SIMPLE_BORDER)
self.dragging = wx.Button(self.panel,-1, obj.GetLabel(), style = wx.BU_EXACTFIT)
self.dragging.SetBackgroundColour(obj.GetBackgroundColour())
......
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