Commit 8cc13495 authored by Guillaume Seguin's avatar Guillaume Seguin

Run reindent.py on the whole repository

parent ec596c5a
#!/usr/bin/env 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/>.
......@@ -336,25 +336,25 @@ class stlwin(wx.Frame):
def center(self, event):
i = self.l.GetSelection()
if i != -1:
m = self.models[self.l.GetString(i)]
m.offsets = [100, 100, m.offsets[2]]
self.Refresh()
m = self.models[self.l.GetString(i)]
m.offsets = [100, 100, m.offsets[2]]
self.Refresh()
def snap(self, event):
i = self.l.GetSelection()
if i != -1:
m = self.models[self.l.GetString(i)]
m.offsets[2] = -1.0 * min(m.facetsminz)[0]
#print m.offsets[2]
self.Refresh()
m = self.models[self.l.GetString(i)]
m.offsets[2] = -1.0 * min(m.facetsminz)[0]
#print m.offsets[2]
self.Refresh()
def delete(self, event):
i = self.l.GetSelection()
if i != -1:
del self.models[self.l.GetString(i)]
self.l.Delete(i)
self.l.Select(self.l.GetCount() - 1)
self.Refresh()
del self.models[self.l.GetString(i)]
self.l.Delete(i)
self.l.Select(self.l.GetCount() - 1)
self.Refresh()
def done(self, event, cb):
try:
......
#!/usr/bin/env 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/>.
......@@ -45,7 +45,7 @@ class printcore():
self.clear = 0 #clear to send, enabled after responses
self.online = False #The printer has responded to the initial command and is active
self.printing = False #is a print currently running, true if printing, false if paused
self.mainqueue = []
self.mainqueue = []
self.priqueue = []
self.queueindex = 0
self.lineno = 0
......@@ -69,7 +69,7 @@ class printcore():
self.print_thread = None
if port is not None and baud is not None:
self.connect(port, baud)
def disconnect(self):
"""Disconnects from printer and pauses the print
"""
......@@ -82,7 +82,7 @@ class printcore():
self.printer = None
self.online = False
self.printing = False
def connect(self,port=None,baud=None):
"""Set port and baudrate if given, then connect to printer
"""
......@@ -98,7 +98,7 @@ class printcore():
self.stop_read_thread = False
self.read_thread = Thread(target=self._listen)
self.read_thread.start()
def reset(self):
"""Reset the printer
"""
......@@ -106,7 +106,7 @@ class printcore():
self.printer.setDTR(1)
time.sleep(0.2)
self.printer.setDTR(0)
def _readline(self):
try:
line = self.printer.readline()
......@@ -164,11 +164,11 @@ class printcore():
self.clear = True
if line.startswith('ok') and "T:" in line and self.tempcb:
#callback for temp, status, whatever
try: self.tempcb(line)
except: pass
try: self.tempcb(line)
except: pass
elif line.startswith('Error'):
if self.errorcb:
#callback for errors
#callback for errors
try: self.errorcb(line)
except: pass
if line.lower().startswith("resend") or line.startswith("rs"):
......@@ -181,10 +181,10 @@ class printcore():
self.resendfrom = toresend
self.clear = True
self.clear = True
def _checksum(self, command):
return reduce(lambda x,y:x^y, map(ord, command))
def startprint(self, data, startindex = 0):
"""Start a print, data is an array of gcode commands.
returns True on success, False if already printing.
......@@ -205,7 +205,7 @@ class printcore():
self.print_thread = Thread(target = self._print)
self.print_thread.start()
return True
def pause(self):
"""Pauses the print, saving the current position.
"""
......@@ -213,7 +213,7 @@ class printcore():
self.printing = False
self.print_thread.join()
self.print_thread = None
def resume(self):
"""Resumes a paused print.
"""
......@@ -221,11 +221,11 @@ class printcore():
self.printing = True
self.print_thread = Thread(target = self._print)
self.print_thread.start()
def send(self, command, wait = 0):
"""Adds a command to the checksummed main command queue if printing, or sends the command immediately if not printing
"""
if self.online:
if self.printing:
self.mainqueue.append(command)
......@@ -243,7 +243,7 @@ class printcore():
wait -= 1
else:
print "Not connected to printer."
def send_now(self, command, wait = 0):
"""Sends a command to the printer ahead of the command queue, without a checksum
"""
......@@ -263,7 +263,7 @@ class printcore():
wait -= 1
else:
print "Not connected to printer."
def _print(self):
if self.startcb:
#callback for printing started
......@@ -278,7 +278,7 @@ class printcore():
#callback for printing done
try: self.endcb()
except: pass
def _sendnext(self):
if not self.printer:
return
......@@ -313,7 +313,7 @@ class printcore():
self.queueindex = 0
self.lineno = 0
self._send("M110", -1, True)
def _send(self, command, lineno = 0, calcchecksum = False):
if calcchecksum:
prefix = "N" + str(lineno) + " " + command
......
......@@ -16,13 +16,13 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
self.cancelButton = wx.Button(self, wx.ID_CANCEL, "")
self.Bind(wx.EVT_BUTTON, self.OnExit, self.cancelButton)
self.Bind(wx.EVT_BUTTON, self.OnSave, self.okButton)
"""
The following list determines which settings are shown.
The dictionary key is the plugin name and the value is a list of setting names as found in the corresponding .csv file for that plugin.
NOTE: Skeinforge is tightly integrated with Tkinter and there appears to be a dependency which stops radio-button values from being saved.
Perhaps this can be solved, but at the moment this dialog cannot modify radio button values. One will have to use the main Skeinforge application.
Perhaps this can be solved, but at the moment this dialog cannot modify radio button values. One will have to use the main Skeinforge application.
"""
self.moduleSettingsMap = {
'dimension':['Filament Diameter (mm):','Retraction Distance (millimeters):', 'Retraction Distance (millimeters):','Extruder Retraction Speed (mm/s):'],
......@@ -34,28 +34,28 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
'raft':['First Layer Main Feedrate (mm/s):','First Layer Perimeter Feedrate (mm/s):','First Layer Flow Rate Infill(scaler):','First Layer Flow Rate Perimeter(scaler):',],
'speed':['Main Feed Rate (mm/s):','Main Flow Rate (scaler):','Perimeter Feed Rate (mm/s):','Perimeter Flow Rate (scaler):','Travel Feed Rate (mm/s):']
}
self.scrollbarPanel = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
self.settingsSizer = self.getProfileSettings()
self.scrollbarPanel.SetSizer(self.settingsSizer)
self.__set_properties()
self.__do_layout()
self.__set_properties()
self.__do_layout()
self.Show()
def __set_properties(self):
self.profileName = skeinforge_profile.getProfileName(skeinforge_profile.getCraftTypeName())
self.SetTitle("Skeinforge Quick Edit Profile: " + self.profileName)
# For some reason the dialog size is not consistent between Windows and Linux - this is a hack to get it working
# For some reason the dialog size is not consistent between Windows and Linux - this is a hack to get it working
if (os.name == 'nt'):
self.SetMinSize(wx.DLG_SZE(self, (465, 370)))
else:
self.SetSize(wx.DLG_SZE(self, (465, 325)))
self.SetPosition((0, 0))
self.scrollbarPanel.SetScrollRate(10, 10)
def __do_layout(self):
mainSizer = wx.BoxSizer(wx.VERTICAL)
actionsSizer = wx.BoxSizer(wx.HORIZONTAL)
......@@ -65,34 +65,34 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
mainSizer.Add(actionsSizer, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
self.SetSizer(mainSizer)
self.Layout()
def getProfileSettings(self):
settingsSizer = wx.GridBagSizer(hgap=2, vgap=1)
settingsRow = 0
for craftName in sorted(self.moduleSettingsMap.keys()):
craftStaticBox = wx.StaticBox(self.scrollbarPanel, -1, craftName.capitalize())
craftStaticBoxSizer = wx.StaticBoxSizer(craftStaticBox, wx.VERTICAL)
# For some reason the dialog size is not consistent between Windows and Linux - this is a hack to get it working
if (os.name == 'nt'):
craftStaticBoxSizer.SetMinSize((320, -1))
else:
else:
craftStaticBoxSizer.SetMinSize((450, -1))
pluginModule = archive.getModuleWithPath(os.path.join(skeinforge_craft.getPluginsDirectoryPath(), craftName))
repo = pluginModule.getNewRepository()
for setting in settings.getReadRepository(repo).preferences:
if setting.name in self.moduleSettingsMap[craftName]:
settingSizer = wx.GridBagSizer(hgap=2, vgap=2)
settingSizer.AddGrowableCol(0)
settingRow = 0
settingLabel = wx.StaticText(self.scrollbarPanel, -1, setting.name)
settingLabel.Wrap(400)
settingSizer.Add(settingLabel, pos=(settingRow, 0))
if (isinstance(setting.value, bool)):
checkbox = wx.CheckBox(self.scrollbarPanel)
checkbox.SetName(craftName + '.' + setting.name)
......@@ -103,7 +103,7 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
textCtrl = wx.TextCtrl(self.scrollbarPanel, value=str(setting.value), size=(50, -1))
textCtrl.SetName(craftName + '.' + setting.name)
settingSizer.Add(textCtrl, pos=(settingRow, 1))
craftStaticBoxSizer.Add(settingSizer, 1, wx.EXPAND, 0)
settingRow += 1
col = settingsRow % 2
......@@ -114,7 +114,7 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
def OnExit(self, e):
self.Destroy()
def OnSave(self, e):
for x in self.scrollbarPanel.GetChildren():
if (isinstance(x, (wx.CheckBox, wx.TextCtrl))):
......
......@@ -13,7 +13,7 @@ class MyFrame(wx.Frame):
def __init__(self, parent, mysize):
wx.Frame.__init__(self, parent, wx.ID_ANY, size=mysize)
self.SetBackgroundColour('black')
# milliseconds per frame
self.delay = 60
# number of loops
......@@ -41,7 +41,7 @@ class MyFrame(wx.Frame):
self.image_list = []
for image_file in file_list:
self.image_list.append(wx.Bitmap(image_file))
# bind the panel to the paint event
wx.EVT_PAINT(self, self.onPaint)
......@@ -73,4 +73,4 @@ width = 800
frameoffset = 35
height = 600 + frameoffset
MyFrame(None, (width, height)).Show()
app.MainLoop()
\ No newline at end of file
app.MainLoop()
......@@ -23,9 +23,9 @@ modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
As a special exception, the copyright holders of this library
As a special exception, the copyright holders of this library
hereby recind Section 3 of the GNU Lesser General Public License. This
means that you MAY NOT apply the terms of the ordinary GNU General
means that you MAY NOT apply the terms of the ordinary GNU General
Public License instead of this License to any given copy of the
Library. This has been done to prevent users of the Library from being
denied access or the ability to use future improvements.
......@@ -94,7 +94,7 @@ class BufferedCanvas(wx.Panel):
Causes the canvas to be updated.
"""
self.Refresh()
def getWidthHeight(self):
width,height = self.GetClientSizeTuple()
if width == 0:
......
......@@ -2,150 +2,150 @@
#Interactive RepRap e axis calibration program
#(C) Nathan Zadoks 2011
#Licensed under CC-BY-SA or GPLv2 and higher - Pick your poison.
s=300 #Extrusion speed (mm/min)
n=100 #Default length to extrude
m= 0 #User-entered measured extrusion length
k=300 #Default amount of steps per mm
port='/dev/ttyUSB0' #Default serial port to connect to printer
temp=210 #Default extrusion temperature
s=300 #Extrusion speed (mm/min)
n=100 #Default length to extrude
m= 0 #User-entered measured extrusion length
k=300 #Default amount of steps per mm
port='/dev/ttyUSB0' #Default serial port to connect to printer
temp=210 #Default extrusion temperature
tempmax=250 #Maximum extrusion temperature
tempmax=250 #Maximum extrusion temperature
t=int(n*60)/s #Time to wait for extrusion
try:
from printdummy import printcore
from printdummy import printcore
except ImportError:
from printcore import printcore
from printcore import printcore
import time,getopt,sys,os
def float_input(prompt=''):
import sys
f=None
while f==None:
s=raw_input(prompt)
try:
f=float(s)
except ValueError:
sys.stderr.write("Not a valid floating-point number.\n")
sys.stderr.flush()
return f
import sys
f=None
while f==None:
s=raw_input(prompt)
try:
f=float(s)
except ValueError:
sys.stderr.write("Not a valid floating-point number.\n")
sys.stderr.flush()
return f
def wait(t,m=''):
import time,sys
sys.stdout.write(m+'['+(' '*t)+']\r'+m+'[')
sys.stdout.flush()
for i in range(t):
for s in ['|\b','/\b','-\b','\\\b','|']:
sys.stdout.write(s)
sys.stdout.flush()
time.sleep(1.0/5)
print
import time,sys
sys.stdout.write(m+'['+(' '*t)+']\r'+m+'[')
sys.stdout.flush()
for i in range(t):
for s in ['|\b','/\b','-\b','\\\b','|']:
sys.stdout.write(s)
sys.stdout.flush()
time.sleep(1.0/5)
print
def w(s):
sys.stdout.write(s)
sys.stdout.flush()
sys.stdout.write(s)
sys.stdout.flush()
def heatup(p,temp,s=0):
curtemp=gettemp(p)
p.send_now('M109 S%03d'%temp)
p.temp=0
if not s: w("Heating extruder up..")
f=False
while curtemp<=(temp-1):
p.send_now('M105')
time.sleep(0.5)
if not f:
time.sleep(1.5)
f=True
curtemp=gettemp(p)
if curtemp: w(u"\rHeating extruder up.. %3d \xb0C"%curtemp)
if s: print
else: print "\nReady."
curtemp=gettemp(p)
p.send_now('M109 S%03d'%temp)
p.temp=0
if not s: w("Heating extruder up..")
f=False
while curtemp<=(temp-1):
p.send_now('M105')
time.sleep(0.5)
if not f:
time.sleep(1.5)
f=True
curtemp=gettemp(p)
if curtemp: w(u"\rHeating extruder up.. %3d \xb0C"%curtemp)
if s: print
else: print "\nReady."
def gettemp(p):
try: p.logl
except: setattr(p,'logl',0)
try: p.temp
except: setattr(p,'temp',0)
for n in range(p.logl,len(p.log)):
line=p.log[n]
if 'T:' in line:
try:
setattr(p,'temp',int(line.split('T:')[1].split()[0]))
except: print line
p.logl=len(p.log)
return p.temp
try: p.logl
except: setattr(p,'logl',0)
try: p.temp
except: setattr(p,'temp',0)
for n in range(p.logl,len(p.log)):
line=p.log[n]
if 'T:' in line:
try:
setattr(p,'temp',int(line.split('T:')[1].split()[0]))
except: print line
p.logl=len(p.log)
return p.temp
if not os.path.exists(port):
port=0
port=0
#Parse options
help=u"""
%s [ -l DISTANCE ] [ -s STEPS ] [ -t TEMP ] [ -p PORT ]
-l --length Length of filament to extrude for each calibration step (default: %d mm)
-s --steps Initial amount of steps to use (default: %d steps)
-t --temp Extrusion temperature in degrees Celsius (default: %d \xb0C, max %d \xb0C)
-p --port Serial port the printer is connected to (default: %s)
-h --help This cruft.
-l --length Length of filament to extrude for each calibration step (default: %d mm)
-s --steps Initial amount of steps to use (default: %d steps)
-t --temp Extrusion temperature in degrees Celsius (default: %d \xb0C, max %d \xb0C)
-p --port Serial port the printer is connected to (default: %s)
-h --help This cruft.
"""[1:-1].encode('utf-8')%(sys.argv[0],n,k,temp,tempmax,port if port else 'auto')
try:
opts,args=getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help","length=","steps=","temp=","port="])
opts,args=getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help","length=","steps=","temp=","port="])
except getopt.GetoptError,err:
print str(err)
print help
sys.exit(2)
print str(err)
print help
sys.exit(2)
for o,a in opts:
if o in ('-h','--help'):
print help
sys.exit()
elif o in ('-l','--length'):
n=float(a)
elif o in ('-s','--steps'):
k=int(a)
elif o in ('-t','--temp'):
temp=int(a)
if temp>=tempmax:
print (u'%d \xb0C? Are you insane?'.encode('utf-8')%temp)+(" That's over nine thousand!" if temp>9000 else '')
sys.exit(255)
elif o in ('-p','--port'):
port=a
if o in ('-h','--help'):
print help
sys.exit()
elif o in ('-l','--length'):
n=float(a)
elif o in ('-s','--steps'):
k=int(a)
elif o in ('-t','--temp'):
temp=int(a)
if temp>=tempmax:
print (u'%d \xb0C? Are you insane?'.encode('utf-8')%temp)+(" That's over nine thousand!" if temp>9000 else '')
sys.exit(255)
elif o in ('-p','--port'):
port=a
#Show initial parameters
print "Initial parameters"
print "Steps per mm: %3d steps"%k
print "Length extruded: %3d mm"%n
print
print
print "Serial port: %s"%(port if port else 'auto')
p=None
try:
#Connect to printer
w("Connecting to printer..")
try:
p=printcore(port,115200)
except:
print 'Error.'
raise
while not p.online:
time.sleep(1)
w('.')
print " connected."
heatup(p,temp)
#Calibration loop
while n!=m:
heatup(p,temp,True)
p.send_now("G92 E0") #Reset e axis
p.send_now("G1 E%d F%d"%(n,s)) #Extrude length of filament
wait(t,'Extruding.. ')
m=float_input("How many millimeters of filament were extruded? ")
if m==0: continue
if n!=m:
k=(n/m)*k
p.send_now("M92 E%d"%int(round(k))) #Set new step count
print "Steps per mm: %3d steps"%k #Tell user
print 'Calibration completed.' #Yay!
#Connect to printer
w("Connecting to printer..")
try:
p=printcore(port,115200)
except:
print 'Error.'
raise
while not p.online:
time.sleep(1)
w('.')
print " connected."
heatup(p,temp)
#Calibration loop
while n!=m:
heatup(p,temp,True)
p.send_now("G92 E0") #Reset e axis
p.send_now("G1 E%d F%d"%(n,s)) #Extrude length of filament
wait(t,'Extruding.. ')
m=float_input("How many millimeters of filament were extruded? ")
if m==0: continue
if n!=m:
k=(n/m)*k
p.send_now("M92 E%d"%int(round(k))) #Set new step count
print "Steps per mm: %3d steps"%k #Tell user
print 'Calibration completed.' #Yay!
except KeyboardInterrupt:
pass
pass
finally:
if p: p.disconnect()
if p: p.disconnect()
......@@ -263,5 +263,3 @@ class Graph(BufferedCanvas):
self.drawextruder0temp(dc, gc)
self.drawextruder1targettemp(dc, gc)
self.drawextruder1temp(dc, gc)
This diff is collapsed.
......@@ -8,14 +8,14 @@ def install_locale(domain):
gettext.install(domain, '/usr/share/pronterface/locale', unicode=1)
elif os.path.exists('/usr/local/share/pronterface/locale'):
gettext.install(domain, '/usr/local/share/pronterface/locale', unicode=1)
else:
else:
gettext.install(domain, './locale', unicode=1)
def imagefile(filename):
for prefix in ['/usr/local/share/pronterface/images', '/usr/share/pronterface/images']:
candidate = os.path.join(prefix, filename)
if os.path.exists(candidate):
return candidate
candidate = os.path.join(prefix, filename)
if os.path.exists(candidate):
return candidate
local_candidate = os.path.join(os.path.dirname(__file__), "images", filename)
if os.path.exists(local_candidate):
return local_candidate
......@@ -24,9 +24,9 @@ def imagefile(filename):
def lookup_file(filename, prefixes):
for prefix in prefixes:
candidate = os.path.join(prefix, filename)
if os.path.exists(candidate):
return candidate
candidate = os.path.join(prefix, filename)
if os.path.exists(candidate):
return candidate
return filename
def pixmapfile(filename):
......
# 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/>.
......@@ -21,7 +21,7 @@ import tempfile
import shutil
import svg.document as wxpsvgdocument
import imghdr
class dispframe(wx.Frame):
def __init__(self, parent, title, res=(800, 600), printer=None):
wx.Frame.__init__(self, parent=parent, title=title)
......@@ -58,7 +58,7 @@ class dispframe(wx.Frame):
points = [wx.Point(*map(lambda x:int(round(float(x) * self.scale)), j.strip().split())) for j in i.strip().split("M")[1].split("L")]
dc.DrawPolygon(points, self.size[0] / 2, self.size[1] / 2)
elif self.slicer == 'Slic3r':
gc = wx.GraphicsContext_Create(dc)
gc = wx.GraphicsContext_Create(dc)
gc.Translate(*self.offset)
gc.Scale(self.scale, self.scale)
wxpsvgdocument.SVGDocument(image).render(gc)
......@@ -69,12 +69,12 @@ class dispframe(wx.Frame):
self.pic.SetBitmap(self.bitmap)
self.pic.Show()
self.Refresh()
except:
raise
pass
def showimgdelay(self, image):
self.drawlayer(image)
self.pic.Show()
......@@ -82,10 +82,10 @@ class dispframe(wx.Frame):
self.Refresh()
if self.p != None and self.p.online:
self.p.send_now("G91")
self.p.send_now("G1 Z%f F300" % (self.thickness,))
self.p.send_now("G90")
self.p.send_now("G91")
self.p.send_now("G1 Z%f F300" % (self.thickness,))
self.p.send_now("G90")
def nextimg(self, event):
if self.index < len(self.layers):
i = self.index
......@@ -99,8 +99,8 @@ class dispframe(wx.Frame):
wx.CallAfter(self.pic.Hide)
wx.CallAfter(self.Refresh)
wx.CallAfter(self.ShowFullScreen, 0)
wx.CallAfter(self.timer.Stop)
wx.CallAfter(self.timer.Stop)
def present(self, layers, interval=0.5, pause=0.2, thickness=0.4, scale=20, size=(800, 600), offset=(0, 0)):
wx.CallAfter(self.pic.Hide)
wx.CallAfter(self.Refresh)
......@@ -117,7 +117,7 @@ class dispframe(wx.Frame):
self.timer.Start(1000 * interval + 1000 * pause)
class setframe(wx.Frame):
def __init__(self, parent, printer=None):
wx.Frame.__init__(self, parent, title="Projector setup")
self.f = dispframe(None, "", printer=printer)
......@@ -147,26 +147,26 @@ class setframe(wx.Frame):
wx.StaticText(self.panel, -1, "Y:", pos=(160, 60))
self.Y = wx.TextCtrl(self.panel, -1, "768", pos=(210, 60))
wx.StaticText(self.panel, -1, "OffsetX:", pos=(160, 90))
self.offsetX = wx.TextCtrl(self.panel, -1, "50", pos=(210, 90))
wx.StaticText(self.panel, -1, "OffsetY:", pos=(160, 120))
self.offsetY = wx.TextCtrl(self.panel, -1, "50", pos=(210, 120))
self.bload = wx.Button(self.panel, -1, "Present", pos=(0, 150))
self.bload.Bind(wx.EVT_BUTTON, self.startdisplay)
wx.StaticText(self.panel, -1, "Fullscreen:", pos=(160, 150))
self.fullscreen = wx.CheckBox(self.panel, -1, pos=(220, 150))
self.fullscreen.SetValue(True)
self.Show()
def __del__(self):
if hasattr(self, 'image_dir') and self.image_dir != '':
shutil.rmtree(self.image_dir)
def parsesvg(self, name):
et = xml.etree.ElementTree.ElementTree(file=name)
#xml.etree.ElementTree.dump(et)
......@@ -177,18 +177,18 @@ class setframe(wx.Frame):
if (slicer == 'Slic3r'):
height = et.getroot().get('height')
width = et.getroot().get('width')
for i in et.findall("{http://www.w3.org/2000/svg}g"):
z = float(i.get('{http://slic3r.org/namespaces/slic3r}z'))
zdiff = z - zlast
zlast = z
svgSnippet = xml.etree.ElementTree.Element('{http://www.w3.org/2000/svg}svg')
svgSnippet.set('height', height + 'mm')
svgSnippet.set('width', width + 'mm')
svgSnippet.set('viewBox', '0 0 ' + height + ' ' + width)
svgSnippet.append(i)
ol += [svgSnippet]
else :
for i in et.findall("{http://www.w3.org/2000/svg}g")[0].findall("{http://www.w3.org/2000/svg}g"):
......@@ -198,7 +198,7 @@ class setframe(wx.Frame):
path = i.find('{http://www.w3.org/2000/svg}path')
ol += [(path.get("d").split("z"))[:-1]]
return ol, zdiff, slicer
def parse3DLPzip(self, name):
if not zipfile.is_zipfile(name):
raise Exception(name + " is not a zip file!")
......@@ -212,7 +212,7 @@ class setframe(wx.Frame):
if os.path.isfile(path) and imghdr.what(path) in acceptedImageTypes:
ol.append(wx.Bitmap(path))
return ol, -1, "bitmap"
def loadfile(self, event):
dlg = wx.FileDialog(self, ("Open file to print"), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard(("Slic3r or Skeinforge svg files (;*.svg;*.SVG;);3DLP Zip (;*.3dlp.zip;)"))
......
......@@ -17,7 +17,7 @@ import wx
class macroed(wx.Dialog):
"""Really simple editor to edit macro definitions"""
def __init__(self,macro_name,definition,callback,gcode=False):
self.indent_chars = " "
title=" macro %s"
......@@ -54,7 +54,7 @@ class macroed(wx.Dialog):
topsizer.Fit(self)
self.Show()
self.e.SetFocus()
def find(self,ev):
# Ask user what to look for, find it and point at it ... (Jezmy)
S = self.e.GetStringSelection()
......@@ -63,27 +63,27 @@ class macroed(wx.Dialog):
FindValue = wx.GetTextFromUser('Please enter a search string:', caption="Search", default_value=S, parent=None)
somecode = self.e.GetValue()
numLines = len(somecode)
position = somecode.find(FindValue, self.e.GetInsertionPoint())
position = somecode.find(FindValue, self.e.GetInsertionPoint())
if position == -1 :
# ShowMessage(self,-1, "Not found!")
titletext = wx.TextCtrl(self.panel,-1,"Not Found!")
else:
# self.title.SetValue("Position : "+str(position))
titletext = wx.TextCtrl(self.panel,-1,str(position))
# ananswer = wx.MessageBox(str(numLines)+" Lines detected in file\n"+str(position), "OK")
titletext = wx.TextCtrl(self.panel,-1,"Not Found!")
else:
# self.title.SetValue("Position : "+str(position))
titletext = wx.TextCtrl(self.panel,-1,str(position))
# ananswer = wx.MessageBox(str(numLines)+" Lines detected in file\n"+str(position), "OK")
self.e.SetFocus()
self.e.SetInsertionPoint(position)
self.e.SetInsertionPoint(position)
self.e.SetSelection(position, position + len(FindValue))
self.e.ShowPosition(position)
def ShowMessage(self, ev , message):
dlg = wxMessageDialog(self, message,
"Info!", wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def save(self,ev):
self.Destroy()
if not self.gcode:
......
# 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/>.
......@@ -38,15 +38,15 @@ I=[
def transpose(matrix):
return zip(*matrix)
#return [[v[i] for v in matrix] for i in xrange(len(matrix[0]))]
def multmatrix(vector,matrix):
return map(sum, transpose(map(lambda x:[x[0]*p for p in x[1]], zip(vector, transpose(matrix)))))
def applymatrix(facet,matrix=I):
#return facet
#return [map(lambda x:-1.0*x,multmatrix(facet[0]+[1],matrix)[:3]),map(lambda x:multmatrix(x+[1],matrix)[:3],facet[1])]
return genfacet(map(lambda x:multmatrix(x+[1],matrix)[:3],facet[1]))
f=[[0,0,0],[[-3.022642, 0.642482, -9.510565],[-3.022642, 0.642482, -9.510565],[-3.022642, 0.642482, -9.510565]]]
m=[
[1,0,0,0],
......@@ -73,7 +73,7 @@ def emitstl(filename,facets=[],objname="stltool_export",binary=1):
f.write(buf)
f.close()
return
f=open(filename,"w")
f.write("solid "+objname+"\n")
......@@ -85,8 +85,8 @@ def emitstl(filename,facets=[],objname="stltool_export",binary=1):
f.write(" endfacet"+"\n")
f.write("endsolid "+objname+"\n")
f.close()
class stl:
def __init__(self, filename=None):
......@@ -94,7 +94,7 @@ class stl:
self.facets=[]
self.facetsminz=[]
self.facetsmaxz=[]
self.name=""
self.insolid=0
self.infacet=0
......@@ -133,7 +133,7 @@ class stl:
for i in self.f:
if not self.parseline(i):
return
def translate(self,v=[0,0,0]):
matrix=[
[1,0,0,v[0]],
......@@ -142,7 +142,7 @@ class stl:
[0,0,0,1]
]
return self.transform(matrix)
def rotate(self,v=[0,0,0]):
import math
z=v[2]
......@@ -167,7 +167,7 @@ class stl:
[0,0,0,1]
]
return self.transform(matrix1).transform(matrix2).transform(matrix3)
def scale(self,v=[0,0,0]):
matrix=[
[v[0],0,0,0],
......@@ -176,8 +176,8 @@ class stl:
[0,0,0,1]
]
return self.transform(matrix)
def transform(self,m=I):
s=stl()
s.facets=[applymatrix(i,m) for i in self.facets]
......@@ -190,7 +190,7 @@ class stl:
s.facetsminz+=[(min(map(lambda x:x[2], facet[1])),facet)]
s.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])),facet)]
return s
def export(self,f=sys.stdout):
f.write("solid "+self.name+"\n")
for i in self.facets:
......@@ -202,14 +202,14 @@ class stl:
f.write(" endfacet"+"\n")
f.write("endsolid "+self.name+"\n")
f.flush()
def parseline(self,l):
l=l.strip()
if l.startswith("solid"):
self.insolid=1
self.name=l[6:]
#print self.name
elif l.startswith("endsolid"):
self.insolid=0
return 0
......@@ -244,7 +244,7 @@ if __name__=="__main__":
working.remove(j[1])
else:
break
print i,len(working)
emitstl("../../Downloads/frame-vertex-neo-foot-x4-a.stl",s.facets,"emitted_object")
#stl("../prusamendel/stl/mendelplate.stl")
#!/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/>.
......@@ -304,14 +304,14 @@ class gcview(object):
('v3f/static', vertices),
('n3f/static', normals)))
if lasth is not None:
self.layers[lasth] = pyglet.graphics.Batch()
indices = range(len(layertemp[lasth][0])) # [[3*i,3*i+1,3*i+2] for i in xrange(len(facets))]
self.vlists.append(self.layers[lasth].add_indexed(len(layertemp[lasth][0]) // 3,
GL_TRIANGLES,
None, # group,
indices,
('v3f/static', layertemp[lasth][0]),
('n3f/static', layertemp[lasth][1])))
self.layers[lasth] = pyglet.graphics.Batch()
indices = range(len(layertemp[lasth][0])) # [[3*i,3*i+1,3*i+2] for i in xrange(len(facets))]
self.vlists.append(self.layers[lasth].add_indexed(len(layertemp[lasth][0]) // 3,
GL_TRIANGLES,
None, # group,
indices,
('v3f/static', layertemp[lasth][0]),
('n3f/static', layertemp[lasth][1])))
def genline(self, i, h, w):
S = i[0][:3]
......@@ -356,28 +356,28 @@ class gcview(object):
return spoints, epoints, S, E
def transform(self, line):
line = line.split(";")[0]
cur = self.prev[:]
if len(line) > 0:
if "G1" in line or "G0" in line or "G92" in line:
if("X" in line):
cur[0] = float(line.split("X")[1].split(" ")[0])
if("Y" in line):
cur[1] = float(line.split("Y")[1].split(" ")[0])
if("Z" in line):
cur[2] = float(line.split("Z")[1].split(" ")[0])
if("E" in line):
cur[3] = float(line.split("E")[1].split(" ")[0])
if self.prev == cur:
return None
if self.fline or "G92" in line:
self.prev = cur
self.fline = 0
return None
else:
r = [self.prev, cur]
self.prev = cur
return r
line = line.split(";")[0]
cur = self.prev[:]
if len(line) > 0:
if "G1" in line or "G0" in line or "G92" in line:
if("X" in line):
cur[0] = float(line.split("X")[1].split(" ")[0])
if("Y" in line):
cur[1] = float(line.split("Y")[1].split(" ")[0])
if("Z" in line):
cur[2] = float(line.split("Z")[1].split(" ")[0])
if("E" in line):
cur[3] = float(line.split("E")[1].split(" ")[0])
if self.prev == cur:
return None
if self.fline or "G92" in line:
self.prev = cur
self.fline = 0
return None
else:
r = [self.prev, cur]
self.prev = cur
return r
def delete(self):
for i in self.vlists:
......@@ -570,27 +570,27 @@ class TestGlPanel(GLPanel):
self.initpos = None
elif event.Dragging() and event.RightIsDown() and event.ShiftDown():
if self.initpos is None:
self.initpos = event.GetPositionTuple()
else:
p1 = self.initpos
p2 = event.GetPositionTuple()
sz = self.GetClientSize()
p1 = list(p1)
p2 = list(p2)
p1[1] *= -1
p2[1] *= -1
self.transv = map(lambda x, y, z, c: c - self.dist * (x - y) / z, list(p1) + [0], list(p2) + [0], list(sz) + [1], self.transv)
glLoadIdentity()
glTranslatef(self.transv[0], self.transv[1], 0)
glTranslatef(0, 0, self.transv[2])
if(self.rot):
glMultMatrixd(build_rotmatrix(self.basequat))
glGetDoublev(GL_MODELVIEW_MATRIX, self.mvmat)
self.rot = 1
self.initpos = None
if self.initpos is None:
self.initpos = event.GetPositionTuple()
else:
p1 = self.initpos
p2 = event.GetPositionTuple()
sz = self.GetClientSize()
p1 = list(p1)
p2 = list(p2)
p1[1] *= -1
p2[1] *= -1
self.transv = map(lambda x, y, z, c: c - self.dist * (x - y) / z, list(p1) + [0], list(p2) + [0], list(sz) + [1], self.transv)
glLoadIdentity()
glTranslatef(self.transv[0], self.transv[1], 0)
glTranslatef(0, 0, self.transv[2])
if(self.rot):
glMultMatrixd(build_rotmatrix(self.basequat))
glGetDoublev(GL_MODELVIEW_MATRIX, self.mvmat)
self.rot = 1
self.initpos = None
else:
#mouse is moving without a button press
p = event.GetPositionTuple()
......
......@@ -5,9 +5,9 @@
import wx
def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise=False):
""" Draws an arc of an ellipse within bounding rect (x,y,w,h)
""" Draws an arc of an ellipse within bounding rect (x,y,w,h)
from startArc to endArc (in radians, relative to the horizontal line of the eclipse)"""
if True:
import warnings
warnings.warn("elliptical arcs are not supported")
......@@ -15,7 +15,7 @@ def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise=False):
h = h/2.0
self.AddArc(x+w, y+h, ((w+h)/2), startAngle, endAngle, clockwise)
return
else:
else:
#implement in terms of AddArc by applying a transformation matrix
#Sigh this can't work, still need to patch wx to allow
#either a) AddPath that's not a closed path or
......@@ -25,19 +25,18 @@ def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise=False):
#possibly be simulated by combining the current transform with option a.
mtx = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix()
path = wx.GraphicsRenderer_GetDefaultRenderer().CreatePath()
mtx.Translate(x+(w/2.0), y+(h/2.0))
mtx.Scale(w/2.0, y/2.0)
path.AddArc(0, 0, 1, startAngle, endAngle, clockwise)
path.Transform(mtx)
self.AddPath(path)
self.MoveToPoint(path.GetCurrentPoint())
self.CloseSubpath()
if not hasattr(wx.GraphicsPath, "AddEllipticalArc"):
wx.GraphicsPath.AddEllipticalArc = AddEllipticalArc
del AddEllipticalArc
\ No newline at end of file
......@@ -2,7 +2,7 @@
Parsers for specific attributes
"""
import urlparse
from pyparsing import (Literal,
from pyparsing import (Literal,
Optional, oneOf, Group, StringEnd, Combine, Word, alphas, hexnums,
CaselessLiteral, SkipTo
)
......@@ -21,14 +21,14 @@ def parsePossibleURL(t):
colorDeclaration = none | currentColor | colourValue
urlEnd = (
Literal(")").suppress() +
Optional(Group(colorDeclaration), default=()) +
Literal(")").suppress() +
Optional(Group(colorDeclaration), default=()) +
StringEnd()
)
url = (
CaselessLiteral("URL")
+
+
Literal("(").suppress()+
Group(SkipTo(urlEnd, include=True).setParseAction(parsePossibleURL))
)
......@@ -37,7 +37,7 @@ url = (
#For none and currentColor, the details tuple will be the empty tuple
#for CSS color declarations, it will be (type, (R,G,B))
#for URLs, it will be ("URL", ((url tuple), fallback))
#The url tuple will be as returned by urlparse.urlsplit, and can be
#The url tuple will be as returned by urlparse.urlsplit, and can be
#an empty tuple if the parser has an error
#The fallback will be another (type, details) tuple as a parsed
#colorDeclaration, but may be the empty tuple if it is not present
......
......@@ -3,4 +3,4 @@
from pyparsing import Literal, Combine
from .identifier import identifier
atkeyword = Combine(Literal("@") + identifier)
\ No newline at end of file
atkeyword = Combine(Literal("@") + identifier)
......@@ -5,4 +5,3 @@
from pyparsing import nestedExpr
block = nestedExpr(opener="{", closer="}")
......@@ -21,31 +21,31 @@ comma = Literal(",").suppress()
def clampColourByte(val):
val = int(val)
return min(max(0,val), 255)
def clampColourPerc(val):
val = float(val)
return min(max(0,val), 100)
def parseColorPerc(token):
val = token[0]
val = clampColourPerc(val)
#normalize to bytes
return int(255 * (val / 100.0))
colorByte = Optional(sign) + integerConstant.setParseAction(lambda t: clampColourByte(t[0]))
colorPerc = number.setParseAction(parseColorPerc) + Literal("%").suppress()
rgb = (
Literal("rgb(").setParseAction(lambda t: "RGB") +
Literal("rgb(").setParseAction(lambda t: "RGB") +
(
#integer constants, ie 255,255,255
Group(colorByte + comma + colorByte + comma + colorByte) ^
#percentage values, ie 100%, 50%
Group(colorPerc + comma + colorPerc + comma + colorPerc)
)
+
+
Literal(")").suppress() + StringEnd()
)
......@@ -54,10 +54,10 @@ def parseShortHex(t):
doubleHex = Word(hexnums, exact=2).setParseAction(lambda t: int(t[0], 16))
hexLiteral = (Literal("#").setParseAction(lambda t: "RGB") +
hexLiteral = (Literal("#").setParseAction(lambda t: "RGB") +
(
Group(doubleHex + doubleHex + doubleHex) |
Word(hexnums, exact=3).setParseAction(parseShortHex)
Word(hexnums, exact=3).setParseAction(parseShortHex)
) + StringEnd()
)
......@@ -66,7 +66,7 @@ def parseNamedColour(t):
return ["RGB", NamedColours[t[0].lower()]]
except KeyError:
return ["RGB", (0,0,0)]
namedColour = Word(alphas).setParseAction(parseNamedColour)
......@@ -246,7 +246,7 @@ NamedColours = {
def fillCSS2SystemColours():
#The system colours require a wxApp to be present to retrieve,
#so if you wnat support for them you'll need
#so if you wnat support for them you'll need
#to call this function after your wxApp instance starts
systemColors = {
"ActiveBorder": wx.SYS_COLOUR_ACTIVEBORDER,
......@@ -280,4 +280,4 @@ def fillCSS2SystemColours():
NamedColours.update(
#strip the alpha from the system colors. Is this really what we want to do?
(k.lower(), wx.SystemSettings.GetColour(v)[:3]) for (k,v) in systemColors.iteritems()
)
\ No newline at end of file
)
......@@ -10,7 +10,7 @@ class White(White):
super(White, self).__init__(ws, min, max, exact)
escaped = (
Literal("\\").suppress() +
Literal("\\").suppress() +
#chr(20)-chr(126) + chr(128)-unichr(sys.maxunicode)
Regex(u"[\u0020-\u007e\u0080-\uffff]", re.IGNORECASE)
)
......@@ -18,7 +18,7 @@ escaped = (
def convertToUnicode(t):
return unichr(int(t[0], 16))
hex_unicode = (
Literal("\\").suppress() +
Literal("\\").suppress() +
Regex("[0-9a-f]{1,6}", re.IGNORECASE) +
Optional(White(exact=1)).suppress()
).setParseAction(convertToUnicode)
......@@ -29,9 +29,9 @@ escape = hex_unicode | escaped
#any unicode literal outside the 0-127 ascii range
nonascii = Regex(u"[^\u0000-\u007f]")
#single character for starting an identifier.
#single character for starting an identifier.
nmstart = Regex(u"[A-Z]", re.IGNORECASE) | nonascii | escape
nmchar = Regex(u"[0-9A-Z-]", re.IGNORECASE) | nonascii | escape
identifier = Combine(nmstart + ZeroOrMore(nmchar))
\ No newline at end of file
identifier = Combine(nmstart + ZeroOrMore(nmchar))
......@@ -5,4 +5,4 @@ def inlineStyle(styleString):
return {}
styles = styleString.split(";")
rv = dict(style.split(":") for style in styles if len(style) != 0)
return rv
\ No newline at end of file
return rv
......@@ -48,4 +48,4 @@ transformList = delimitedList(Group(transform), delim=maybeComma)
if __name__ == '__main__':
from tests.test_css import *
unittest.main()
\ No newline at end of file
unittest.main()
......@@ -43,4 +43,4 @@ length = lengthValue + Optional(lengthUnit, default=None) + StringEnd()
length.leaveWhitespace()
#set the parse action aftward so it doesn't "infect" the parsers that build on it
number.setParseAction(asFloat)
\ No newline at end of file
number.setParseAction(asFloat)
This diff is collapsed.
"""
SVG path data parser
Usage:
steps = svg.parseString(pathdata)
for command, arguments in steps:
pass
"""
from pyparsing import (ParserElement, Literal, Word, CaselessLiteral,
from pyparsing import (ParserElement, Literal, Word, CaselessLiteral,
Optional, Combine, Forward, ZeroOrMore, nums, oneOf, Group, ParseException, OneOrMore)
#ParserElement.enablePackrat()
def Command(char):
""" Case insensitive but case preserving"""
return CaselessPreservingLiteral(char)
def Arguments(token):
return Group(token)
class CaselessPreservingLiteral(CaselessLiteral):
""" Like CaselessLiteral, but returns the match as found
instead of as defined.
......@@ -40,8 +40,8 @@ class CaselessPreservingLiteral(CaselessLiteral):
exc = self.myException
exc.loc = loc
exc.pstr = instring
raise exc
raise exc
def Sequence(token):
""" A sequence of the token"""
return OneOrMore(token+maybeComma)
......@@ -58,13 +58,13 @@ def convertToFloat(s, loc, toks):
exponent = CaselessLiteral("e")+Optional(sign)+Word(nums)
#note that almost all these fields are optional,
#note that almost all these fields are optional,
#and this can match almost anything. We rely on Pythons built-in
#float() function to clear out invalid values - loosely matching like this
#speeds up parsing quite a lot
floatingPointConstant = Combine(
Optional(sign) +
Optional(Word(nums)) +
Optional(sign) +
Optional(Word(nums)) +
Optional(Literal(".") + Optional(Word(nums)))+
Optional(exponent)
)
......@@ -75,7 +75,7 @@ number = floatingPointConstant
#same as FP constant but don't allow a - sign
nonnegativeNumber = Combine(
Optional(Word(nums)) +
Optional(Word(nums)) +
Optional(Literal(".") + Optional(Word(nums)))+
Optional(exponent)
)
......@@ -120,7 +120,7 @@ ellipticalArcArgument = Group(
coordinatePair #(x,y)
)
ellipticalArc = Group(Command("A") + Arguments(Sequence(ellipticalArcArgument)))
smoothQuadraticBezierCurveto = Group(Command("T") + Arguments(coordinatePairSequence))
......@@ -155,39 +155,37 @@ def profile():
p.disable()
p.print_stats()
bpath = """M204.33 139.83 C196.33 133.33 206.68 132.82 206.58 132.58 C192.33 97.08 169.35
81.41 167.58 80.58 C162.12 78.02 159.48 78.26 160.45 76.97 C161.41 75.68 167.72 79.72 168.58
80.33 C193.83 98.33 207.58 132.33 207.58 132.33 C207.58 132.33 209.33 133.33 209.58 132.58
C219.58 103.08 239.58 87.58 246.33 81.33 C253.08 75.08 256.63 74.47 247.33 81.58 C218.58 103.58
210.34 132.23 210.83 132.33 C222.33 134.83 211.33 140.33 211.83 139.83 C214.85 136.81 214.83 145.83 214.83
145.83 C214.83 145.83 231.83 110.83 298.33 66.33 C302.43 63.59 445.83 -14.67 395.83 80.83 C393.24 85.79 375.83
bpath = """M204.33 139.83 C196.33 133.33 206.68 132.82 206.58 132.58 C192.33 97.08 169.35
81.41 167.58 80.58 C162.12 78.02 159.48 78.26 160.45 76.97 C161.41 75.68 167.72 79.72 168.58
80.33 C193.83 98.33 207.58 132.33 207.58 132.33 C207.58 132.33 209.33 133.33 209.58 132.58
C219.58 103.08 239.58 87.58 246.33 81.33 C253.08 75.08 256.63 74.47 247.33 81.58 C218.58 103.58
210.34 132.23 210.83 132.33 C222.33 134.83 211.33 140.33 211.83 139.83 C214.85 136.81 214.83 145.83 214.83
145.83 C214.83 145.83 231.83 110.83 298.33 66.33 C302.43 63.59 445.83 -14.67 395.83 80.83 C393.24 85.79 375.83
105.83 375.83 105.83 C375.83 105.83 377.33 114.33 371.33 121.33 C370.3 122.53 367.83 134.33 361.83 140.83 C360.14 142.67
361.81 139.25 361.83 140.83 C362.33 170.83 337.76 170.17 339.33 170.33 C348.83 171.33 350.19 183.66 350.33 183.83 C355.83
190.33 353.83 191.83 355.83 194.83 C366.63 211.02 355.24 210.05 356.83 212.83 C360.83 219.83 355.99 222.72 357.33 224.83
C360.83 230.33 354.75 233.84 354.83 235.33 C355.33 243.83 349.67 240.73 349.83 244.33 C350.33 255.33 346.33 250.83 343.83 254.83
361.81 139.25 361.83 140.83 C362.33 170.83 337.76 170.17 339.33 170.33 C348.83 171.33 350.19 183.66 350.33 183.83 C355.83
190.33 353.83 191.83 355.83 194.83 C366.63 211.02 355.24 210.05 356.83 212.83 C360.83 219.83 355.99 222.72 357.33 224.83
C360.83 230.33 354.75 233.84 354.83 235.33 C355.33 243.83 349.67 240.73 349.83 244.33 C350.33 255.33 346.33 250.83 343.83 254.83
C336.33 266.83 333.46 262.38 332.83 263.83 C329.83 270.83 325.81 269.15 324.33 270.83 C320.83 274.83 317.33 274.83 315.83 276.33
C308.83 283.33 304.86 278.39 303.83 278.83 C287.83 285.83 280.33 280.17 277.83 280.33 C270.33 280.83 271.48 279.67 269.33 277.83
C237.83 250.83 219.33 211.83 215.83 206.83 C214.4 204.79 211.35 193.12 212.33 195.83 C214.33 201.33 213.33 250.33 207.83 250.33
C202.33 250.33 201.83 204.33 205.33 195.83 C206.43 193.16 204.4 203.72 201.79 206.83 C196.33 213.33 179.5 250.83 147.59 277.83
C145.42 279.67 146.58 280.83 138.98 280.33 C136.46 280.17 128.85 285.83 112.65 278.83 C111.61 278.39 107.58 283.33 100.49 276.33
C98.97 274.83 95.43 274.83 91.88 270.83 C90.39 269.15 86.31 270.83 83.27 263.83 C82.64 262.38 79.73 266.83 72.13 254.83 C69.6 250.83
65.54 255.33 66.05 244.33 C66.22 240.73 60.48 243.83 60.99 235.33 C61.08 233.84 54.91 230.33 58.45 224.83 C59.81 222.72 54.91 219.83
58.96 212.83 C60.57 210.05 49.04 211.02 59.97 194.83 C62 191.83 59.97 190.33 65.54 183.83 C65.69 183.66 67.06 171.33 76.69 170.33
C78.28 170.17 53.39 170.83 53.9 140.83 C53.92 139.25 55.61 142.67 53.9 140.83 C47.82 134.33 45.32 122.53 44.27 121.33 C38.19 114.33
39.71 105.83 39.71 105.83 C39.71 105.83 22.08 85.79 19.46 80.83 C-31.19 -14.67 114.07 63.59 118.22 66.33 C185.58 110.83 202 145.83
C308.83 283.33 304.86 278.39 303.83 278.83 C287.83 285.83 280.33 280.17 277.83 280.33 C270.33 280.83 271.48 279.67 269.33 277.83
C237.83 250.83 219.33 211.83 215.83 206.83 C214.4 204.79 211.35 193.12 212.33 195.83 C214.33 201.33 213.33 250.33 207.83 250.33
C202.33 250.33 201.83 204.33 205.33 195.83 C206.43 193.16 204.4 203.72 201.79 206.83 C196.33 213.33 179.5 250.83 147.59 277.83
C145.42 279.67 146.58 280.83 138.98 280.33 C136.46 280.17 128.85 285.83 112.65 278.83 C111.61 278.39 107.58 283.33 100.49 276.33
C98.97 274.83 95.43 274.83 91.88 270.83 C90.39 269.15 86.31 270.83 83.27 263.83 C82.64 262.38 79.73 266.83 72.13 254.83 C69.6 250.83
65.54 255.33 66.05 244.33 C66.22 240.73 60.48 243.83 60.99 235.33 C61.08 233.84 54.91 230.33 58.45 224.83 C59.81 222.72 54.91 219.83
58.96 212.83 C60.57 210.05 49.04 211.02 59.97 194.83 C62 191.83 59.97 190.33 65.54 183.83 C65.69 183.66 67.06 171.33 76.69 170.33
C78.28 170.17 53.39 170.83 53.9 140.83 C53.92 139.25 55.61 142.67 53.9 140.83 C47.82 134.33 45.32 122.53 44.27 121.33 C38.19 114.33
39.71 105.83 39.71 105.83 C39.71 105.83 22.08 85.79 19.46 80.83 C-31.19 -14.67 114.07 63.59 118.22 66.33 C185.58 110.83 202 145.83
202 145.83 C202 145.83 202.36 143.28 203 141.83 C203.64 140.39 204.56 140.02 204.33 139.83 z"""
def ptest():
svg.parseString(bpath)
if __name__ == '__main__':
#~ from tests.test_pathdata import *
#~ unittest.main()
profile()
......@@ -12,7 +12,7 @@ def PrintHeader():
def PrintMenu():
return '<div id="mainmenu"><ul><li><a href="/">home</a></li><li><a href="/settings">settings</a></li><li><a href="/console">console</a></li><li><a href="/status">status (XML)</a></li></ul></div>'
def PrintFooter():
return "</body></html>"
......@@ -24,7 +24,7 @@ def TReloadPage(action):
def clear_text(mypass):
return mypass
gPronterPtr = 0
gWeblog = ""
gLogRefresh =5
......@@ -80,7 +80,7 @@ class ConnectButton(object):
'tools.basic_auth.realm': 'My Print Server',
'tools.basic_auth.users': users,
'tools.basic_auth.encrypt': clear_text}
class DisconnectButton(object):
def index(self):
#handle connect push, then reload page
......@@ -149,7 +149,7 @@ class MoveButton(object):
'tools.basic_auth.realm': 'My Print Server',
'tools.basic_auth.users': users,
'tools.basic_auth.encrypt': clear_text}
class CustomButton(object):
def button(self, *args):
if not args:
......@@ -164,7 +164,7 @@ class CustomButton(object):
'tools.basic_auth.realm': 'My Print Server',
'tools.basic_auth.users': users,
'tools.basic_auth.encrypt': clear_text}
class HomeButton(object):
def axis(self, *args):
if not args:
......@@ -183,13 +183,13 @@ class HomeButton(object):
if(taxis == "all"):
gPronterPtr.onecmd('home')
return ReloadPage("Home All")
axis.exposed = True
axis._cp_config = {'tools.basic_auth.on': True,
'tools.basic_auth.realm': 'My Print Server',
'tools.basic_auth.users': users,
'tools.basic_auth.encrypt': clear_text}
class XMLstatus(object):
def index(self):
#handle connect push, then reload page
......@@ -203,7 +203,7 @@ class XMLstatus(object):
state="Printing"
if gPronterPtr.paused:
state="Paused"
txt=txt+'<state>'+state+'</state>\n'
txt=txt+'<file>'+str(gPronterPtr.filename)+'</file>\n'
txt=txt+'<status>'+str(gPronterPtr.status.GetStatusText())+'</status>\n'
......@@ -234,13 +234,13 @@ class XMLstatus(object):
index.exposed = True
class WebInterface(object):
def __init__(self, pface):
if (sys.version_info[1] > 6):
# 'allow_no_value' wasn't added until 2.7
config = ConfigParser.SafeConfigParser(allow_no_value=True)
# 'allow_no_value' wasn't added until 2.7
config = ConfigParser.SafeConfigParser(allow_no_value=True)
else:
config = ConfigParser.SafeConfigParser()
config = ConfigParser.SafeConfigParser()
config.read(configfile(pface.web_auth_config or 'auth.config'))
users[config.get("user", "user")] = config.get("user", "pass")
self.pface = pface
......@@ -248,12 +248,12 @@ class WebInterface(object):
global gWeblog
self.name="<div id='title'>Pronterface Web-Interface</div>"
gWeblog = ""
gPronterPtr = self.pface
gPronterPtr = self.pface
settings = SettingsPage()
logpage = LogPage()
console = ConsolePage()
#actions
connect = ConnectButton()
disconnect = DisconnectButton()
......@@ -264,7 +264,7 @@ class WebInterface(object):
home = HomeButton()
move = MoveButton()
custom =CustomButton()
def index(self):
pageText=PrintHeader()+self.name+PrintMenu()
pageText+="<div id='content'>\n"
......@@ -274,20 +274,20 @@ class WebInterface(object):
pageText+="<li><a href='/reset'>Reset</a></li>\n"
pageText+="<li><a href='/printbutton'>Print</a></li>\n"
pageText+="<li><a href='/pausebutton'>Pause</a></li>\n"
for i in gPronterPtr.cpbuttons:
pageText+="<li><a href='/custom/button/"+i[1]+"'>"+i[0]+"</a></li>\n"
#for i in gPronterPtr.custombuttons:
# print(str(i));
pageText+="</ul>\n"
pageText+="</div>\n"
pageText+="<div id='gui'>\n"
pageText+="<div id='control_xy'>"
pageText+="<img src='/images/control_xy.png' usemap='#xymap'/>"
pageText+='<map name="xymap">'
pageText+='<area shape="rect" coords="8,5,51,48" href="/home/axis/x" alt="X Home" title="X Home" />'
pageText+='<area shape="rect" coords="195,6,236,46" href="/home/axis/y" alt="Y Home" title="Y Home" />'
pageText+='<area shape="rect" coords="7,192,48,232" href="/home/axis/all" alt="All Home" title="All Home" />'
......@@ -336,7 +336,7 @@ class WebInterface(object):
# pageText+="<ul><li><b>Bed Temp:</b></li><li><a href='/off'>OFF</a></li><li><a href='/185'>185 (PLA)</a></li><li><a href='/240'>240 (ABS)</a></li></ul>"
# pageText+="</div>"
# pageText+="</div>"
pageText=pageText+"<div id='file'>File Loaded: <i>"+str(gPronterPtr.filename)+"</i></div>"
pageText+="<div id='logframe'><iframe src='/logpage' width='100%' height='100%'>iFraming Not Supported?? No log for you.</iframe></div>"
pageText+=PrintFooter()
......@@ -357,7 +357,7 @@ class WebInterfaceStub(object):
def KillWebInterfaceThread():
cherrypy.engine.exit()
def StartWebInterfaceThread(webInterface):
current_dir = os.path.dirname(os.path.abspath(__file__))
cherrypy.config.update({'engine.autoreload_on':False})
......
# 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, os, math
from bufferedcanvas import *
from printrun_utils import *
from printrun_utils import *
def sign(n):
if n < 0: return -1
......@@ -56,10 +56,10 @@ class XYButtons(BufferedCanvas):
self.lastMove = None
self.lastCorner = None
self.bgcolor = wx.Colour()
self.bgcolor.SetFromName(bgcolor)
self.bgcolormask = wx.Colour(self.bgcolor.Red(), self.bgcolor.Green(), self.bgcolor.Blue(), 128)
self.bgcolor = wx.Colour()
self.bgcolor.SetFromName(bgcolor)
self.bgcolormask = wx.Colour(self.bgcolor.Red(), self.bgcolor.Green(), self.bgcolor.Blue(), 128)
BufferedCanvas.__init__(self, parent, ID)
self.SetSize(self.bg_bmp.GetSize())
......@@ -70,11 +70,11 @@ class XYButtons(BufferedCanvas):
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
self.Bind(wx.EVT_KEY_UP, self.OnKey)
wx.GetTopLevelParent(self).Bind(wx.EVT_CHAR_HOOK, self.OnTopLevelKey)
def disable(self):
self.enabled = False
self.update()
def enable(self):
self.enabled = True
self.update()
......@@ -84,7 +84,7 @@ class XYButtons(BufferedCanvas):
self.moveCallback(*self.lastMove)
if self.lastCorner:
self.cornerCallback(self.lastCorner)
def clearRepeat(self):
self.lastMove = None
self.lastCorner = None
......@@ -95,7 +95,7 @@ class XYButtons(BufferedCanvas):
pxlen = x1 - pos.x
pylen = y1 - pos.y
return abs(xlen*pylen-ylen*pxlen)/math.sqrt(xlen**2+ylen**2)
def distanceToPoint(self, x1, y1, x2, y2):
return math.sqrt((x1-x2)**2 + (y1-y2)**2)
......@@ -103,17 +103,17 @@ class XYButtons(BufferedCanvas):
idx = self.keypad_idx + 1
if idx > 2: idx = 0
return idx
def setKeypadIndex(self, idx):
self.keypad_idx = idx
self.update()
def getMovement(self):
xdir = [1, 0, -1, 0][self.quadrant]
ydir = [0, 1, 0, -1][self.quadrant]
magnitude = math.pow(10, self.concentric-1)
return (magnitude * xdir, magnitude * ydir)
def lookupConcentric(self, radius):
idx = 0
for r in XYButtons.concentric_circle_radii[1:]:
......@@ -134,27 +134,27 @@ class XYButtons(BufferedCanvas):
quadrant = 1 # Up
else:
quadrant = 2 # Left
idx = self.lookupConcentric(radius)
return (quadrant, idx)
def mouseOverKeypad(self, mpos):
for idx, kpos in XYButtons.keypad_positions.items():
radius = self.distanceToPoint(mpos[0], mpos[1], kpos[0], kpos[1])
if radius < 9:
return idx
return None
def drawPartialPie(self, gc, center, r1, r2, angle1, angle2):
p1 = wx.Point(center.x + r1*math.cos(angle1), center.y + r1*math.sin(angle1))
path = gc.CreatePath()
path.MoveToPoint(p1.x, p1.y)
path.AddArc(center.x, center.y, r1, angle1, angle2, True)
path.AddArc(center.x, center.y, r2, angle2, angle1, False)
path.AddLineToPoint(p1.x, p1.y)
gc.DrawPath(path)
def highlightQuadrant(self, gc, quadrant, concentric):
assert(quadrant >= 0 and quadrant <= 3)
assert(concentric >= 0 and concentric <= 3)
......@@ -175,12 +175,12 @@ class XYButtons(BufferedCanvas):
elif quadrant == 3:
a1, a2 = (math.pi*0.25, math.pi*0.75)
center.y += inner_ring_radius
r1 = XYButtons.concentric_circle_radii[concentric]
r2 = XYButtons.concentric_circle_radii[concentric+1]
self.drawPartialPie(gc, center, r1-inner_ring_radius, r2-inner_ring_radius, a1+fudge, a2-fudge)
def drawCorner(self, gc, x, y, angle=0.0):
w, h = XYButtons.corner_size
......@@ -201,7 +201,7 @@ class XYButtons(BufferedCanvas):
w, h = XYButtons.corner_size
cx, cy = XYButtons.center
ww, wh = self.GetSizeTuple()
inset = 10
if corner == 0:
x, y = (cx - ww/2 + inset, cy - wh/2 + inset)
......@@ -215,10 +215,10 @@ class XYButtons(BufferedCanvas):
elif corner == 3:
x, y = (cx - ww/2 + inset, cy + wh/2 - inset)
self.drawCorner(gc, x+w/2, y-h/2, math.pi*3/2)
def draw(self, dc, w, h):
dc.SetBackground(wx.Brush(self.bgcolor))
dc.SetBackground(wx.Brush(self.bgcolor))
dc.Clear()
gc = wx.GraphicsContext.Create(dc)
......@@ -226,7 +226,7 @@ class XYButtons(BufferedCanvas):
if self.bg_bmp:
w, h = (self.bg_bmp.GetWidth(), self.bg_bmp.GetHeight())
gc.DrawBitmap(self.bg_bmp, 0, 0, w, h)
if self.enabled:
# Brush and pen for grey overlay when mouse hovers over
gc.SetPen(wx.Pen(wx.Colour(100,100,100,172), 4))
......@@ -238,13 +238,13 @@ class XYButtons(BufferedCanvas):
self.highlightQuadrant(gc, self.quadrant, self.concentric)
elif self.corner != None:
self.highlightCorner(gc, self.corner)
if self.keypad_idx >= 0:
padw, padh = (self.keypad_bmp.GetWidth(), self.keypad_bmp.GetHeight())
pos = XYButtons.keypad_positions[self.keypad_idx]
pos = (pos[0] - padw/2 - 3, pos[1] - padh/2 - 3)
gc.DrawBitmap(self.keypad_bmp, pos[0], pos[1], padw, padh)
# Draw label overlays
gc.SetPen(wx.Pen(wx.Colour(255,255,255,128), 1))
gc.SetBrush(wx.Brush(wx.Colour(255,255,255,128+64)))
......@@ -256,7 +256,7 @@ class XYButtons(BufferedCanvas):
gc.SetPen(wx.Pen(self.bgcolor, 0))
gc.SetBrush(wx.Brush(self.bgcolormask))
gc.DrawRectangle(0, 0, w, h)
# Used to check exact position of keypad dots, should we ever resize the bg image
# for idx, kpos in XYButtons.label_overlay_positions.items():
......@@ -289,7 +289,7 @@ class XYButtons(BufferedCanvas):
else:
evt.Skip()
return
if self.moveCallback:
self.concentric = self.keypad_idx
x, y = self.getMovement()
......@@ -301,7 +301,7 @@ class XYButtons(BufferedCanvas):
def OnMotion(self, event):
if not self.enabled:
return
oldcorner = self.corner
oldq, oldc = self.quadrant, self.concentric
......@@ -318,7 +318,7 @@ class XYButtons(BufferedCanvas):
# If mouse hovers in space between quadrants, don't commit to a quadrant
if riseDist <= XYButtons.spacer or fallDist <= XYButtons.spacer:
self.quadrant = None
cx, cy = XYButtons.center
if mpos.x < cx and mpos.y < cy:
self.corner = 0
......@@ -335,7 +335,7 @@ class XYButtons(BufferedCanvas):
def OnLeftDown(self, event):
if not self.enabled:
return
# Take focus when clicked so that arrow keys can control movement
self.SetFocus()
......@@ -362,7 +362,7 @@ class XYButtons(BufferedCanvas):
self.setKeypadIndex(-1)
else:
self.setKeypadIndex(idx)
def OnLeaveWindow(self, evt):
self.quadrant = None
self.concentric = None
......
# 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, os, math
from bufferedcanvas import *
from printrun_utils import *
from printrun_utils import *
def sign(n):
if n < 0: return -1
......@@ -42,9 +42,9 @@ class ZButtons(BufferedCanvas):
# Remember the last clicked value, so we can repeat when spacebar pressed
self.lastValue = None
self.bgcolor = wx.Colour()
self.bgcolor.SetFromName(bgcolor)
self.bgcolormask = wx.Colour(self.bgcolor.Red(), self.bgcolor.Green(), self.bgcolor.Blue(), 128)
self.bgcolor = wx.Colour()
self.bgcolor.SetFromName(bgcolor)
self.bgcolormask = wx.Colour(self.bgcolor.Red(), self.bgcolor.Green(), self.bgcolor.Blue(), 128)
BufferedCanvas.__init__(self, parent, ID)
......@@ -59,7 +59,7 @@ class ZButtons(BufferedCanvas):
def disable(self):
self.enabled = False
self.update()
def enable(self):
self.enabled = True
self.update()
......@@ -78,7 +78,7 @@ class ZButtons(BufferedCanvas):
return idx
idx += 1
return None
def highlight(self, gc, rng, dir):
assert(rng >= -1 and rng <= 3)
assert(dir >= -1 and dir <= 1)
......@@ -93,13 +93,13 @@ class ZButtons(BufferedCanvas):
gc.DrawRoundedRectangle(x, y, w, h, 4)
# gc.DrawRectangle(x, y, w, h)
# self.drawPartialPie(dc, center, r1-inner_ring_radius, r2-inner_ring_radius, a1+fudge, a2-fudge)
def getRangeDir(self, pos):
ydelta = ZButtons.center[1] - pos[1]
return (self.lookupRange(abs(ydelta)), sign(ydelta))
def draw(self, dc, w, h):
dc.SetBackground(wx.Brush(self.bgcolor))
dc.SetBackground(wx.Brush(self.bgcolor))
dc.Clear()
gc = wx.GraphicsContext.Create(dc)
if self.bg_bmp:
......@@ -114,7 +114,7 @@ class ZButtons(BufferedCanvas):
if kpos and idx != self.range:
r = kpos[2]
gc.DrawEllipse(ZButtons.center[0]-kpos[0]-r, ZButtons.center[1]-kpos[1]-r, r*2, r*2)
# Top 'layer' is the mouse-over highlights
gc.SetPen(wx.Pen(wx.Colour(100,100,100,172), 4))
gc.SetBrush(wx.Brush(wx.Colour(0,0,0,128)))
......@@ -132,7 +132,7 @@ class ZButtons(BufferedCanvas):
def OnMotion(self, event):
if not self.enabled:
return
oldr, oldd = self.range, self.direction
mpos = event.GetPosition()
......
# 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/>.
......@@ -70,7 +70,7 @@ class scapewin(wx.Frame):
self.SetIcon(wx.Icon("plater.ico",wx.BITMAP_TYPE_ICO))
self.SetClientSize(size)
self.panel=wx.Panel(self,size=size)
"""
if __name__ == '__main__':
......@@ -82,4 +82,3 @@ if __name__ == '__main__':
"""
zimage("catposthtmap2.jpg","testobj.stl")
del a
This diff is collapsed.
......@@ -49,7 +49,7 @@ from printrun.zbuttons import ZButtons
from printrun.graph import Graph
from printrun.printrun_utils import pixmapfile, configfile
import pronsole
def dosify(name):
return os.path.split(name)[1].split(".")[0][:8]+".g"
......@@ -316,7 +316,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.settbtn.SetForegroundColour, "")
wx.CallAfter(self.htemp.SetBackgroundColour, "white")
wx.CallAfter(self.htemp.Refresh)
def do_settemp(self, l = ""):
try:
if not l.__class__ in (str, unicode) or not len(l):
......@@ -579,7 +579,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview)
#uts.Add((25,-1))
#uts.Add((15,-1),flag=wx.EXPAND)
#uts.Add(self.minibtn,0,wx.ALIGN_CENTER)
......@@ -642,7 +642,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#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)
......@@ -738,7 +738,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
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)
self.htemp.SetValue(i)
if( '(' not in self.btemp.Value):
self.btemp.SetValue(self.btemp.Value + ' (user)')
......@@ -748,7 +748,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#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")
......@@ -767,7 +767,7 @@ 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.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)
......@@ -778,11 +778,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
# 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,1))
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),
......@@ -845,12 +845,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.commandbox.SetSelection(0,len(self.commandbox.history[self.commandbox.histindex]))
elif e.GetKeyCode()==wx.WXK_DOWN:
if self.commandbox.histindex==len(self.commandbox.history):
self.commandbox.history+=[self.commandbox.GetValue()] #save current command
self.commandbox.history+=[self.commandbox.GetValue()] #save current command
if len(self.commandbox.history):
self.commandbox.histindex=(self.commandbox.histindex+1)%len(self.commandbox.history)
self.commandbox.SetValue(self.commandbox.history[self.commandbox.histindex])
self.commandbox.SetSelection(0,len(self.commandbox.history[self.commandbox.histindex]))
else:
e.Skip()
......@@ -957,10 +957,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
b.SetToolTip(wx.ToolTip(_("click to add new custom button")))
b.Bind(wx.EVT_BUTTON,self.cbutton_edit)
else:
b=wx.Button(self.panel,-1,".",size=(1,1))
#b=wx.StaticText(self.panel,-1,"",size=(72,22),style=wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER
b.Disable()
#continue
b=wx.Button(self.panel,-1,".",size=(1,1))
#b=wx.StaticText(self.panel,-1,"",size=(72,22),style=wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER
b.Disable()
#continue
b.custombutton=i
b.properties=btndef
if btndef is not None:
......@@ -984,9 +984,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def nextarg(rest):
rest=rest.lstrip()
if rest.startswith('"'):
return rest[1:].split('"',1)
return rest[1:].split('"',1)
else:
return rest.split(None,1)
return rest.split(None,1)
#try:
num,argstr=nextarg(argstr)
num=int(num)
......@@ -1385,7 +1385,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
except:
break
wx.CallAfter(self.status.SetStatusText,_("Not connected to printer."))
def capture(self, func, *args, **kwargs):
stdout=sys.stdout
cout=None
......@@ -1518,7 +1518,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.f=[i.replace("\n","").replace("\r","") for i in of]
of.close()
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.pausebtn.Disable)
......@@ -1553,7 +1553,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
except:
pass
dlg=wx.FileDialog(self,_("Open file to print"),basedir,style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard(_("OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*"))
dlg.SetWildcard(_("OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*"))
if(filename is not None or dlg.ShowModal() == wx.ID_OK):
if filename is not None:
name=filename
......@@ -1810,4 +1810,3 @@ if __name__ == '__main__':
app.MainLoop()
except:
pass
#!/usr/bin/env 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/>.
......@@ -43,7 +43,7 @@ class install (_install):
except:
self.warn ("Could not write installed files list %s" % \
INSTALLED_FILES)
return
return
file.write (data)
file.close ()
......@@ -66,7 +66,7 @@ class uninstall (_install):
except:
self.warn ("Could not read installed files list %s" % \
INSTALLED_FILES)
return
return
files = file.readlines ()
file.close ()
prepend = ""
......
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