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
fb357bae
Commit
fb357bae
authored
Mar 26, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make instant reload of UI functional. Woohoo ^^
parent
6f6b4fc5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
31 deletions
+61
-31
__init__.py
printrun/gui/__init__.py
+15
-11
toolbar.py
printrun/gui/toolbar.py
+25
-5
pronterface.py
printrun/pronterface.py
+21
-15
No files found.
printrun/gui/__init__.py
View file @
fb357bae
...
@@ -101,6 +101,7 @@ class MainWindow(wx.Frame):
...
@@ -101,6 +101,7 @@ class MainWindow(wx.Frame):
# when we're connected to a printer
# when we're connected to a printer
self
.
panel
=
wx
.
Panel
(
self
,
-
1
,
size
=
kwargs
[
"size"
])
self
.
panel
=
wx
.
Panel
(
self
,
-
1
,
size
=
kwargs
[
"size"
])
self
.
reset_ui
()
self
.
reset_ui
()
self
.
statefulControls
=
[]
def
reset_ui
(
self
):
def
reset_ui
(
self
):
self
.
panels
=
[]
self
.
panels
=
[]
...
@@ -172,12 +173,6 @@ class MainWindow(wx.Frame):
...
@@ -172,12 +173,6 @@ class MainWindow(wx.Frame):
self
.
panel
.
SetSizerAndFit
(
self
.
notesizer
)
self
.
panel
.
SetSizerAndFit
(
self
.
notesizer
)
# disable all printer controls until we connect to a printer
self
.
pausebtn
.
Disable
()
self
.
recoverbtn
.
Disable
()
for
i
in
self
.
printerControls
:
i
.
Disable
()
self
.
cbuttons_reload
()
self
.
cbuttons_reload
()
minsize
=
self
.
lowersizer
.
GetMinSize
()
# lower pane
minsize
=
self
.
lowersizer
.
GetMinSize
()
# lower pane
minsize
[
1
]
=
self
.
notebook
.
GetSize
()[
1
]
minsize
[
1
]
=
self
.
notebook
.
GetSize
()[
1
]
...
@@ -254,10 +249,19 @@ class MainWindow(wx.Frame):
...
@@ -254,10 +249,19 @@ class MainWindow(wx.Frame):
minsize
[
1
]
=
min
(
minsize
[
1
],
displaysize
[
1
])
minsize
[
1
]
=
min
(
minsize
[
1
],
displaysize
[
1
])
self
.
SetMinSize
(
self
.
ClientToWindowSize
(
minsize
))
# client to window
self
.
SetMinSize
(
self
.
ClientToWindowSize
(
minsize
))
# client to window
# disable all printer controls until we connect to a printer
self
.
cbuttons_reload
()
def
gui_set_connected
(
self
):
self
.
xyb
.
enable
()
self
.
zb
.
enable
()
for
control
in
self
.
printerControls
:
control
.
Enable
()
def
gui_set_disconnected
(
self
):
self
.
printbtn
.
Disable
()
self
.
pausebtn
.
Disable
()
self
.
pausebtn
.
Disable
()
self
.
recoverbtn
.
Disable
()
self
.
recoverbtn
.
Disable
()
for
i
in
self
.
printerControls
:
for
control
in
self
.
printerControls
:
i
.
Disable
()
control
.
Disable
()
self
.
xyb
.
disable
()
self
.
cbuttons_reload
()
self
.
zb
.
disable
()
printrun/gui/toolbar.py
View file @
fb357bae
...
@@ -50,18 +50,38 @@ def MainToolbar(root, parentpanel = None, use_wrapsizer = False):
...
@@ -50,18 +50,38 @@ def MainToolbar(root, parentpanel = None, use_wrapsizer = False):
except
:
except
:
pass
pass
self
.
Add
(
root
.
baud
)
self
.
Add
(
root
.
baud
)
root
.
connectbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Connect"
),
root
.
connect
,
_
(
"Connect to the printer"
),
self
)
root
.
resetbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Reset"
),
root
.
reset
,
_
(
"Reset the printer"
),
self
)
if
not
hasattr
(
root
,
"connectbtn"
):
root
.
connectbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Connect"
),
root
.
connect
,
_
(
"Connect to the printer"
))
root
.
statefulControls
.
append
(
root
.
connectbtn
)
else
:
root
.
connectbtn
.
Reparent
(
parentpanel
)
self
.
Add
(
root
.
connectbtn
)
if
not
hasattr
(
root
,
"resetbtn"
):
root
.
resetbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Reset"
),
root
.
reset
,
_
(
"Reset the printer"
))
root
.
statefulControls
.
append
(
root
.
resetbtn
)
else
:
root
.
resetbtn
.
Reparent
(
parentpanel
)
self
.
Add
(
root
.
resetbtn
)
self
.
AddStretchSpacer
(
prop
=
1
)
self
.
AddStretchSpacer
(
prop
=
1
)
root
.
loadbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Load file"
),
root
.
loadfile
,
_
(
"Load a 3D model file"
),
self
)
root
.
loadbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Load file"
),
root
.
loadfile
,
_
(
"Load a 3D model file"
),
self
)
root
.
sdbtn
=
make_autosize_button
(
parentpanel
,
_
(
"SD"
),
root
.
sdmenu
,
_
(
"SD Card Printing"
),
self
)
root
.
sdbtn
=
make_autosize_button
(
parentpanel
,
_
(
"SD"
),
root
.
sdmenu
,
_
(
"SD Card Printing"
),
self
)
root
.
sdbtn
.
Reparent
(
parentpanel
)
root
.
printerControls
.
append
(
root
.
sdbtn
)
root
.
printerControls
.
append
(
root
.
sdbtn
)
root
.
printbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Print"
),
root
.
printfile
,
_
(
"Start Printing Loaded File"
),
self
)
if
not
hasattr
(
root
,
"printbtn"
):
root
.
printbtn
.
Disable
()
root
.
printbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Print"
),
root
.
printfile
,
_
(
"Start Printing Loaded File"
))
root
.
pausebtn
=
make_autosize_button
(
parentpanel
,
_
(
"Pause"
),
root
.
pause
,
_
(
"Pause Current Print"
),
self
)
root
.
statefulControls
.
append
(
root
.
printbtn
)
else
:
root
.
printbtn
.
Reparent
(
parentpanel
)
self
.
Add
(
root
.
printbtn
)
if
not
hasattr
(
root
,
"pausebtn"
):
root
.
pausebtn
=
make_autosize_button
(
parentpanel
,
_
(
"Pause"
),
root
.
pause
,
_
(
"Pause Current Print"
))
root
.
statefulControls
.
append
(
root
.
pausebtn
)
else
:
root
.
pausebtn
.
Reparent
(
parentpanel
)
self
.
Add
(
root
.
pausebtn
)
root
.
offbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Off"
),
root
.
off
,
_
(
"Turn printer off"
),
self
)
root
.
offbtn
=
make_autosize_button
(
parentpanel
,
_
(
"Off"
),
root
.
off
,
_
(
"Turn printer off"
),
self
)
root
.
printerControls
.
append
(
root
.
offbtn
)
root
.
printerControls
.
append
(
root
.
offbtn
)
...
...
printrun/pronterface.py
View file @
fb357bae
...
@@ -247,6 +247,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -247,6 +247,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
update_recent_files
(
"recentfiles"
,
self
.
settings
.
recentfiles
)
self
.
update_recent_files
(
"recentfiles"
,
self
.
settings
.
recentfiles
)
self
.
reload_ui
()
self
.
reload_ui
()
# disable all printer controls until we connect to a printer
self
.
gui_set_disconnected
()
self
.
statusbar
=
self
.
CreateStatusBar
()
self
.
statusbar
=
self
.
CreateStatusBar
()
self
.
statusbar
.
SetStatusText
(
_
(
"Not connected to printer."
))
self
.
statusbar
.
SetStatusText
(
_
(
"Not connected to printer."
))
...
@@ -280,16 +282,33 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -280,16 +282,33 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def
reload_ui
(
self
,
*
args
):
def
reload_ui
(
self
,
*
args
):
if
not
self
.
window_ready
:
return
if
not
self
.
window_ready
:
return
self
.
Freeze
()
self
.
Freeze
()
# If UI is being recreated, delete current one
if
self
.
ui_ready
:
if
self
.
ui_ready
:
# Create a temporary panel to reparent widgets with state we want
# to retain across UI changes
logcontent
=
self
.
logbox
.
GetValue
()
temppanel
=
wx
.
Panel
(
self
)
for
control
in
self
.
statefulControls
:
control
.
GetContainingSizer
()
.
Detach
(
control
)
control
.
Reparent
(
temppanel
)
self
.
panel
.
DestroyChildren
()
self
.
panel
.
DestroyChildren
()
self
.
gwindow
.
Destroy
()
self
.
gwindow
.
Destroy
()
self
.
reset_ui
()
self
.
reset_ui
()
# Create UI
if
self
.
settings
.
uimode
==
"Tabbed"
:
if
self
.
settings
.
uimode
==
"Tabbed"
:
self
.
createTabbedGui
()
self
.
createTabbedGui
()
else
:
else
:
self
.
createGui
(
self
.
settings
.
uimode
==
"Compact"
,
self
.
createGui
(
self
.
settings
.
uimode
==
"Compact"
,
self
.
settings
.
controlsmode
==
"Mini"
)
self
.
settings
.
controlsmode
==
"Mini"
)
# Finalize
if
self
.
online
:
self
.
gui_set_connected
()
if
self
.
ui_ready
:
if
self
.
ui_ready
:
self
.
logbox
.
SetValue
(
logcontent
)
temppanel
.
Destroy
()
self
.
panel
.
Layout
()
self
.
panel
.
Layout
()
self
.
ui_ready
=
True
self
.
ui_ready
=
True
self
.
Thaw
()
self
.
Thaw
()
...
@@ -340,12 +359,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -340,12 +359,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if
hasattr
(
self
,
"extrudersel"
):
if
hasattr
(
self
,
"extrudersel"
):
self
.
do_tool
(
self
.
extrudersel
.
GetValue
())
self
.
do_tool
(
self
.
extrudersel
.
GetValue
())
for
i
in
self
.
printerControls
:
self
.
gui_set_connected
()
i
.
Enable
()
# Enable XYButtons and ZButtons
self
.
xyb
.
enable
()
self
.
zb
.
enable
()
if
self
.
filename
:
if
self
.
filename
:
self
.
printbtn
.
Enable
()
self
.
printbtn
.
Enable
()
...
@@ -1919,15 +1933,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
...
@@ -1919,15 +1933,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
wx
.
CallAfter
(
self
.
connectbtn
.
SetToolTip
,
wx
.
ToolTip
(
_
(
"Connect to the printer"
)))
wx
.
CallAfter
(
self
.
connectbtn
.
SetToolTip
,
wx
.
ToolTip
(
_
(
"Connect to the printer"
)))
wx
.
CallAfter
(
self
.
connectbtn
.
Bind
,
wx
.
EVT_BUTTON
,
self
.
connect
)
wx
.
CallAfter
(
self
.
connectbtn
.
Bind
,
wx
.
EVT_BUTTON
,
self
.
connect
)
wx
.
CallAfter
(
self
.
printbtn
.
Disable
)
wx
.
CallAfter
(
self
.
gui_set_disconnected
)
wx
.
CallAfter
(
self
.
pausebtn
.
Disable
)
wx
.
CallAfter
(
self
.
recoverbtn
.
Disable
)
for
i
in
self
.
printerControls
:
wx
.
CallAfter
(
i
.
Disable
)
# Disable XYButtons and ZButtons
wx
.
CallAfter
(
self
.
xyb
.
disable
)
wx
.
CallAfter
(
self
.
zb
.
disable
)
if
self
.
paused
:
if
self
.
paused
:
self
.
p
.
paused
=
0
self
.
p
.
paused
=
0
...
...
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