Skip to content

Commit

Permalink
Merge pull request #590 from thormj/ClearGCode
Browse files Browse the repository at this point in the history
Added a button and code to clear gcode.
  • Loading branch information
BarbourSmith authored Jan 24, 2018
2 parents db3de95 + b1ade05 commit a2972b4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions UIElements/gcodeCanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def reloadGcode(self, *args):
'''

filename = self.data.gcodeFile
if filename is "": #Blank the g-code if we're loading "nothing"
self.data.gcode = ""
return

try:
filterfile = open(filename, 'r')
rawfilters = filterfile.read()
Expand Down Expand Up @@ -152,8 +156,7 @@ def reloadGcode(self, *args):
else:
self.data.zMoves.append(index)
except:
if filename is not "":
self.data.message_queue.put("Message: Cannot reopen gcode file. It may have been moved or deleted. To locate it or open a different file use Actions > Open G-code")
self.data.message_queue.put("Message: Cannot reopen gcode file. It may have been moved or deleted. To locate it or open a different file use Actions > Open G-code")
self.data.gcodeFile = ""

def centerCanvas(self, *args):
Expand Down
11 changes: 11 additions & 0 deletions UIElements/viewMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ def openFile(self):
size_hint=(0.9, 0.9))
self._popup.open()

def clear_gcode(self):
'''
Clear gcode
'''
self.data.gcodeFile = ""

#close the parent popup
self.parentWidget.close()

def reloadGcode(self):
'''
Expand Down
4 changes: 4 additions & 0 deletions groundcontrol.kv
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@
text: 'View Gcode'
disabled: False
on_press: root.show_gcode()
Button:
text: 'Clear Gcode'
disabled: False
on_press: root.clear_gcode()
Button:
text: 'Reset View'
disabled: False
Expand Down

0 comments on commit a2972b4

Please sign in to comment.