Skip to content

Commit

Permalink
Merge pull request vlachoudis#810 from buschhardt/commenteditor
Browse files Browse the repository at this point in the history
comment uncomment rows added
  • Loading branch information
vlachoudis authored May 4, 2018
2 parents bef3b01 + 6b468a5 commit 6373845
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions CNCList.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from CNC import Tab, Block, CNC
import tkExtra
import re
#import tkDialogs

BLOCK_COLOR = "LightYellow"
Expand Down Expand Up @@ -661,6 +662,28 @@ def toggleEnable(self, event=None):
self._toggleEnable()
self.winfo_toplevel().event_generate("<<Status>>",data="Toggled Visibility of selected objects")

# ----------------------------------------------------------------------
# comment uncomment row
# ----------------------------------------------------------------------
def commentRow(self, event=None):
if not self._items: return
all_items = self._items
sel_items = list(map(int,self.curselection()))
mreg = re.compile("^\((.*)\)$")
change = False
for i in sel_items:
my_item = all_items[i]
if my_item[1] is not None:
change = True
#check for ()
line = self.gcode[my_item[0]][my_item[1]]
m = mreg.search(line)
if m is None:
self.gcode[my_item[0]][my_item[1]] = "("+line+")"
else:
self.gcode[my_item[0]][my_item[1]] = m.group(1)
if change: self.fill()

# ----------------------------------------------------------------------
# change color of a block
# ----------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions EditorPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,11 @@ def __init__(self, master, app):

# ---
row += 1
b = Ribbon.LabelButton(self.frame,
b = Ribbon.LabelButton(self.frame, self.app, "<<Comment>>",
image=Utils.icons["comment"],
text=_("Comment"),
compound=LEFT,
anchor=W,
state=DISABLED,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, columnspan=2, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("(Un)Comment selected lines"))
Expand Down
1 change: 1 addition & 0 deletions bCNC.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def __init__(self, master, **kw):
self.bind('<<Enable>>', self.editor.enable)
self.bind('<<Disable>>', self.editor.disable)
self.bind('<<ChangeColor>>', self.editor.changeColor)
self.bind('<<Comment>>', self.editor.commentRow)

# Canvas X-bindings
self.bind("<<ViewChange>>", self.viewChange)
Expand Down

0 comments on commit 6373845

Please sign in to comment.