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
ae7bac41
Commit
ae7bac41
authored
Sep 05, 2012
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More cleanup of buttons handling, sanitize custom buttons
parent
d01cb51a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
44 deletions
+52
-44
gui.py
printrun/gui.py
+11
-22
pronterface_widgets.py
printrun/pronterface_widgets.py
+19
-0
pronterface.py
pronterface.py
+22
-22
No files found.
printrun/gui.py
View file @
ae7bac41
...
...
@@ -61,17 +61,17 @@ class LeftPane(wx.GridBagSizer):
self
.
Add
(
self
.
xyzsizer
,
pos
=
(
1
,
0
),
span
=
(
1
,
8
),
flag
=
wx
.
ALIGN_CENTER
)
for
i
in
root
.
cpbuttons
:
btn
=
make_button
(
root
.
panel
,
i
[
0
],
root
.
procbutton
,
i
[
5
]
,
style
=
wx
.
BU_EXACTFIT
)
btn
.
SetBackgroundColour
(
i
[
3
]
)
btn
=
make_button
(
root
.
panel
,
i
.
label
,
root
.
procbutton
,
i
.
tooltip
,
style
=
wx
.
BU_EXACTFIT
)
btn
.
SetBackgroundColour
(
i
.
background
)
btn
.
SetForegroundColour
(
"black"
)
btn
.
properties
=
i
root
.
btndict
[
i
[
1
]
]
=
btn
root
.
btndict
[
i
.
command
]
=
btn
root
.
printerControls
.
append
(
btn
)
if
i
[
2
]
==
None
:
if
i
[
4
]
==
0
:
if
i
.
pos
==
None
:
if
i
.
span
==
0
:
llts
.
Add
(
btn
)
else
:
self
.
Add
(
btn
,
pos
=
i
[
2
],
span
=
i
[
4
]
)
self
.
Add
(
btn
,
pos
=
i
.
pos
,
span
=
i
.
span
)
root
.
xyfeedc
=
wx
.
SpinCtrl
(
root
.
panel
,
-
1
,
str
(
root
.
settings
.
xy_feedrate
),
min
=
0
,
max
=
50000
,
size
=
(
70
,
-
1
))
root
.
xyfeedc
.
SetToolTip
(
wx
.
ToolTip
(
"Set Maximum Speed for X & Y axes (mm/min)"
))
...
...
@@ -90,9 +90,7 @@ class LeftPane(wx.GridBagSizer):
self
.
Add
(
wx
.
StaticText
(
root
.
panel
,
-
1
,
_
(
"Heat:"
)),
pos
=
(
2
,
0
),
span
=
(
1
,
1
),
flag
=
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALIGN_RIGHT
)
htemp_choices
=
[
root
.
temps
[
i
]
+
" ("
+
i
+
")"
for
i
in
sorted
(
root
.
temps
.
keys
(),
key
=
lambda
x
:
root
.
temps
[
x
])]
root
.
settoff
=
wx
.
Button
(
root
.
panel
,
-
1
,
_
(
"Off"
),
size
=
(
36
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
settoff
.
SetToolTip
(
wx
.
ToolTip
(
"Switch Hotend Off"
))
root
.
settoff
.
Bind
(
wx
.
EVT_BUTTON
,
lambda
e
:
root
.
do_settemp
(
"off"
))
root
.
settoff
=
make_button
(
root
.
panel
,
_
(
"Off"
),
lambda
e
:
root
.
do_settemp
(
"off"
),
_
(
"Switch Hotend Off"
),
size
=
(
36
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
printerControls
.
append
(
root
.
settoff
)
self
.
Add
(
root
.
settoff
,
pos
=
(
2
,
1
),
span
=
(
1
,
1
))
...
...
@@ -104,18 +102,14 @@ class LeftPane(wx.GridBagSizer):
root
.
htemp
.
Bind
(
wx
.
EVT_COMBOBOX
,
root
.
htemp_change
)
self
.
Add
(
root
.
htemp
,
pos
=
(
2
,
2
),
span
=
(
1
,
2
))
root
.
settbtn
=
wx
.
Button
(
root
.
panel
,
-
1
,
_
(
"Set"
),
size
=
(
38
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
settbtn
.
SetToolTip
(
wx
.
ToolTip
(
"Switch Hotend On"
))
root
.
settbtn
.
Bind
(
wx
.
EVT_BUTTON
,
root
.
do_settemp
)
root
.
settbtn
=
make_button
(
root
.
panel
,
_
(
"Set"
),
root
.
do_settemp
,
_
(
"Switch Hotend On"
),
size
=
(
38
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
printerControls
.
append
(
root
.
settbtn
)
self
.
Add
(
root
.
settbtn
,
pos
=
(
2
,
4
),
span
=
(
1
,
1
))
self
.
Add
(
wx
.
StaticText
(
root
.
panel
,
-
1
,
_
(
"Bed:"
)),
pos
=
(
3
,
0
),
span
=
(
1
,
1
),
flag
=
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALIGN_RIGHT
)
btemp_choices
=
[
root
.
bedtemps
[
i
]
+
" ("
+
i
+
")"
for
i
in
sorted
(
root
.
bedtemps
.
keys
(),
key
=
lambda
x
:
root
.
temps
[
x
])]
root
.
setboff
=
wx
.
Button
(
root
.
panel
,
-
1
,
_
(
"Off"
),
size
=
(
36
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
setboff
.
SetToolTip
(
wx
.
ToolTip
(
"Switch Heated Bed Off"
))
root
.
setboff
.
Bind
(
wx
.
EVT_BUTTON
,
lambda
e
:
root
.
do_bedtemp
(
"off"
))
root
.
setboff
=
make_button
(
root
.
panel
,
_
(
"Off"
),
lambda
e
:
root
.
do_bedtemp
(
"off"
),
_
(
"Switch Heated Bed Off"
),
size
=
(
36
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
printerControls
.
append
(
root
.
setboff
)
self
.
Add
(
root
.
setboff
,
pos
=
(
3
,
1
),
span
=
(
1
,
1
))
...
...
@@ -127,9 +121,7 @@ class LeftPane(wx.GridBagSizer):
root
.
btemp
.
Bind
(
wx
.
EVT_COMBOBOX
,
root
.
btemp_change
)
self
.
Add
(
root
.
btemp
,
pos
=
(
3
,
2
),
span
=
(
1
,
2
))
root
.
setbbtn
=
wx
.
Button
(
root
.
panel
,
-
1
,
_
(
"Set"
),
size
=
(
38
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
setbbtn
.
SetToolTip
(
wx
.
ToolTip
(
"Switch Heated Bed On"
))
root
.
setbbtn
.
Bind
(
wx
.
EVT_BUTTON
,
root
.
do_bedtemp
)
root
.
setbbtn
=
make_button
(
root
.
panel
,
_
(
"Set"
),
root
.
do_bedtemp
,
(
"Switch Heated Bed On"
),
size
=
(
38
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
printerControls
.
append
(
root
.
setbbtn
)
self
.
Add
(
root
.
setbbtn
,
pos
=
(
3
,
4
),
span
=
(
1
,
1
))
...
...
@@ -232,11 +224,8 @@ class LogPane(wx.BoxSizer):
root
.
commandbox
.
histindex
=
1
#root.printerControls.append(root.commandbox)
lbrs
.
Add
(
root
.
commandbox
,
1
)
root
.
sendbtn
=
wx
.
Button
(
root
.
panel
,
-
1
,
_
(
"Send"
),
style
=
wx
.
BU_EXACTFIT
)
root
.
sendbtn
.
SetToolTip
(
wx
.
ToolTip
(
"Send Command to Printer"
))
root
.
sendbtn
.
Bind
(
wx
.
EVT_BUTTON
,
root
.
sendline
)
root
.
sendbtn
=
make_button
(
root
.
panel
,
_
(
"Send"
),
root
.
sendline
,
_
(
"Send Command to Printer"
),
style
=
wx
.
BU_EXACTFIT
,
container
=
lbrs
)
#root.printerControls.append(root.sendbtn)
lbrs
.
Add
(
root
.
sendbtn
)
self
.
Add
(
lbrs
,
0
,
wx
.
EXPAND
)
class
MainToolbar
(
wx
.
BoxSizer
):
...
...
printrun/pronterface_widgets.py
View file @
ae7bac41
...
...
@@ -316,3 +316,22 @@ class TempGauge(wx.Panel):
gc
.
SetFont
(
gc
.
CreateFont
(
wx
.
Font
(
10
,
wx
.
FONTFAMILY_DEFAULT
,
wx
.
FONTSTYLE_NORMAL
,
wx
.
FONTWEIGHT_BOLD
)))
gc
.
DrawText
(
self
.
title
,
x0
+
18
,
y0
+
3
)
gc
.
DrawText
(
text
,
x0
+
118
,
y0
+
3
)
class
SpecialButton
(
object
):
label
=
None
command
=
None
background
=
None
pos
=
None
span
=
None
tooltip
=
None
custom
=
None
def
__init__
(
self
,
label
,
command
,
background
=
None
,
pos
=
None
,
span
=
None
,
tooltip
=
None
,
custom
=
False
):
self
.
label
=
label
self
.
command
=
command
self
.
pos
=
pos
self
.
background
=
background
self
.
span
=
span
self
.
tooltip
=
tooltip
self
.
custom
=
custom
pronterface.py
View file @
ae7bac41
...
...
@@ -115,10 +115,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
paused
=
False
self
.
sentlines
=
Queue
.
Queue
(
30
)
self
.
cpbuttons
=
[
[
_
(
"Motors off"
),
(
"M84"
),
None
,
(
250
,
250
,
250
),
0
,
_
(
"Switch all motors off"
)]
,
[
_
(
"Check temp"
),
(
"M105"
),
(
2
,
5
),
(
225
,
200
,
200
),
(
1
,
1
),
_
(
"Check current hotend temperature"
)]
,
[
_
(
"Extrude"
),
(
"extrude"
),
(
4
,
0
),
(
225
,
200
,
200
),
(
1
,
2
),
_
(
"Advance extruder by set length"
)]
,
[
_
(
"Reverse"
),
(
"reverse"
),
(
5
,
0
),
(
225
,
200
,
200
),
(
1
,
2
),
_
(
"Reverse extruder by set length"
)]
,
SpecialButton
(
_
(
"Motors off"
),
(
"M84"
),
(
250
,
250
,
250
),
None
,
0
,
_
(
"Switch all motors off"
))
,
SpecialButton
(
_
(
"Check temp"
),
(
"M105"
),
(
225
,
200
,
200
),
(
2
,
5
),
(
1
,
1
),
_
(
"Check current hotend temperature"
))
,
SpecialButton
(
_
(
"Extrude"
),
(
"extrude"
),
(
225
,
200
,
200
),
(
4
,
0
),
(
1
,
2
),
_
(
"Advance extruder by set length"
))
,
SpecialButton
(
_
(
"Reverse"
),
(
"reverse"
),
(
225
,
200
,
200
),
(
5
,
0
),
(
1
,
2
),
_
(
"Reverse extruder by set length"
))
,
]
self
.
custombuttons
=
[]
self
.
btndict
=
{}
...
...
@@ -649,16 +649,16 @@ class PronterWindow(MainWindow, pronsole.pronsole):
for
i
in
xrange
(
len
(
self
.
custombuttons
)):
btndef
=
self
.
custombuttons
[
i
]
try
:
b
=
wx
.
Button
(
self
.
panel
,
-
1
,
btndef
[
0
]
,
style
=
wx
.
BU_EXACTFIT
)
b
.
SetToolTip
(
wx
.
ToolTip
(
_
(
"Execute command: "
)
+
btndef
[
1
]
))
if
len
(
btndef
)
>
2
:
b
.
SetBackgroundColour
(
btndef
[
2
]
)
b
=
wx
.
Button
(
self
.
panel
,
-
1
,
btndef
.
label
,
style
=
wx
.
BU_EXACTFIT
)
b
.
SetToolTip
(
wx
.
ToolTip
(
_
(
"Execute command: "
)
+
btndef
.
command
))
if
btndef
.
background
:
b
.
SetBackgroundColour
(
btndef
.
background
)
rr
,
gg
,
bb
=
b
.
GetBackgroundColour
()
.
Get
()
if
0.3
*
rr
+
0.59
*
gg
+
0.11
*
bb
<
60
:
b
.
SetForegroundColour
(
"#ffffff"
)
except
:
if
i
==
newbuttonbuttonindex
:
self
.
newbuttonbutton
=
b
=
wx
.
Button
(
self
.
panel
,
-
1
,
"+"
,
size
=
(
19
,
18
),
style
=
wx
.
BU_EXACTFIT
)
self
.
newbuttonbutton
=
b
=
wx
.
Button
(
self
.
panel
,
-
1
,
"+"
,
size
=
(
19
,
18
),
style
=
wx
.
BU_EXACTFIT
)
#b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
b
.
SetForegroundColour
(
"#4444ff"
)
b
.
SetToolTip
(
wx
.
ToolTip
(
_
(
"click to add new custom button"
)))
...
...
@@ -712,10 +712,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
webInterface
.
AddLog
(
"Custom button number should be between 0 and 63"
)
return
while
num
>=
len
(
self
.
custombuttons
):
self
.
custombuttons
+=
[
None
]
self
.
custombuttons
[
num
]
=
[
title
,
command
]
self
.
custombuttons
.
append
(
None
)
self
.
custombuttons
[
num
]
=
SpecialButton
(
title
,
command
)
if
colour
is
not
None
:
self
.
custombuttons
[
num
]
+=
[
colour
]
self
.
custombuttons
[
num
]
.
background
=
colour
if
not
self
.
processing_rc
:
self
.
cbuttons_reload
()
#except Exception, x:
...
...
@@ -726,8 +726,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if
new_n
is
None
:
new_n
=
n
if
bdef
is
None
or
bdef
==
""
:
self
.
save_in_rc
((
"button
%
d"
%
n
),
''
)
elif
len
(
bdef
)
>
2
:
colour
=
bdef
[
2
]
elif
bdef
.
background
:
colour
=
bdef
.
background
if
type
(
colour
)
not
in
(
str
,
unicode
):
#print type(colour), map(type, colour)
if
type
(
colour
)
==
tuple
and
tuple
(
map
(
type
,
colour
))
==
(
int
,
int
,
int
):
...
...
@@ -735,18 +735,18 @@ class PronterWindow(MainWindow, pronsole.pronsole):
colour
=
wx
.
Colour
(
*
colour
)
.
GetAsString
(
wx
.
C2S_NAME
|
wx
.
C2S_HTML_SYNTAX
)
else
:
colour
=
wx
.
Colour
(
colour
)
.
GetAsString
(
wx
.
C2S_NAME
|
wx
.
C2S_HTML_SYNTAX
)
self
.
save_in_rc
((
"button
%
d"
%
n
),
'button
%
d "
%
s" /c "
%
s"
%
s'
%
(
new_n
,
bdef
[
0
],
colour
,
bdef
[
1
]
))
self
.
save_in_rc
((
"button
%
d"
%
n
),
'button
%
d "
%
s" /c "
%
s"
%
s'
%
(
new_n
,
bdef
.
label
,
colour
,
bdef
.
command
))
else
:
self
.
save_in_rc
((
"button
%
d"
%
n
),
'button
%
d "
%
s"
%
s'
%
(
new_n
,
bdef
[
0
],
bdef
[
1
]
))
self
.
save_in_rc
((
"button
%
d"
%
n
),
'button
%
d "
%
s"
%
s'
%
(
new_n
,
bdef
.
label
,
bdef
.
command
))
def
cbutton_edit
(
self
,
e
,
button
=
None
):
bedit
=
ButtonEdit
(
self
)
if
button
is
not
None
:
n
=
button
.
custombutton
bedit
.
name
.
SetValue
(
button
.
properties
[
0
]
)
bedit
.
command
.
SetValue
(
button
.
properties
[
1
]
)
if
len
(
button
.
properties
)
>
2
:
colour
=
button
.
properties
[
2
]
bedit
.
name
.
SetValue
(
button
.
label
)
bedit
.
command
.
SetValue
(
button
.
command
)
if
button
.
background
:
colour
=
button
.
background
if
type
(
colour
)
not
in
(
str
,
unicode
):
#print type(colour)
if
type
(
colour
)
==
tuple
and
tuple
(
map
(
type
,
colour
))
==
(
int
,
int
,
int
):
...
...
@@ -762,9 +762,9 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if
bedit
.
ShowModal
()
==
wx
.
ID_OK
:
if
n
==
len
(
self
.
custombuttons
):
self
.
custombuttons
+=
[
None
]
self
.
custombuttons
[
n
]
=
[
bedit
.
name
.
GetValue
()
.
strip
(),
bedit
.
command
.
GetValue
()
.
strip
()]
self
.
custombuttons
[
n
]
=
SpecialButton
(
bedit
.
name
.
GetValue
()
.
strip
(),
bedit
.
command
.
GetValue
()
.
strip
(),
custom
=
True
)
if
bedit
.
color
.
GetValue
()
.
strip
()
!=
""
:
self
.
custombuttons
[
n
]
+=
[
bedit
.
color
.
GetValue
()]
self
.
custombuttons
[
n
]
.
background
=
bedit
.
color
.
GetValue
()
self
.
cbutton_save
(
n
,
self
.
custombuttons
[
n
])
bedit
.
Destroy
()
self
.
cbuttons_reload
()
...
...
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