Add custom button support, change progress bar color, make gcode preview bigger

master
kliment 2011-06-25 01:28:36 +02:00
parent 96243e1883
commit 83d593ee11
4 changed files with 66 additions and 12 deletions

6
README
View File

@ -14,18 +14,18 @@ http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.12.0-py2
http://launchpad.net/pyreadline/trunk/1.7/+download/pyreadline-1.7.win32.exe
On Ubuntu/debian, do:
apt-get install python-serial python-wxgtk2.8
sudo apt-get install python-serial python-wxgtk2.8
On Mac OS X, download and install:
http://downloads.sourceforge.net/wxpython/wxPython2.8-osx-unicode-2.8.12.0-universal-py2.6.dmg
Grab the source for pyserial from http://pypi.python.org/packages/source/p/pyserial/pyserial-2.5.tar.gz
Unzip pyserial to a folder. Then, in a terminal, change to the folder you unzipped to, then type in:
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
sudo python setup.py install
Alternatively, you can run python in 32 bit mode by setting the following environment variable before running:
Alternatively, you can run python in 32 bit mode by setting the following environment variable before running the setup.py command:
export VERSIONER_PYTHON_PREFER_32_BIT=yes
sudo python setup.py install
Then repeat the same with http://launchpad.net/pyreadline/trunk/1.7/+download/pyreadline-1.7.zip
USING PRONTERFACE

16
custombtn.txt Normal file
View File

@ -0,0 +1,16 @@
btns=[
###Defining custom buttons for pronterface is easy. Here's how.
###Below these instructions, add a line with the following format for each button
# ["button name","command",color(RGB)], <--That comma is important, do not forget it
###As an example: (Remove the # to try it out):
#["Read temp","M105",(200,100,100)],
###You can use gcodes or any pronsole/pronterface commands
###The first three buttons will end up at the top of the window, visible in mini mode
###The rest of the buttons will be at the bottom of the gcode preview
###ADD BUTTON DEFINITIONS BELOW THIS LINE
###ADD BUTTON DEFINITIONS ABOVE THIS LINE
]

13
gviz.py
View File

@ -9,6 +9,8 @@ class window(wx.Frame):
self.p.addgcode(i)
#print time.time()-s
self.p.Bind(wx.EVT_KEY_DOWN,self.key)
self.Bind(wx.EVT_KEY_DOWN,self.key)
def key(self, event):
x=event.GetKeyCode()
#print x
@ -70,11 +72,12 @@ class gviz(wx.Panel):
dc=wx.PaintDC(self)
dc.SetBackground(wx.Brush((250,250,200)))
dc.Clear()
dc.SetBrush(wx.Brush((0,0,0)))
dc.DrawRectangle(self.size[0]-15,0,15,self.size[1])
dc.SetBrush(wx.Brush((0,255,0)))
if len(self.layers):
dc.DrawRectangle(self.size[0]-14,(1.0-(1.0*self.layerindex)/len(self.layers))*self.size[1],13,self.size[1]-1)
if not self.showall:
dc.SetBrush(wx.Brush((43,144,255)))
dc.DrawRectangle(self.size[0]-15,0,15,self.size[1])
dc.SetBrush(wx.Brush((0,255,0)))
if len(self.layers):
dc.DrawRectangle(self.size[0]-14,(1.0-(1.0*(self.layerindex+1))/len(self.layers))*self.size[1],13,self.size[1]-1)
if self.showall:
l=[]
for i in self.layers:

View File

@ -83,13 +83,20 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
["Extrude",("extrude"),(13,0),(225,200,200),(1,2)],
["Reverse",("reverse"),(14,0),(225,200,200),(1,2)],
]
self.custombuttons=[]
self.btndict={}
self.load_rc(".pronsolerc")
customdict={}
try:
execfile("custombtn.txt",customdict)
self.custombuttons=customdict["btns"]
except:
pass
self.popmenu()
self.popwindow()
self.t=Tee(self.catchprint)
self.stdout=sys.stdout
self.mini=False
self.load_rc(".pronsolerc")
self.p.sendcb=self.sentcb
self.curlayer=0
@ -257,7 +264,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
ubs.Add(self.monitorbox)
ubs.Add(wx.StaticText(self.panel,-1,"Monitor\nprinter",pos=(470,37)))
self.monitorbox.Bind(wx.EVT_CHECKBOX,self.setmonitor)
try:
for i in self.custombuttons[:3]:
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)
@ -329,11 +346,29 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
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,(200,200),(200,200))
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())
lls.Add(self.gviz,pos=(0,10),span=(9,1))
cs=wx.GridBagSizer()
cs.Add(self.gviz,pos=(0,0),span=(1,3))
posindex=0
try:
for i in self.custombuttons[3:]:
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)