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
df051e60
Commit
df051e60
authored
Aug 06, 2011
by
Kliment
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add horrifyingly simple gcode editor
parent
ed20b692
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
13 deletions
+38
-13
pronterface.py
pronterface.py
+38
-13
No files found.
pronterface.py
View file @
df051e60
...
@@ -264,6 +264,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -264,6 +264,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
menustrip
=
wx
.
MenuBar
()
self
.
menustrip
=
wx
.
MenuBar
()
m
=
wx
.
Menu
()
m
=
wx
.
Menu
()
self
.
Bind
(
wx
.
EVT_MENU
,
self
.
loadfile
,
m
.
Append
(
-
1
,
"&Open..."
,
" Opens file"
))
self
.
Bind
(
wx
.
EVT_MENU
,
self
.
loadfile
,
m
.
Append
(
-
1
,
"&Open..."
,
" Opens file"
))
self
.
Bind
(
wx
.
EVT_MENU
,
self
.
do_editgcode
,
m
.
Append
(
-
1
,
"&Edit..."
,
" Edit open file"
))
if
sys
.
platform
!=
'darwin'
:
if
sys
.
platform
!=
'darwin'
:
self
.
Bind
(
wx
.
EVT_MENU
,
lambda
x
:
threading
.
Thread
(
target
=
lambda
:
self
.
do_skein
(
"set"
))
.
start
(),
m
.
Append
(
-
1
,
"SFACT Settings"
,
" Adjust SFACT settings"
))
self
.
Bind
(
wx
.
EVT_MENU
,
lambda
x
:
threading
.
Thread
(
target
=
lambda
:
self
.
do_skein
(
"set"
))
.
start
(),
m
.
Append
(
-
1
,
"SFACT Settings"
,
" Adjust SFACT settings"
))
try
:
try
:
...
@@ -283,6 +284,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -283,6 +284,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
update_macros_menu
()
self
.
update_macros_menu
()
self
.
SetMenuBar
(
self
.
menustrip
)
self
.
SetMenuBar
(
self
.
menustrip
)
def
doneediting
(
self
,
gcode
):
f
=
open
(
self
.
filename
,
"w"
)
f
.
write
(
"
\n
"
.
join
(
gcode
))
f
.
close
()
wx
.
CallAfter
(
self
.
loadfile
,
None
,
self
.
filename
)
def
do_editgcode
(
self
,
e
=
None
):
if
(
self
.
filename
is
not
None
):
macroed
(
self
.
filename
,
self
.
f
,
self
.
doneediting
,
1
)
def
new_macro
(
self
,
e
=
None
):
def
new_macro
(
self
,
e
=
None
):
dialog
=
wx
.
Dialog
(
self
,
-
1
,
"Enter macro name"
,
size
=
(
200
,
100
))
dialog
=
wx
.
Dialog
(
self
,
-
1
,
"Enter macro name"
,
size
=
(
200
,
100
))
panel
=
wx
.
Panel
(
dialog
,
-
1
)
panel
=
wx
.
Panel
(
dialog
,
-
1
)
...
@@ -956,7 +968,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -956,7 +968,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
thread
(
target
=
self
.
skein_func
)
.
start
()
thread
(
target
=
self
.
skein_func
)
.
start
()
thread
(
target
=
self
.
skein_monitor
)
.
start
()
thread
(
target
=
self
.
skein_monitor
)
.
start
()
def
loadfile
(
self
,
event
):
def
loadfile
(
self
,
event
,
filename
=
None
):
basedir
=
self
.
settings
.
last_file_path
basedir
=
self
.
settings
.
last_file_path
if
not
os
.
path
.
exists
(
basedir
):
if
not
os
.
path
.
exists
(
basedir
):
basedir
=
"."
basedir
=
"."
...
@@ -966,7 +978,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -966,7 +978,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
pass
pass
dlg
=
wx
.
FileDialog
(
self
,
"Open file to print"
,
basedir
,
style
=
wx
.
FD_OPEN
|
wx
.
FD_FILE_MUST_EXIST
)
dlg
=
wx
.
FileDialog
(
self
,
"Open file to print"
,
basedir
,
style
=
wx
.
FD_OPEN
|
wx
.
FD_FILE_MUST_EXIST
)
dlg
.
SetWildcard
(
"STL and GCODE files (;*.gcode;*.g;*.stl;*.STL;)"
)
dlg
.
SetWildcard
(
"STL and GCODE files (;*.gcode;*.g;*.stl;*.STL;)"
)
if
(
dlg
.
ShowModal
()
==
wx
.
ID_OK
):
if
(
filename
is
not
None
or
dlg
.
ShowModal
()
==
wx
.
ID_OK
):
if
filename
is
not
None
:
name
=
filename
else
:
name
=
dlg
.
GetPath
()
name
=
dlg
.
GetPath
()
if
not
(
os
.
path
.
exists
(
name
)):
if
not
(
os
.
path
.
exists
(
name
)):
self
.
status
.
SetStatusText
(
"File not found!"
)
self
.
status
.
SetStatusText
(
"File not found!"
)
...
@@ -1136,13 +1151,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -1136,13 +1151,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
class
macroed
(
wx
.
Dialog
):
class
macroed
(
wx
.
Dialog
):
"""Really simple editor to edit macro definitions"""
"""Really simple editor to edit macro definitions"""
def
__init__
(
self
,
macro_name
,
definition
,
callback
):
def
__init__
(
self
,
macro_name
,
definition
,
callback
,
gcode
=
False
):
self
.
indent_chars
=
" "
self
.
indent_chars
=
" "
wx
.
Dialog
.
__init__
(
self
,
None
,
title
=
"macro
%
s"
%
macro_name
,
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
RESIZE_BORDER
)
title
=
" macro
%
s"
if
gcode
:
title
=
"
%
s"
self
.
gcode
=
gcode
wx
.
Dialog
.
__init__
(
self
,
None
,
title
=
title
%
macro_name
,
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
RESIZE_BORDER
)
self
.
callback
=
callback
self
.
callback
=
callback
self
.
panel
=
wx
.
Panel
(
self
,
-
1
)
self
.
panel
=
wx
.
Panel
(
self
,
-
1
)
titlesizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
titlesizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
title
=
wx
.
StaticText
(
self
.
panel
,
-
1
,
" macro
%
s: "
%
macro_name
)
title
=
wx
.
StaticText
(
self
.
panel
,
-
1
,
title
%
macro_name
)
title
.
SetFont
(
wx
.
Font
(
11
,
wx
.
NORMAL
,
wx
.
NORMAL
,
wx
.
BOLD
))
title
.
SetFont
(
wx
.
Font
(
11
,
wx
.
NORMAL
,
wx
.
NORMAL
,
wx
.
BOLD
))
titlesizer
.
Add
(
title
,
1
)
titlesizer
.
Add
(
title
,
1
)
self
.
okb
=
wx
.
Button
(
self
.
panel
,
-
1
,
"Save"
)
self
.
okb
=
wx
.
Button
(
self
.
panel
,
-
1
,
"Save"
)
...
@@ -1154,7 +1173,10 @@ class macroed(wx.Dialog):
...
@@ -1154,7 +1173,10 @@ class macroed(wx.Dialog):
topsizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
topsizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
topsizer
.
Add
(
titlesizer
,
0
,
wx
.
EXPAND
)
topsizer
.
Add
(
titlesizer
,
0
,
wx
.
EXPAND
)
self
.
e
=
wx
.
TextCtrl
(
self
.
panel
,
style
=
wx
.
TE_MULTILINE
+
wx
.
HSCROLL
,
size
=
(
200
,
200
))
self
.
e
=
wx
.
TextCtrl
(
self
.
panel
,
style
=
wx
.
TE_MULTILINE
+
wx
.
HSCROLL
,
size
=
(
200
,
200
))
if
not
self
.
gcode
:
self
.
e
.
SetValue
(
self
.
unindent
(
definition
))
self
.
e
.
SetValue
(
self
.
unindent
(
definition
))
else
:
self
.
e
.
SetValue
(
"
\n
"
.
join
(
definition
))
topsizer
.
Add
(
self
.
e
,
1
,
wx
.
ALL
+
wx
.
EXPAND
)
topsizer
.
Add
(
self
.
e
,
1
,
wx
.
ALL
+
wx
.
EXPAND
)
self
.
panel
.
SetSizer
(
topsizer
)
self
.
panel
.
SetSizer
(
topsizer
)
topsizer
.
Layout
()
topsizer
.
Layout
()
...
@@ -1163,7 +1185,10 @@ class macroed(wx.Dialog):
...
@@ -1163,7 +1185,10 @@ class macroed(wx.Dialog):
self
.
e
.
SetFocus
()
self
.
e
.
SetFocus
()
def
save
(
self
,
ev
):
def
save
(
self
,
ev
):
self
.
Destroy
()
self
.
Destroy
()
if
not
self
.
gcode
:
self
.
callback
(
self
.
reindent
(
self
.
e
.
GetValue
()))
self
.
callback
(
self
.
reindent
(
self
.
e
.
GetValue
()))
else
:
self
.
callback
(
self
.
e
.
GetValue
()
.
split
(
"
\n
"
))
def
close
(
self
,
ev
):
def
close
(
self
,
ev
):
self
.
Destroy
()
self
.
Destroy
()
def
unindent
(
self
,
text
):
def
unindent
(
self
,
text
):
...
...
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