Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
4c348272
Commit
4c348272
authored
May 22, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Settings and Settings dialog
parent
cbaed9e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
184 additions
and
61 deletions
+184
-61
pronterface_widgets.py
printrun/pronterface_widgets.py
+10
-14
pronsole.py
pronsole.py
+161
-28
pronterface.py
pronterface.py
+13
-19
No files found.
printrun/pronterface_widgets.py
View file @
4c348272
...
...
@@ -120,35 +120,31 @@ class MacroEditor(wx.Dialog):
reindented
+=
self
.
indent_chars
+
line
+
"
\n
"
return
reindented
class
o
ptions
(
wx
.
Dialog
):
class
PronterO
ptions
(
wx
.
Dialog
):
"""Options editor"""
def
__init__
(
self
,
pronterface
):
wx
.
Dialog
.
__init__
(
self
,
None
,
title
=
_
(
"Edit settings"
),
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
RESIZE_BORDER
)
topsizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
vbox
=
wx
.
StaticBoxSizer
(
wx
.
StaticBox
(
self
,
label
=
_
(
"
Default
s"
))
,
wx
.
VERTICAL
)
vbox
=
wx
.
StaticBoxSizer
(
wx
.
StaticBox
(
self
,
label
=
_
(
"
Setting
s"
))
,
wx
.
VERTICAL
)
topsizer
.
Add
(
vbox
,
1
,
wx
.
ALL
+
wx
.
EXPAND
)
grid
=
wx
.
FlexGridSizer
(
rows
=
0
,
cols
=
2
,
hgap
=
8
,
vgap
=
2
)
grid
.
SetFlexibleDirection
(
wx
.
BOTH
)
grid
.
AddGrowableCol
(
1
)
grid
.
SetNonFlexibleGrowMode
(
wx
.
FLEX_GROWMODE_SPECIFIED
)
vbox
.
Add
(
grid
,
0
,
wx
.
EXPAND
)
ctrls
=
{}
for
k
,
v
in
sorted
(
pronterface
.
settings
.
_all_settings
()
.
items
()):
ctrls
[
k
,
0
]
=
wx
.
StaticText
(
self
,
-
1
,
k
)
ctrls
[
k
,
1
]
=
wx
.
TextCtrl
(
self
,
-
1
,
str
(
v
))
if
k
in
pronterface
.
helpdict
:
ctrls
[
k
,
0
]
.
SetToolTipString
(
pronterface
.
helpdict
.
get
(
k
))
ctrls
[
k
,
1
]
.
SetToolTipString
(
pronterface
.
helpdict
.
get
(
k
))
grid
.
Add
(
ctrls
[
k
,
0
],
0
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
|
wx
.
ALIGN_RIGHT
)
grid
.
Add
(
ctrls
[
k
,
1
],
1
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
|
wx
.
EXPAND
)
for
setting
in
pronterface
.
settings
.
_all_settings
():
grid
.
Add
(
setting
.
get_label
(
self
),
0
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
|
wx
.
ALIGN_RIGHT
)
grid
.
Add
(
setting
.
get_widget
(
self
),
1
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
|
wx
.
EXPAND
)
topsizer
.
Add
(
self
.
CreateSeparatedButtonSizer
(
wx
.
OK
+
wx
.
CANCEL
),
0
,
wx
.
EXPAND
)
self
.
SetSizer
(
topsizer
)
topsizer
.
Layout
()
topsizer
.
Fit
(
self
)
if
self
.
ShowModal
()
==
wx
.
ID_OK
:
for
k
,
v
in
pronterface
.
settings
.
_all_settings
()
.
items
():
if
ctrls
[
k
,
1
]
.
GetValue
()
!=
str
(
v
):
pronterface
.
set
(
k
,
str
(
ctrls
[
k
,
1
]
.
GetValue
()))
for
setting
in
pronterface
.
settings
.
_all_settings
():
old_value
=
setting
.
value
setting
.
update
()
if
setting
.
value
!=
old_value
:
pronterface
.
set
(
setting
.
name
,
setting
.
value
)
self
.
Destroy
()
class
ButtonEdit
(
wx
.
Dialog
):
...
...
pronsole.py
View file @
4c348272
...
...
@@ -28,6 +28,8 @@ from printrun.printrun_utils import install_locale
from
printrun
import
gcoder
install_locale
(
'pronterface'
)
from
functools
import
wraps
if
os
.
name
==
"nt"
:
try
:
import
_winreg
...
...
@@ -54,27 +56,169 @@ def confirm():
return
confirm
()
return
False
class
Settings
:
def
setting_add_tooltip
(
func
):
@
wraps
(
func
)
def
decorator
(
self
,
*
args
,
**
kwargs
):
widget
=
func
(
self
,
*
args
,
**
kwargs
)
if
self
.
help
:
widget
.
SetToolTipString
(
self
.
help
)
return
widget
return
decorator
class
Setting
(
object
):
hidden
=
False
def
__init__
(
self
,
name
,
default
,
label
=
None
,
help
=
None
):
self
.
name
=
name
self
.
default
=
default
self
.
_value
=
default
self
.
label
=
label
self
.
help
=
help
def
_get_value
(
self
):
return
self
.
_value
def
_set_value
(
self
,
value
):
raise
NotImplementedError
value
=
property
(
_get_value
,
_set_value
)
@
setting_add_tooltip
def
get_label
(
self
,
parent
):
import
wx
widget
=
wx
.
StaticText
(
parent
,
-
1
,
self
.
label
or
self
.
name
)
return
widget
@
setting_add_tooltip
def
get_widget
(
self
,
parent
):
return
self
.
get_specific_widget
(
parent
)
def
get_specific_widget
(
self
,
parent
):
raise
NotImplementedError
def
set
(
self
,
value
):
raise
NotImplementedError
def
get
(
self
):
raise
NotImplementedError
def
update
(
self
):
raise
NotImplementedError
def
__str__
(
self
):
return
self
.
name
def
__repr__
(
self
):
return
self
.
name
class
HiddenSetting
(
Setting
):
hidden
=
True
def
_set_value
(
self
,
value
):
self
.
_value
=
value
value
=
property
(
Setting
.
_get_value
,
_set_value
)
class
wxSetting
(
Setting
):
widget
=
None
def
_set_value
(
self
,
value
):
self
.
_value
=
value
if
self
.
widget
:
self
.
widget
.
SetValue
(
value
)
value
=
property
(
Setting
.
_get_value
,
_set_value
)
def
update
(
self
):
self
.
value
=
self
.
widget
.
GetValue
()
class
StringSetting
(
wxSetting
):
def
get_specific_widget
(
self
,
parent
):
import
wx
self
.
widget
=
wx
.
TextCtrl
(
parent
,
-
1
,
str
(
self
.
value
))
return
self
.
widget
class
ComboSetting
(
wxSetting
):
def
__init__
(
self
,
name
,
default
,
choices
,
label
=
None
,
help
=
None
):
super
(
ComboSetting
,
self
)
.
__init__
(
name
,
default
,
label
,
help
)
self
.
choices
=
choices
def
get_specific_widget
(
self
,
parent
):
import
wx
self
.
widget
=
wx
.
ComboBox
(
parent
,
-
1
,
str
(
self
.
value
),
choices
=
self
.
choices
,
style
=
wx
.
CB_DROPDOWN
)
return
self
.
widget
class
SpinSetting
(
wxSetting
):
def
__init__
(
self
,
name
,
default
,
min
,
max
,
label
=
None
,
help
=
None
):
super
(
SpinSetting
,
self
)
.
__init__
(
name
,
default
,
label
,
help
)
self
.
min
=
min
self
.
max
=
max
def
get_specific_widget
(
self
,
parent
):
import
wx
self
.
widget
=
wx
.
SpinCtrl
(
parent
,
-
1
,
min
=
self
.
min
,
max
=
self
.
max
)
self
.
widget
.
SetValue
(
self
.
value
)
return
self
.
widget
class
FloatSpinSetting
(
SpinSetting
):
def
get_specific_widget
(
self
,
parent
):
from
wx.lib.agw.floatspin
import
FloatSpin
self
.
widget
=
FloatSpin
(
parent
,
-
1
,
value
=
self
.
value
,
min_val
=
self
.
min
,
max_val
=
self
.
max
,
digits
=
2
)
return
self
.
widget
class
BooleanSetting
(
wxSetting
):
def
get_specific_widget
(
self
,
parent
):
import
wx
self
.
widget
=
wx
.
CheckBox
(
parent
,
-
1
)
self
.
widget
.
SetValue
(
bool
(
self
.
value
))
return
self
.
widget
class
Settings
(
object
):
#def _temperature_alias(self): return {"pla":210, "abs":230, "off":0}
#def _temperature_validate(self, v):
# if v < 0: raise ValueError("You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0.")
#def _bedtemperature_alias(self): return {"pla":60, "abs":110, "off":0}
def
_baudrate_list
(
self
):
return
[
"2400"
,
"9600"
,
"19200"
,
"38400"
,
"57600"
,
"115200"
]
def
_baudrate_list
(
self
):
return
[
"2400"
,
"9600"
,
"19200"
,
"38400"
,
"57600"
,
"115200"
,
"250000"
]
def
__init__
(
self
):
# defaults here.
# the initial value determines the type
self
.
port
=
""
self
.
baudrate
=
115200
self
.
bedtemp_abs
=
110
self
.
bedtemp_pla
=
60
self
.
temperature_abs
=
230
self
.
temperature_pla
=
185
self
.
xy_feedrate
=
3000
self
.
z_feedrate
=
200
self
.
e_feedrate
=
300
self
.
slicecommand
=
"python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s"
self
.
sliceoptscommand
=
"python skeinforge/skeinforge_application/skeinforge.py"
self
.
final_command
=
""
self
.
_add
(
StringSetting
(
"port"
,
""
,
_
(
"Serial port"
),
_
(
"Port used to communicate with printer"
)))
self
.
_add
(
ComboSetting
(
"baudrate"
,
115200
,
self
.
_baudrate_list
(),
_
(
"Baud rate"
),
_
(
"Communications Speed (default: 115200)"
)))
self
.
_add
(
SpinSetting
(
"bedtemp_abs"
,
110
,
0
,
400
,
_
(
"Bed temperature for ABS"
),
_
(
"Heated Build Platform temp for ABS (default: 110 deg C)"
)))
self
.
_add
(
SpinSetting
(
"bedtemp_pla"
,
60
,
0
,
400
,
_
(
"Bed temperature for PLA"
),
_
(
"Heated Build Platform temp for PLA (default: 60 deg C)"
)))
self
.
_add
(
SpinSetting
(
"temperature_abs"
,
230
,
0
,
400
,
_
(
"Bed temperature for ABS"
),
_
(
"Extruder temp for ABS (default: 230 deg C)"
)))
self
.
_add
(
SpinSetting
(
"temperature_pla"
,
185
,
0
,
400
,
_
(
"Bed temperature for PLA"
),
_
(
"Extruder temp for PLA (default: 185 deg C)"
)))
self
.
_add
(
SpinSetting
(
"xy_feedrate"
,
3000
,
0
,
50000
,
_
(
"X & Y manual feedrate"
),
_
(
"Feedrate for Control Panel Moves in X and Y (default: 3000mm/min)"
)))
self
.
_add
(
SpinSetting
(
"z_feedrate"
,
200
,
0
,
50000
,
_
(
"Z manual feedrate"
),
_
(
"Feedrate for Control Panel Moves in Z (default: 200mm/min)"
)))
self
.
_add
(
SpinSetting
(
"e_feedrate"
,
300
,
0
,
1000
,
_
(
"E manual feedrate"
),
_
(
"Feedrate for Control Panel Moves in Extrusions (default: 300mm/min)"
)))
self
.
_add
(
StringSetting
(
"slicecommand"
,
"python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s"
,
_
(
"Slice command"
),
_
(
"Slice command
\n
default:
\n
python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s)"
)))
self
.
_add
(
StringSetting
(
"sliceoptscommand"
,
"python skeinforge/skeinforge_application/skeinforge.py"
,
_
(
"Slicer options command"
),
_
(
"Slice settings command
\n
default:
\n
python skeinforge/skeinforge_application/skeinforge.py"
)))
self
.
_add
(
StringSetting
(
"final_command"
,
""
,
_
(
"Final command"
),
_
(
"Executable to run when the print is finished"
)))
_settings
=
[]
def
__setattr__
(
self
,
name
,
value
):
if
name
.
startswith
(
"_"
):
return
object
.
__setattr__
(
self
,
name
,
value
)
if
isinstance
(
value
,
Setting
):
if
not
value
.
hidden
:
self
.
_settings
.
append
(
value
)
object
.
__setattr__
(
self
,
"_"
+
name
,
value
)
elif
hasattr
(
self
,
"_"
+
name
):
getattr
(
self
,
"_"
+
name
)
.
value
=
value
else
:
setattr
(
self
,
name
,
StringSetting
(
name
=
name
,
default
=
value
))
def
__getattr__
(
self
,
name
):
if
name
.
startswith
(
"_"
):
return
object
.
__getattribute__
(
self
,
name
)
return
getattr
(
self
,
"_"
+
name
)
.
value
def
_add
(
self
,
setting
):
setattr
(
self
,
setting
.
name
,
setting
)
def
_set
(
self
,
key
,
value
):
try
:
...
...
@@ -93,6 +237,7 @@ class Settings:
except
AttributeError
:
pass
return
value
def
_tabcomplete
(
self
,
key
):
try
:
return
getattr
(
self
,
"_
%
s_list"
%
key
)()
...
...
@@ -103,8 +248,9 @@ class Settings:
except
AttributeError
:
pass
return
[]
def
_all_settings
(
self
):
return
dict
([(
k
,
getattr
(
self
,
k
))
for
k
in
self
.
__dict__
.
keys
()
if
not
k
.
startswith
(
"_"
)])
return
self
.
_settings
class
Status
:
...
...
@@ -169,19 +315,6 @@ class pronsole(cmd.Cmd):
self
.
settings
.
_bedtemp_pla_cb
=
self
.
set_temp_preset
self
.
monitoring
=
0
self
.
silent
=
False
self
.
helpdict
=
{}
self
.
helpdict
[
"baudrate"
]
=
_
(
"Communications Speed (default: 115200)"
)
self
.
helpdict
[
"bedtemp_abs"
]
=
_
(
"Heated Build Platform temp for ABS (default: 110 deg C)"
)
self
.
helpdict
[
"bedtemp_pla"
]
=
_
(
"Heated Build Platform temp for PLA (default: 60 deg C)"
)
self
.
helpdict
[
"e_feedrate"
]
=
_
(
"Feedrate for Control Panel Moves in Extrusions (default: 300mm/min)"
)
self
.
helpdict
[
"port"
]
=
_
(
"Port used to communicate with printer"
)
self
.
helpdict
[
"slicecommand"
]
=
_
(
"Slice command
\n
default:
\n
python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s)"
)
self
.
helpdict
[
"sliceoptscommand"
]
=
_
(
"Slice settings command
\n
default:
\n
python skeinforge/skeinforge_application/skeinforge.py"
)
self
.
helpdict
[
"temperature_abs"
]
=
_
(
"Extruder temp for ABS (default: 230 deg C)"
)
self
.
helpdict
[
"temperature_pla"
]
=
_
(
"Extruder temp for PLA (default: 185 deg C)"
)
self
.
helpdict
[
"xy_feedrate"
]
=
_
(
"Feedrate for Control Panel Moves in X and Y (default: 3000mm/min)"
)
self
.
helpdict
[
"z_feedrate"
]
=
_
(
"Feedrate for Control Panel Moves in Z (default: 200mm/min)"
)
self
.
helpdict
[
"final_command"
]
=
_
(
"Executable to run when the print is finished"
)
self
.
commandprefixes
=
'MGT$'
self
.
promptstrs
=
{
"offline"
:
"
%(bold)
suninitialized>
%(normal)
s "
,
"fallback"
:
"
%(bold)
sPC>
%(normal)
s "
,
...
...
pronterface.py
View file @
4c348272
...
...
@@ -46,7 +46,7 @@ import printcore
from
printrun.printrun_utils
import
pixmapfile
,
configfile
from
printrun.gui
import
MainWindow
import
pronsole
from
pronsole
import
dosify
from
pronsole
import
dosify
,
HiddenSetting
,
StringSetting
,
SpinSetting
,
FloatSpinSetting
,
BooleanSetting
from
printrun
import
gcoder
def
parse_temperature_report
(
report
,
key
):
...
...
@@ -85,26 +85,20 @@ class Tee(object):
class
PronterWindow
(
MainWindow
,
pronsole
.
pronsole
):
def
__init__
(
self
,
filename
=
None
,
size
=
winsize
):
pronsole
.
pronsole
.
__init__
(
self
)
self
.
settings
.
build_dimensions
=
'200x200x100+0+0+0+0+0+0'
#default build dimensions are 200x200x100 with 0, 0, 0 in the corner of the bed
self
.
settings
.
last_bed_temperature
=
0.0
self
.
settings
.
last_file_path
=
""
self
.
settings
.
last_temperature
=
0.0
self
.
settings
.
preview_extrusion_width
=
0.5
self
.
settings
.
preview_grid_step1
=
10.
self
.
settings
.
preview_grid_step2
=
50.
self
.
settings
.
bgcolor
=
"#FFFFFF"
#default build dimensions are 200x200x100 with 0, 0, 0 in the corner of the bed and endstops at 0, 0 and 0
self
.
settings
.
_add
(
StringSetting
(
"build_dimensions"
,
"200x200x100+0+0+0+0+0+0"
,
_
(
"Build dimensions"
),
_
(
"Dimensions of Build Platform
\n
& optional offset of origin
\n
& optional switch position
\n\n
Examples:
\n
XXXxYYY
\n
XXX,YYY,ZZZ
\n
XXXxYYYxZZZ+OffX+OffY+OffZ
\n
XXXxYYYxZZZ+OffX+OffY+OffZ+HomeX+HomeY+HomeZ"
)))
self
.
settings
.
_add
(
BooleanSetting
(
"viz3d"
,
False
,
_
(
"Enable 3D viewer"
),
_
(
"Use 3D visualization instead of 2D layered visualization"
)))
self
.
settings
.
_add
(
HiddenSetting
(
"last_bed_temperature"
,
0.0
))
self
.
settings
.
_add
(
HiddenSetting
(
"last_file_path"
,
""
))
self
.
settings
.
_add
(
HiddenSetting
(
"last_temperature"
,
0.0
))
self
.
settings
.
_add
(
FloatSpinSetting
(
"preview_extrusion_width"
,
0.5
,
0
,
10
,
_
(
"Preview extrusion width"
),
_
(
"Width of Extrusion in Preview (default: 0.5)"
)))
self
.
settings
.
_add
(
SpinSetting
(
"preview_grid_step1"
,
10.
,
0
,
200
,
_
(
"Fine grid spacing"
),
_
(
"Fine Grid Spacing (default: 10)"
)))
self
.
settings
.
_add
(
SpinSetting
(
"preview_grid_step2"
,
50.
,
0
,
200
,
_
(
"Coarse grid spacing"
),
_
(
"Coarse Grid Spacing (default: 50)"
)))
self
.
settings
.
_add
(
StringSetting
(
"bgcolor"
,
"#FFFFFF"
,
_
(
"Background color"
),
_
(
"Pronterface background color (default: #FFFFFF)"
)))
self
.
pauseScript
=
"pause.gcode"
self
.
endScript
=
"end.gcode"
self
.
helpdict
[
"build_dimensions"
]
=
_
(
"Dimensions of Build Platform
\n
& optional offset of origin
\n
& optional switch position
\n\n
Examples:
\n
XXXxYYY
\n
XXX,YYY,ZZZ
\n
XXXxYYYxZZZ+OffX+OffY+OffZ
\n
XXXxYYYxZZZ+OffX+OffY+OffZ+HomeX+HomeY+HomeZ"
)
self
.
helpdict
[
"last_bed_temperature"
]
=
_
(
"Last Set Temperature for the Heated Print Bed"
)
self
.
helpdict
[
"last_file_path"
]
=
_
(
"Folder of last opened file"
)
self
.
helpdict
[
"last_temperature"
]
=
_
(
"Last Temperature of the Hot End"
)
self
.
helpdict
[
"preview_extrusion_width"
]
=
_
(
"Width of Extrusion in Preview (default: 0.5)"
)
self
.
helpdict
[
"preview_grid_step1"
]
=
_
(
"Fine Grid Spacing (default: 10)"
)
self
.
helpdict
[
"preview_grid_step2"
]
=
_
(
"Coarse Grid Spacing (default: 50)"
)
self
.
helpdict
[
"bgcolor"
]
=
_
(
"Pronterface background color (default: #FFFFFF)"
)
self
.
filename
=
filename
os
.
putenv
(
"UBUNTU_MENUPROXY"
,
"0"
)
MainWindow
.
__init__
(
self
,
None
,
title
=
_
(
"Printer Interface"
),
size
=
size
);
...
...
@@ -451,7 +445,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
macros_menu
=
wx
.
Menu
()
m
.
AppendSubMenu
(
self
.
macros_menu
,
_
(
"&Macros"
))
self
.
Bind
(
wx
.
EVT_MENU
,
self
.
new_macro
,
self
.
macros_menu
.
Append
(
-
1
,
_
(
"<&New...>"
)))
self
.
Bind
(
wx
.
EVT_MENU
,
lambda
*
e
:
o
ptions
(
self
),
m
.
Append
(
-
1
,
_
(
"&Options"
),
_
(
" Options dialog"
)))
self
.
Bind
(
wx
.
EVT_MENU
,
lambda
*
e
:
PronterO
ptions
(
self
),
m
.
Append
(
-
1
,
_
(
"&Options"
),
_
(
" Options dialog"
)))
self
.
Bind
(
wx
.
EVT_MENU
,
lambda
x
:
threading
.
Thread
(
target
=
lambda
:
self
.
do_skein
(
"set"
))
.
start
(),
m
.
Append
(
-
1
,
_
(
"Slicing Settings"
),
_
(
" Adjust slicing settings"
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment