2011-05-12 16:44:54 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# "Weaver" Graphical Client
|
|
|
|
#(C) Jeremy Kajikawa 2011
|
|
|
|
#Licensed under GPLv2 and newer
|
|
|
|
#
|
|
|
|
import os, sys
|
|
|
|
from StringIO import StringIO
|
|
|
|
try:
|
|
|
|
import printcore
|
|
|
|
except:
|
|
|
|
from printrun import printcore
|
|
|
|
|
|
|
|
try:
|
|
|
|
import wx
|
|
|
|
|
|
|
|
class AppWindow(wx.Frame):
|
|
|
|
def __init__(self):
|
2011-05-14 08:07:44 +00:00
|
|
|
wx.Frame.__init__(self, None, title="Weaver")
|
|
|
|
|
2011-05-17 14:11:33 +00:00
|
|
|
# Menus and Items
|
2011-05-12 16:44:54 +00:00
|
|
|
self.menustrip = wx.MenuBar()
|
|
|
|
m = wx.Menu()
|
2011-05-14 08:07:44 +00:00
|
|
|
self.Bind(wx.EVT_MENU, self.OnLoadOpts, m.Append(wx.ID_ANY,"&Load Options"," Load Configuration Settings"))
|
|
|
|
self.Bind(wx.EVT_MENU, self.OnSaveOpts, m.Append(wx.ID_ANY,"&Save Options"," Save Configuration Settings"))
|
2011-05-12 16:44:54 +00:00
|
|
|
m.AppendSeparator()
|
|
|
|
self.Bind(wx.EVT_MENU, self.OnExit, m.Append(wx.ID_EXIT,"Close"," Closes the Window"))
|
|
|
|
self.menustrip.Append(m,"&Print")
|
|
|
|
m = wx.Menu()
|
2011-05-14 08:07:44 +00:00
|
|
|
self.Bind(wx.EVT_MENU, self.OnPass, m.Append(wx.ID_ANY," "," "))
|
2011-05-12 16:44:54 +00:00
|
|
|
self.menustrip.Append(m,"&Object")
|
|
|
|
m = wx.Menu()
|
2011-05-14 08:07:44 +00:00
|
|
|
self.Bind(wx.EVT_MENU, self.OnWiki, m.Append(wx.ID_ANY,"&Wiki"," Http://www.reprap.org/wiki/Weaver"))
|
2011-05-12 16:44:54 +00:00
|
|
|
m.AppendSeparator()
|
|
|
|
self.Bind(wx.EVT_MENU, self.OnAbout, m.Append(wx.ID_ABOUT, "&About"," Information about this program"))
|
|
|
|
self.menustrip.Append(m,"&Help")
|
|
|
|
self.SetMenuBar(self.menustrip)
|
|
|
|
|
2011-05-17 14:11:33 +00:00
|
|
|
# Displayed Layout Follows
|
2011-05-14 08:07:44 +00:00
|
|
|
self.vlayout = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
|
hbox.Add(wx.StaticText(self, -1, "Device :", style=wx.ALIGN_CENTRE), 0, wx.ALL, 1)
|
|
|
|
self.SerialPort = wx.ComboBox(self, -1,
|
|
|
|
choices=["/dev/ttyUSB0", "serial.device/0", "COM1"],
|
|
|
|
style=wx.CB_SIMPLE|wx.CB_DROPDOWN|wx.CB_SORT)
|
|
|
|
hbox.Add(self.SerialPort, 0, wx.ALL, 1)
|
|
|
|
hbox.Add(wx.StaticText(self, -1, "Speed :", style=wx.ALIGN_CENTRE), 0, wx.ALL, 1)
|
|
|
|
self.SerialSpeed = wx.ComboBox(self, -1,
|
|
|
|
choices=["2400", "9600", "19200", "38400", "57600", "115200"],
|
|
|
|
style=wx.CB_SIMPLE|wx.CB_DROPDOWN|wx.CB_READONLY|wx.CB_SORT)
|
|
|
|
hbox.Add(self.SerialSpeed, 0, wx.ALL, 1)
|
|
|
|
self.vlayout.Add(hbox, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 1)
|
|
|
|
self.hlayout = wx.BoxSizer(wx.HORIZONTAL)
|
2011-05-14 12:52:51 +00:00
|
|
|
vbox = wx.BoxSizer(wx.VERTICAL)
|
2011-05-14 08:07:44 +00:00
|
|
|
# GCode Shell
|
|
|
|
self.ShellHistory = []
|
2011-05-14 12:52:51 +00:00
|
|
|
# Tweak This for improved Response Display
|
|
|
|
self.ShellView = wx.TextCtrl(self, size=(200, 80))
|
2011-05-14 08:07:44 +00:00
|
|
|
vbox.Add(self.ShellView, 0, wx.ALL, 0)
|
2011-05-14 12:52:51 +00:00
|
|
|
# Using a ComboBox selection for History
|
2011-05-14 08:07:44 +00:00
|
|
|
self.ShellProc = wx.ComboBox(self, -1,
|
|
|
|
choices = self.ShellHistory,
|
|
|
|
style=wx.CB_SIMPLE|wx.CB_DROPDOWN|wx.CB_SORT)
|
|
|
|
vbox.Add(self.ShellProc, 0, wx.ALL, 1)
|
2011-05-14 12:52:51 +00:00
|
|
|
# Clear or Send Command String
|
2011-05-14 08:07:44 +00:00
|
|
|
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
|
self.ShellClear = wx.Button(self, wx.ID_ANY, 'Clear')
|
|
|
|
hbox.Add(self.ShellClear, 0, wx.ALL, 1)
|
|
|
|
self.ShellSend = wx.Button(self, wx.ID_ANY, 'Send')
|
|
|
|
hbox.Add(self.ShellSend, 0, wx.ALL, 1)
|
|
|
|
vbox.Add(hbox, 1, wx.ALL, 1)
|
|
|
|
self.hlayout.Add(vbox, 1, wx.ALL, 1)
|
2011-05-14 12:52:51 +00:00
|
|
|
#
|
2011-05-14 08:07:44 +00:00
|
|
|
vbox = wx.BoxSizer(wx.VERTICAL)
|
2011-05-14 12:52:51 +00:00
|
|
|
# Workflow
|
|
|
|
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
|
self.LoadSTL = wx.Button(self, wx.ID_ANY, 'Load STL')
|
|
|
|
hbox.Add(self.LoadSTL, 0, wx.ALL, 0)
|
|
|
|
self.LoadGCode = wx.Button(self, wx.ID_ANY, 'Load GCode')
|
|
|
|
hbox.Add(self.LoadGCode, 0, wx.ALL, 0)
|
|
|
|
vbox.Add(hbox, 0, wx.ALL, 1)
|
|
|
|
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
2011-05-15 18:31:49 +00:00
|
|
|
self.PrintCancel = wx.ToggleButton(self, wx.ID_ANY, 'Print')
|
2011-05-14 12:52:51 +00:00
|
|
|
hbox.Add(self.PrintCancel, 0, wx.ALL, 0)
|
2011-05-15 18:31:49 +00:00
|
|
|
self.PauseResume = wx.ToggleButton(self, wx.ID_ANY, 'Pause')
|
2011-05-14 12:52:51 +00:00
|
|
|
hbox.Add(self.PauseResume, 0, wx.ALL, 0)
|
|
|
|
vbox.Add(hbox, 0, wx.ALL, 1)
|
2011-05-18 02:42:03 +00:00
|
|
|
self.SkeinForge = wx.Button(self, wx.ID_ANY, 'Edit in SkeinForge')
|
|
|
|
vbox.Add(self.SkeinForge, 0, wx.ALL, 1)
|
2011-05-14 08:07:44 +00:00
|
|
|
self.hlayout.Add(vbox, 1, wx.ALL, 1)
|
2011-05-14 12:52:51 +00:00
|
|
|
|
|
|
|
#
|
2011-05-14 08:07:44 +00:00
|
|
|
vbox = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
# Wxyz
|
|
|
|
self.hlayout.Add(vbox, 1, wx.ALL, 1)
|
2011-05-14 12:52:51 +00:00
|
|
|
|
2011-05-14 08:07:44 +00:00
|
|
|
self.vlayout.Add(self.hlayout, 1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 1)
|
2011-05-14 12:52:51 +00:00
|
|
|
|
2011-05-17 14:11:33 +00:00
|
|
|
# Need to correct EVT_ codes for button types
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnSerialPort, self.SerialPort)
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnSerialSpeed, self.SerialPort)
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnShellProc, self.ShellProc)
|
2011-05-18 11:45:42 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnShellClear, self.ShellClear)
|
2011-05-17 14:11:33 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnShellSend, self.ShellSend)
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnLoadSTL, self.LoadSTL)
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnLoadGCode, self.LoadGCode)
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnPrintCancel, self.PrintCancel)
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnPauseResume, self.PauseResume)
|
2011-05-18 02:42:03 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnSkeinForge, self.SkeinForge)
|
2011-05-17 14:11:33 +00:00
|
|
|
|
|
|
|
self.CreateStatusBar()
|
2011-05-14 08:07:44 +00:00
|
|
|
self.SetSizer(self.vlayout)
|
|
|
|
self.vlayout.Fit(self)
|
|
|
|
self.Layout()
|
2011-05-14 12:52:51 +00:00
|
|
|
|
2011-05-14 08:07:44 +00:00
|
|
|
self.Centre()
|
2011-05-12 16:44:54 +00:00
|
|
|
self.Show(True)
|
|
|
|
|
|
|
|
def OnAbout(self,event):
|
2011-05-12 18:43:46 +00:00
|
|
|
dlg = wx.MessageDialog( self, "Prusa - Mendel - RAMPS - Sprinter", "About Weaver", wx.OK)
|
2011-05-12 16:44:54 +00:00
|
|
|
dlg.ShowModal()
|
|
|
|
dlg.Destroy()
|
|
|
|
|
2011-05-14 08:07:44 +00:00
|
|
|
def OnLoadOpts(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnSaveOpts(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnWiki(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnPass(self,event):
|
2011-05-12 16:44:54 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
def OnExit(self,event):
|
|
|
|
self.Close(True)
|
|
|
|
|
2011-05-17 14:11:33 +00:00
|
|
|
def OnSerialPort(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnSerialSpeed(self,event):
|
|
|
|
pass
|
|
|
|
|
2011-05-14 08:07:44 +00:00
|
|
|
def OnShellProc(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnShellClear(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnShellSend(self,event):
|
|
|
|
pass
|
|
|
|
|
2011-05-17 14:11:33 +00:00
|
|
|
def OnLoadSTL(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnLoadGCode(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnPrintCancel(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnPauseResume(self,event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def OnSkeinForge(self,event):
|
|
|
|
pass
|
|
|
|
|
2011-05-12 16:44:54 +00:00
|
|
|
except:
|
|
|
|
print("Library Failure -- Please install the wxPython Libraries")
|
|
|
|
quit()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app = wx.App(False)
|
|
|
|
main = AppWindow()
|
|
|
|
app.MainLoop()
|
|
|
|
|