Ejemplo n.º 1
0
 def popwindow(self):
     self.gviz=gviz.window([],
         build_dimensions=self.build_dimensions_list,
         grid=(10,50),
         extrusion_width=0.5)
     #self.gviz.showall=1
     self.gwindow=gviz.window([],
         build_dimensions=self.build_dimensions_list,
         grid=(10,50),
         extrusion_width=0.5)
     #self.gviz.Bind(wx.EVT_LEFT_DOWN,self.showwin)
     self.gviz.Bind(wx.EVT_CLOSE,lambda x:self.gwindow.Hide())
     #self.gviz.Bind(wx.EVT_LEFT_DOWN,self.showwin)
     self.loadbtn=wx.Button(self.panel,-1,"Load file")
     self.loadbtn.Bind(wx.EVT_BUTTON,self.loadfile)
     vcs=wx.BoxSizer(wx.VERTICAL)
     vcs.Add(self.loadbtn)
     vcs.Add(self.gviz,1,flag=wx.SHAPED)
     self.panel.SetSizer(vcs)
     self.status=self.CreateStatusBar()
Ejemplo n.º 2
0
    def popwindow(self):
        # 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)
        uts.Add(wx.StaticText(self.panel, -1, "Port:", pos=(0, 5)), wx.TOP | wx.LEFT, 5)
        scan = self.scanserial()
        self.serialport = wx.ComboBox(self.panel, -1, choices=scan, style=wx.CB_DROPDOWN | wx.CB_SORT, pos=(50, 0))
        try:
            self.serialport.SetValue(scan[0])
            if self.settings.port:
                self.serialport.SetValue(self.settings.port)
        except:
            pass
        uts.Add(self.serialport)
        uts.Add(wx.StaticText(self.panel, -1, "@", pos=(250, 5)), wx.RIGHT, 5)
        self.baud = wx.ComboBox(
            self.panel,
            -1,
            choices=["2400", "9600", "19200", "38400", "57600", "115200"],
            style=wx.CB_DROPDOWN | wx.CB_SORT,
            size=(110, 30),
            pos=(275, 0),
        )
        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", pos=(380, 0))
        uts.Add(self.connectbtn)
        self.connectbtn.SetToolTipString("Connect to the printer")
        self.connectbtn.Bind(wx.EVT_BUTTON, self.connect)
        self.disconnectbtn = wx.Button(self.panel, -1, "Disconnect", pos=(470, 0))
        self.disconnectbtn.Bind(wx.EVT_BUTTON, self.disconnect)
        uts.Add(self.disconnectbtn)
        self.resetbtn = wx.Button(self.panel, -1, "Reset", pos=(560, 0))
        self.resetbtn.Bind(wx.EVT_BUTTON, self.reset)
        uts.Add(self.resetbtn)
        self.minibtn = wx.Button(self.panel, -1, "Mini mode", pos=(690, 0))
        self.minibtn.Bind(wx.EVT_BUTTON, self.toggleview)
        uts.Add((10, -1))
        self.monitorbox = wx.CheckBox(self.panel, -1, "", pos=(450, 37))
        uts.Add((15, -1))
        uts.Add(self.monitorbox)
        uts.Add(wx.StaticText(self.panel, -1, "Monitor\nprinter", pos=(470, 37)))
        self.monitorbox.Bind(wx.EVT_CHECKBOX, self.setmonitor)

        uts.Add((15, -1), flag=wx.EXPAND)
        uts.Add(self.minibtn)

        # SECOND ROW
        ubs = self.upperbottomsizer = wx.BoxSizer(wx.HORIZONTAL)

        self.loadbtn = wx.Button(self.panel, -1, "Load file", pos=(0, 40))
        self.loadbtn.Bind(wx.EVT_BUTTON, self.loadfile)
        ubs.Add(self.loadbtn)
        self.uploadbtn = wx.Button(self.panel, -1, "SD Upload", pos=(90, 40))
        self.uploadbtn.Bind(wx.EVT_BUTTON, self.upload)
        ubs.Add(self.uploadbtn)
        self.sdprintbtn = wx.Button(self.panel, -1, "SD Print", pos=(180, 40))
        self.sdprintbtn.Bind(wx.EVT_BUTTON, self.sdprintfile)
        ubs.Add(self.sdprintbtn)
        self.printbtn = wx.Button(self.panel, -1, "Print", pos=(270, 40))
        self.printbtn.Bind(wx.EVT_BUTTON, self.printfile)
        ubs.Add(self.printbtn)
        self.pausebtn = wx.Button(self.panel, -1, "Pause", pos=(360, 40))
        self.pausebtn.Bind(wx.EVT_BUTTON, self.pause)
        ubs.Add(self.pausebtn)
        ubs.Add((50, -1), flag=wx.EXPAND)
        try:
            for i in self.custombuttons[:4]:
                if i is None:
                    continue
                b = wx.Button(self.panel, -1, i[0])
                b.properties = i
                b.SetBackgroundColour(i[2])
                b.Bind(wx.EVT_BUTTON, self.procbutton)
                ubs.Add(b)
        except:
            pass
        # Right full view
        lrs = self.lowerrsizer = wx.BoxSizer(wx.VERTICAL)
        self.logbox = wx.TextCtrl(self.panel, size=(350, 340), pos=(440, 75), style=wx.TE_MULTILINE)
        self.logbox.SetEditable(0)
        lrs.Add(self.logbox)
        lbrs = wx.BoxSizer(wx.HORIZONTAL)
        self.commandbox = wx.TextCtrl(self.panel, size=(250, 30), pos=(440, 420), style=wx.TE_PROCESS_ENTER)
        self.commandbox.Bind(wx.EVT_TEXT_ENTER, self.sendline)
        lbrs.Add(self.commandbox)
        self.sendbtn = wx.Button(self.panel, -1, "Send", pos=(700, 420))
        self.sendbtn.Bind(wx.EVT_BUTTON, self.sendline)
        lbrs.Add(self.sendbtn)
        lrs.Add(lbrs)

        # left pane
        lls = self.lowerlsizer = wx.GridBagSizer()
        lls.Add(wx.StaticText(self.panel, -1, "mm/min", pos=(60, 69)), pos=(0, 4), span=(1, 4))
        self.xyfeedc = wx.SpinCtrl(
            self.panel, -1, str(self.settings.xy_feedrate), min=0, max=50000, size=(60, 25), pos=(25, 83)
        )
        lls.Add(wx.StaticText(self.panel, -1, "XY:", pos=(2, 90 - 2)), pos=(1, 0), span=(1, 2))
        lls.Add(self.xyfeedc, pos=(1, 2), span=(1, 4))
        lls.Add(wx.StaticText(self.panel, -1, "Z:", pos=(90, 90 - 2)), pos=(1, 6), span=(1, 2))
        self.zfeedc = wx.SpinCtrl(
            self.panel, -1, str(self.settings.z_feedrate), min=0, max=50000, size=(60, 25), pos=(105, 83)
        )
        lls.Add(self.zfeedc, pos=(1, 8), span=(1, 4))

        # lls.Add((200,375))

        for i in self.cpbuttons:
            btn = wx.Button(self.panel, -1, i[0])  # ,size=(60,-1))
            btn.SetBackgroundColour(i[3])
            btn.SetForegroundColour("black")
            btn.properties = i
            btn.Bind(wx.EVT_BUTTON, self.procbutton)
            self.btndict[i[1]] = btn
            lls.Add(btn, pos=i[2], span=i[4])

        lls.Add(wx.StaticText(self.panel, -1, "Heater:", pos=(0, 343)), pos=(11, 0), span=(1, 1))
        self.htemp = wx.ComboBox(
            self.panel,
            -1,
            choices=[self.temps[i] + " (" + i + ")" for i in sorted(self.temps.keys())],
            style=wx.CB_DROPDOWN,
            size=(90, 25),
            pos=(45, 337),
        )
        self.htemp.SetValue("0")
        lls.Add(self.htemp, pos=(11, 1), span=(1, 3))
        self.settbtn = wx.Button(self.panel, -1, "Set", size=(30, -1), pos=(135, 335))
        self.settbtn.Bind(wx.EVT_BUTTON, self.do_settemp)
        lls.Add(self.settbtn, pos=(11, 4), span=(1, 2))
        lls.Add(wx.StaticText(self.panel, -1, "Bed:", pos=(0, 343)), pos=(12, 0), span=(1, 1))
        self.btemp = wx.ComboBox(
            self.panel,
            -1,
            choices=[self.bedtemps[i] + " (" + i + ")" for i in sorted(self.temps.keys())],
            style=wx.CB_DROPDOWN,
            size=(90, 25),
            pos=(45, 367),
        )
        self.btemp.SetValue("0")
        lls.Add(self.btemp, pos=(12, 1), span=(1, 3))
        self.setbbtn = wx.Button(self.panel, -1, "Set", size=(30, -1), pos=(135, 365))
        self.setbbtn.Bind(wx.EVT_BUTTON, self.do_bedtemp)
        lls.Add(self.setbbtn, pos=(12, 4), span=(1, 2))
        self.tempdisp = wx.StaticText(self.panel, -1, "")
        lls.Add(self.tempdisp, pos=(12, 6), span=(1, 3))

        self.edist = wx.SpinCtrl(self.panel, -1, "5", min=0, max=1000, size=(60, 25), pos=(70, 398))
        self.edist.SetBackgroundColour((225, 200, 200))
        self.edist.SetForegroundColour("black")
        lls.Add(self.edist, pos=(13, 3), span=(1, 2))
        lls.Add(wx.StaticText(self.panel, -1, "mm", pos=(130, 407)), pos=(13, 5), span=(1, 2))
        self.efeedc = wx.SpinCtrl(
            self.panel, -1, str(self.settings.e_feedrate), min=0, max=50000, size=(60, 25), pos=(70, 397 + 28)
        )
        self.efeedc.SetBackgroundColour((225, 200, 200))
        self.efeedc.SetForegroundColour("black")
        self.efeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds)
        lls.Add(self.efeedc, pos=(14, 3), span=(1, 2))
        lls.Add(wx.StaticText(self.panel, -1, "mm/min", pos=(130, 407 + 27)), pos=(14, 5), span=(1, 2))
        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.gviz = gviz.gviz(self.panel, (300, 300), (200, 200))
        self.gviz.showall = 1
        self.gwindow = gviz.window([])
        self.gviz.Bind(wx.EVT_LEFT_DOWN, self.showwin)
        self.gwindow.Bind(wx.EVT_CLOSE, lambda x: self.gwindow.Hide())
        cs = wx.GridBagSizer()
        cs.Add(self.gviz, pos=(0, 0), span=(1, 3))
        posindex = 0
        try:
            for i in self.custombuttons[4:]:
                if i is None:
                    continue
                b = wx.Button(self.panel, -1, i[0])
                b.properties = i
                b.SetBackgroundColour(i[2])
                b.Bind(wx.EVT_BUTTON, self.procbutton)
                cs.Add(b, pos=(1 + posindex / 3, posindex % 3), span=(1, 1))
                posindex += 1
        except:
            pass
        lls.Add(cs, pos=(0, 10), span=(15, 1))

        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(lrs)
        self.topsizer = wx.BoxSizer(wx.VERTICAL)
        self.topsizer.Add(self.uppersizer)
        self.topsizer.Add(self.lowersizer)
        self.panel.SetSizer(self.topsizer)
        self.status = self.CreateStatusBar()
        self.status.SetStatusText("Not connected to printer.")
        self.Bind(wx.EVT_CLOSE, self.kill)
        self.topsizer.Layout()
        self.topsizer.Fit(self)