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
d08bc641
Commit
d08bc641
authored
Jul 06, 2011
by
Keegi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple small GUI editor for macros in pronterface
parent
8ca085a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
7 deletions
+58
-7
pronsole.py
pronsole.py
+13
-7
pronterface.py
pronterface.py
+45
-0
No files found.
pronsole.py
View file @
d08bc641
...
...
@@ -182,6 +182,15 @@ class pronsole(cmd.Cmd):
print
"Empty macro - cancelled"
del
self
.
cur_macro
,
self
.
cur_macro_name
,
self
.
cur_macro_def
def
start_macro
(
self
,
macro_name
,
prev_definition
=
""
):
if
not
self
.
processing_rc
:
print
"Enter macro using indented lines, end with empty line"
self
.
cur_macro_name
=
macro_name
self
.
cur_macro_def
=
""
self
.
cur_macro
=
"def macro(self,*arg):
\n
"
self
.
onecmd
=
self
.
hook_macro
# override onecmd temporarily
self
.
prompt
=
"..>"
def
do_macro
(
self
,
args
):
if
args
.
strip
()
==
""
:
self
.
print_topics
(
"User-defined macros"
,
self
.
macros
.
keys
(),
15
,
80
)
...
...
@@ -214,13 +223,10 @@ class pronsole(cmd.Cmd):
self
.
cur_macro
=
"def macro(self,*arg):
\n
self.onecmd('"
+
macro_def
+
"'.format(*arg))
\n
"
self
.
end_macro
()
return
if
not
self
.
processing_rc
:
print
"Enter macro using indented lines, end with empty line"
self
.
cur_macro_name
=
macro_name
self
.
cur_macro_def
=
""
self
.
cur_macro
=
"def macro(self,*arg):
\n
"
self
.
onecmd
=
self
.
hook_macro
# override onecmd temporarily
self
.
prompt
=
"..>"
if
self
.
macros
.
has_key
(
macro_name
):
self
.
start_macro
(
macro_name
,
self
.
macros
[
macro_name
])
else
:
self
.
start_macro
(
macro_name
)
def
help_macro
(
self
):
print
"Define single-line macro: macro <name> <definition>"
...
...
pronterface.py
View file @
d08bc641
...
...
@@ -172,6 +172,19 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
except
:
print
"You must enter a temperature."
def
start_macro
(
self
,
macro_name
,
old_macro_definition
=
""
):
if
not
self
.
processing_rc
:
import
macroed
def
cb
(
definition
):
pronsole
.
pronsole
.
start_macro
(
self
,
macro_name
)
for
line
in
definition
.
split
(
"
\n
"
):
if
hasattr
(
self
,
"cur_macro_def"
):
self
.
hook_macro
(
line
)
if
hasattr
(
self
,
"cur_macro_def"
):
self
.
end_macro
()
macroed
.
macroed
(
macro_name
,
old_macro_definition
,
cb
)
else
:
pronsole
.
pronsole
.
start_macro
(
self
,
macro_name
,
old_macro_definition
)
def
catchprint
(
self
,
l
):
wx
.
CallAfter
(
self
.
logbox
.
AppendText
,
l
)
...
...
@@ -786,6 +799,38 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
printbtn
.
SetLabel
(
"Print"
)
self
.
paused
=
0
class
macroed
(
wx
.
Frame
):
"""Really simple editor to edit macro definitions"""
def
__init__
(
self
,
macro_name
,
definition
,
callback
):
# TBD: remove top-level indent from the definition (if any)
wx
.
Frame
.
__init__
(
self
,
None
,
title
=
"macro
%
s"
%
macro_name
)
self
.
callback
=
callback
self
.
panel
=
wx
.
Panel
(
self
,
-
1
)
titlesizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
title
=
wx
.
StaticText
(
self
.
panel
,
-
1
,
" macro
%
s: "
%
macro_name
)
title
.
SetFont
(
wx
.
Font
(
11
,
wx
.
NORMAL
,
wx
.
NORMAL
,
wx
.
BOLD
))
titlesizer
.
Add
(
title
,
1
)
self
.
okb
=
wx
.
Button
(
self
.
panel
,
-
1
,
"Save"
)
self
.
okb
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
save
)
titlesizer
.
Add
(
self
.
okb
)
self
.
cancelb
=
wx
.
Button
(
self
.
panel
,
-
1
,
"Cancel"
)
self
.
cancelb
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
close
)
titlesizer
.
Add
(
self
.
cancelb
)
topsizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
topsizer
.
Add
(
titlesizer
,
0
,
wx
.
EXPAND
)
self
.
e
=
wx
.
TextCtrl
(
self
.
panel
,
style
=
wx
.
TE_MULTILINE
+
wx
.
HSCROLL
,
size
=
(
200
,
200
))
self
.
e
.
SetValue
(
definition
)
topsizer
.
Add
(
self
.
e
,
1
,
wx
.
ALL
+
wx
.
EXPAND
)
self
.
panel
.
SetSizer
(
topsizer
)
topsizer
.
Layout
()
topsizer
.
Fit
(
self
)
self
.
Show
()
def
save
(
self
,
ev
):
self
.
Close
()
# TBD: add back top-level indent unless single line.
self
.
callback
(
self
.
e
.
GetValue
())
def
close
(
self
,
ev
):
self
.
Close
()
if
__name__
==
'__main__'
:
...
...
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