| 1 |
# -*- coding: ascii -*- |
| 2 |
# $Id: CNCEditor.py,v 1.9 2014/10/15 15:04:38 bnv Exp $ |
| 3 |
# |
| 4 |
# Author: [email protected] |
| 5 |
# Date: 24-Aug-2014 |
| 6 |
|
| 7 |
from __future__scip-python python python-stdlib 3.11 __future__/__init__: import print_functionscip-python python python-stdlib 3.11 __future__/print_function.print_function. |
| 8 |
from __future__scip-python python python-stdlib 3.11 __future__/__init__: import absolute_importscip-python python python-stdlib 3.11 __future__/absolute_import.absolute_import. |
| 9 |
try: |
| 10 |
from cStringIOscip-python python bCNC 0.9.14.318 cStringIO/__init__: import StringIO |
| 11 |
except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 12 |
from ioscip-python python python-stdlib 3.11 io/__init__: import StringIO |
| 13 |
try: |
| 14 |
import cPickle as pickle |
| 15 |
except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 16 |
import picklescip-python python python-stdlib 3.11 pickle/__init__: |
| 17 |
try: |
| 18 |
from Tkinterscip-python python bCNC 0.9.14.318 Tkinter/__init__: import * |
| 19 |
import tkFont |
| 20 |
except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 21 |
from tkinterscip-python python python-stdlib 3.11 tkinter/__init__: import * |
| 22 |
import tkinter.fontscip-python python python-stdlib 3.11 `tkinter.font`/__init__: as tkFont |
| 23 |
|
| 24 |
from CNCscip-python python bCNC 0.9.14.318 CNC/__init__: import Blockscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#, CNCscip-python python bCNC 0.9.14.318 `bCNC.CNC`/CNC# |
| 25 |
import tkExtra |
| 26 |
import rescip-python python python-stdlib 3.11 re/__init__: |
| 27 |
import jsonscip-python python python-stdlib 3.11 json/__init__: |
| 28 |
#import tkDialogs |
| 29 |
|
| 30 |
BLOCK_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/BLOCK_COLOR. = "LightYellow" |
| 31 |
COMMENT_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/COMMENT_COLOR. = "Blue" |
| 32 |
DISABLE_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/DISABLE_COLOR. = "Gray" |
| 33 |
from CNCCanvasscip-python python bCNC 0.9.14.318 CNCCanvas/__init__: import TAB_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCCanvas`/TAB_COLOR. |
| 34 |
|
| 35 |
MAXINTscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/MAXINT. = 1000000000 # python3 doesn't have maxint |
| 36 |
|
| 37 |
|
| 38 |
#============================================================================== |
| 39 |
# CNC Listbox |
| 40 |
#============================================================================== |
| 41 |
class CNCListboxscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#(Listboxscip-python python python-stdlib 3.11 tkinter/__init__:): |
| 42 |
def __init__scip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self), masterscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(master), appscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(app), *kwscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(kw), **kwargsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(kwargs)): |
| 43 |
Listboxscip-python python python-stdlib 3.11 tkinter/__init__:.__init__scip-python python python-stdlib 3.11 tkinter/Listbox#__init__().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self), masterscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(master), *kwscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(kw), **kwargsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(kwargs)) |
| 44 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Button-1>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).button1scip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().) |
| 45 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<ButtonRelease-1>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).release1scip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().) |
| 46 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Double-1>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().) |
| 47 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Return>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).editscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().) |
| 48 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<KP_Enter>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).editscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().) |
| 49 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Insert>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).insertItemscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().) |
| 50 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-Return>",selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).insertItemscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().) |
| 51 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-space>",selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).commandFocusscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commandFocus().) |
| 52 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Left>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).toggleKeyscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().) |
| 53 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Right>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).toggleKeyscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().) |
| 54 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-d>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).clonescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().) |
| 55 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-Up>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).orderUpscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().) |
| 56 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-Prior>",selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).orderUpscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().) |
| 57 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-Down>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).orderDownscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().) |
| 58 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-Next>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).orderDownscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().) |
| 59 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-p>", lambda e : "break") |
| 60 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-n>", lambda e : "break") |
| 61 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-D>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).dumpscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#dump().) |
| 62 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Delete>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).deleteBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().) |
| 63 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<BackSpace>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).deleteBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().) |
| 64 |
try: |
| 65 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<KP_Delete>",selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).deleteBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().) |
| 66 |
except: |
| 67 |
pass |
| 68 |
|
| 69 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-b>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).insertBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().) |
| 70 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).bind("<Control-Key-r>", selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().) |
| 71 |
|
| 72 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos. = [] # listbox position of each block |
| 73 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items. = [] # each listbox lien which item (bid,lid) shows |
| 74 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).appscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#app. = appscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(app) |
| 75 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode. = appscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(app).gcode |
| 76 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).fontscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#font. = tkFont.nametofont(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).cget("font")) |
| 77 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self)._ystartscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_ystart. = 0 |
| 78 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self)._doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_double. = False # double clicked handled |
| 79 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self)._hadfocusscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_hadfocus. = False |
| 80 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#__init__().(self).filterscip-python python python-stdlib 3.11 builtins/filter# = None |
| 81 |
|
| 82 |
# ---------------------------------------------------------------------- |
| 83 |
def commandFocusscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commandFocus().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commandFocus().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commandFocus().(event)=None): |
| 84 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commandFocus().(self).appscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#app..commandFocus(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commandFocus().(event)) |
| 85 |
return "break" |
| 86 |
|
| 87 |
# ---------------------------------------------------------------------- |
| 88 |
# Change the value of a list item |
| 89 |
# and return the value of the old one |
| 90 |
# ---------------------------------------------------------------------- |
| 91 |
def setscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(self), indexscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(index), valuescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(value)): |
| 92 |
"""Set/Change the value of a list item""" |
| 93 |
try: |
| 94 |
sel = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(self).selection_includes(indexscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(index)) |
| 95 |
act = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 96 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(self).delete(indexscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(index)) |
| 97 |
except TclErrorscip-python python python-stdlib 3.11 tkinter/__init__:: |
| 98 |
return |
| 99 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(self).insert(indexscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(index), valuescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(value)) |
| 100 |
if sel: selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(self).selection_set(indexscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(index)) |
| 101 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(self).activate(act) |
| 102 |
|
| 103 |
# ---------------------------------------------------------------------- |
| 104 |
# Fill listbox with enable items |
| 105 |
# ---------------------------------------------------------------------- |
| 106 |
def fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(event)=None): |
| 107 |
ypos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).yview()[0] |
| 108 |
act = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 109 |
|
| 110 |
#sel = self.curselection() |
| 111 |
items = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).getSelectionscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelection().() |
| 112 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).delete(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 113 |
|
| 114 |
del selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[:] |
| 115 |
del selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[:] |
| 116 |
y = 0 |
| 117 |
for bi,block in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks): |
| 118 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).filterscip-python python python-stdlib 3.11 builtins/filter# is not None: |
| 119 |
if not (selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).filterscip-python python python-stdlib 3.11 builtins/filter# in block.name() or \ |
| 120 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).filterscip-python python python-stdlib 3.11 builtins/filter#=="enable" and block.enable or |
| 121 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).filterscip-python python python-stdlib 3.11 builtins/filter#=="disable" and not block.enable): |
| 122 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos..appendscip-python python python-stdlib 3.11 builtins/list#append().(None) |
| 123 |
continue |
| 124 |
|
| 125 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos..appendscip-python python python-stdlib 3.11 builtins/list#append().(y) |
| 126 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).insert(ENDscip-python python python-stdlib 3.11 tkinter/__init__:, block.header()) |
| 127 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items..appendscip-python python python-stdlib 3.11 builtins/list#append().((bi, None)) |
| 128 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).itemconfig(ENDscip-python python python-stdlib 3.11 tkinter/__init__:, background=BLOCK_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/BLOCK_COLOR.) |
| 129 |
y += 1 |
| 130 |
if not block.enable: |
| 131 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).itemconfig(ENDscip-python python python-stdlib 3.11 tkinter/__init__:, foreground=DISABLE_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/DISABLE_COLOR.) |
| 132 |
if not block.expand: continue |
| 133 |
|
| 134 |
for lj,line in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(block): |
| 135 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).insert(ENDscip-python python python-stdlib 3.11 tkinter/__init__:, line) |
| 136 |
y += 1 |
| 137 |
if line and line[0] in ("(","%"): |
| 138 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).itemconfig(ENDscip-python python python-stdlib 3.11 tkinter/__init__:, foreground=COMMENT_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/COMMENT_COLOR.) |
| 139 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items..appendscip-python python python-stdlib 3.11 builtins/list#append().((bi, lj)) |
| 140 |
|
| 141 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).selectscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(items) |
| 142 |
#for i in sel: self.selection_set(i) |
| 143 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).yview_moveto(ypos) |
| 144 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).activate(act) |
| 145 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().(self).see(act) |
| 146 |
|
| 147 |
# ---------------------------------------------------------------------- |
| 148 |
# Copy selected items to clipboard |
| 149 |
# ---------------------------------------------------------------------- |
| 150 |
def copyscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().(event)=None): |
| 151 |
jsonobj=[] |
| 152 |
for block,line in selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().(self).getCleanSelectionscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getCleanSelection().(): |
| 153 |
if line is None: |
| 154 |
jsonobj.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks[block].dump()) |
| 155 |
else: |
| 156 |
jsonobj.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks[block][line]) |
| 157 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().(self).clipboard_clear() |
| 158 |
jsonstring=jsonscip-python python python-stdlib 3.11 json/__init__:.dumpsscip-python python python-stdlib 3.11 json/dumps().(jsonobj) |
| 159 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().(self).clipboard_append(jsonstring) |
| 160 |
return "break" |
| 161 |
# ---------------------------------------------------------------------- |
| 162 |
def cutscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#cut().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#cut().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#cut().(event)=None): |
| 163 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#cut().(self).copyscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#copy().() |
| 164 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#cut().(self).deleteBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().() |
| 165 |
return "break" |
| 166 |
|
| 167 |
# ---------------------------------------------------------------------- |
| 168 |
def pastescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(event)=None): |
| 169 |
try: clipboard = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).selection_get(selection='CLIPBOARD') |
| 170 |
except: return |
| 171 |
|
| 172 |
ypos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).yview()[0] |
| 173 |
# paste them after the last selected item |
| 174 |
# bid,lid push them to self so it can be accessed from addLines() |
| 175 |
# python3 might fix this with the inner scope |
| 176 |
try: |
| 177 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid., selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).curselection()[-1]] |
| 178 |
except: |
| 179 |
try: |
| 180 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid., selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[-1] |
| 181 |
except: |
| 182 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid. = 0 |
| 183 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. = None |
| 184 |
|
| 185 |
selitems = [] |
| 186 |
undoinfo = [] |
| 187 |
|
| 188 |
def addLinesscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#addLines().(linesscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#addLines().(lines)): |
| 189 |
for line in linesscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#addLines().(lines).splitlines(): |
| 190 |
# Create a new block |
| 191 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. is None: |
| 192 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid. += 1 |
| 193 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid. > len(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks): |
| 194 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid. = len(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks) |
| 195 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. = MAXINTscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/MAXINT. |
| 196 |
block = Blockscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#() |
| 197 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addBlockUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid.,block)) |
| 198 |
selitems.appendscip-python python python-stdlib 3.11 builtins/list#append().((selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid., None)) |
| 199 |
else: |
| 200 |
block = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks[selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid.] |
| 201 |
|
| 202 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. == MAXINTscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/MAXINT.: |
| 203 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. = len(block) |
| 204 |
selitems.appendscip-python python python-stdlib 3.11 builtins/list#append().((selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid., len(block))) |
| 205 |
else: |
| 206 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. += 1 |
| 207 |
selitems.appendscip-python python python-stdlib 3.11 builtins/list#append().((selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid., selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid.)) |
| 208 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..insLineUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid., selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid., line)) |
| 209 |
try : |
| 210 |
objs = jsonscip-python python python-stdlib 3.11 json/__init__:.loadsscip-python python python-stdlib 3.11 json/loads().(clipboard) |
| 211 |
except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as e: |
| 212 |
objs = [clipboard] |
| 213 |
for obj in objs: |
| 214 |
if isinstance(obj,listscip-python python python-stdlib 3.11 builtins/list#): |
| 215 |
obj =tuplescip-python python python-stdlib 3.11 builtins/tuple#(obj) |
| 216 |
if isinstance(obj,tuplescip-python python python-stdlib 3.11 builtins/tuple#): |
| 217 |
block = Blockscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#.loadscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#load().(obj) |
| 218 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid. += 1 |
| 219 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addBlockUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid., block)) |
| 220 |
selitems.appendscip-python python python-stdlib 3.11 builtins/list#append().((selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_bid.,None)) |
| 221 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self)._lidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_lid. = None |
| 222 |
else: |
| 223 |
addLinesscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#addLines().(obj) |
| 224 |
if not undoinfo: return |
| 225 |
|
| 226 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(undoinfo) |
| 227 |
|
| 228 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 229 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 230 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).yview_moveto(ypos) |
| 231 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).selectscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(selitems, clearscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(clear)=True) |
| 232 |
|
| 233 |
#self.selection_set(ACTIVE) |
| 234 |
#self.see(ACTIVE) |
| 235 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#paste().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 236 |
|
| 237 |
# ---------------------------------------------------------------------- |
| 238 |
# Clone selected blocks |
| 239 |
# ---------------------------------------------------------------------- |
| 240 |
def clonescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(event)=None): |
| 241 |
sel = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(intscip-python python python-stdlib 3.11 builtins/int#,selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).curselection())) |
| 242 |
if not sel: return |
| 243 |
|
| 244 |
ypos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).yview()[0] |
| 245 |
undoinfo = [] |
| 246 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 247 |
pos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[sel[-1]][0]+1 |
| 248 |
blocks = [] |
| 249 |
for i in reversedscip-python python python-stdlib 3.11 builtins/reversed#(sel): |
| 250 |
bid, lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[i] |
| 251 |
if lid is None: |
| 252 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..cloneBlockUndo(bid, pos)) |
| 253 |
for i in rangescip-python python python-stdlib 3.11 builtins/range#(len(blocks)): blocks[i] += 1 |
| 254 |
blocks.appendscip-python python python-stdlib 3.11 builtins/list#append().(pos) |
| 255 |
else: |
| 256 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..cloneLineUndo(bid, lid)) |
| 257 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(undoinfo) |
| 258 |
|
| 259 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 260 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).yview_moveto(ypos) |
| 261 |
if blocks: |
| 262 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).selectBlocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlocks().(blocks) |
| 263 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).activate(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[blocks[-1]]) |
| 264 |
else: |
| 265 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).selection_set(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 266 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).see(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 267 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#clone().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 268 |
return "break" |
| 269 |
|
| 270 |
# ---------------------------------------------------------------------- |
| 271 |
# Delete selected blocks of code |
| 272 |
# ---------------------------------------------------------------------- |
| 273 |
def deleteBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(event)=None): |
| 274 |
sel = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(intscip-python python python-stdlib 3.11 builtins/int#,selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).curselection())) |
| 275 |
if not sel: return |
| 276 |
|
| 277 |
ypos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).yview()[0] |
| 278 |
undoinfo = [] |
| 279 |
for i in reversedscip-python python python-stdlib 3.11 builtins/reversed#(sel): |
| 280 |
bid, lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[i] |
| 281 |
if isinstance(lid,intscip-python python python-stdlib 3.11 builtins/int#): |
| 282 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..delLineUndo(bid, lid)) |
| 283 |
else: |
| 284 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..delBlockUndo(bid)) |
| 285 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(undoinfo) |
| 286 |
|
| 287 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 288 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 289 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).yview_moveto(ypos) |
| 290 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).selection_set(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 291 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).see(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 292 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 293 |
|
| 294 |
# ---------------------------------------------------------------------- |
| 295 |
# Edit active item |
| 296 |
# ---------------------------------------------------------------------- |
| 297 |
def editscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(event)=None): |
| 298 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 299 |
txt = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).get(active) |
| 300 |
if eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(event): |
| 301 |
x = eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(event).x |
| 302 |
else: |
| 303 |
x = 0 |
| 304 |
|
| 305 |
ypos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).yview()[0] |
| 306 |
bid, lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[active] |
| 307 |
if lid is None: |
| 308 |
txt0 = txt |
| 309 |
txt = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].name() |
| 310 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).setscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(active, txt) |
| 311 |
edit = tkExtra.InPlaceEdit(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self), select=False, bg=selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).cget("bg")) |
| 312 |
else: |
| 313 |
edit = tkExtra.InPlaceEdit(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self),x=x, select=False, bg=selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).cget("bg")) |
| 314 |
|
| 315 |
if edit.value is None or edit.value==txt: |
| 316 |
if lid is None: |
| 317 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).setscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(active,txt0) |
| 318 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).itemconfig(active, background=BLOCK_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/BLOCK_COLOR.) |
| 319 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].enable: |
| 320 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).itemconfig(active, foreground=DISABLE_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/DISABLE_COLOR.) |
| 321 |
return |
| 322 |
|
| 323 |
if isinstance(lid,intscip-python python python-stdlib 3.11 builtins/int#): |
| 324 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..setLineUndo(bid, lid, edit.value)) |
| 325 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).setscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(active, edit.value) |
| 326 |
if edit.value and edit.value[0] in ("(","%"): |
| 327 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).itemconfig(active, foreground=COMMENT_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/COMMENT_COLOR.) |
| 328 |
|
| 329 |
else: |
| 330 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..setBlockNameUndo(bid, edit.value)) |
| 331 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).setscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#set().(active, selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].header()) |
| 332 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).itemconfig(active, background=BLOCK_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/BLOCK_COLOR.) |
| 333 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].enable: |
| 334 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).itemconfig(active, foreground=DISABLE_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/DISABLE_COLOR.) |
| 335 |
|
| 336 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).yview_moveto(ypos) |
| 337 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 338 |
|
| 339 |
# ---------------------------------------------------------------------- |
| 340 |
# return active block id |
| 341 |
# ---------------------------------------------------------------------- |
| 342 |
def activeBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#activeBlock().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#activeBlock().(self)): |
| 343 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#activeBlock().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 344 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#activeBlock().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: |
| 345 |
bid, lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#activeBlock().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[active] |
| 346 |
else: |
| 347 |
bid = 0 |
| 348 |
return bid |
| 349 |
|
| 350 |
# ---------------------------------------------------------------------- |
| 351 |
# Insert a line or a block |
| 352 |
# ---------------------------------------------------------------------- |
| 353 |
def insertItemscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().(event)=None): |
| 354 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 355 |
if active is None: return |
| 356 |
if len(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.)==0 or selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[active][1] is None: |
| 357 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().(self).insertBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().() |
| 358 |
else: |
| 359 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertItem().(self).insertLinescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().() |
| 360 |
|
| 361 |
# ---------------------------------------------------------------------- |
| 362 |
# Insert New Block |
| 363 |
# ---------------------------------------------------------------------- |
| 364 |
def insertBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(event)=None): |
| 365 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 366 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: |
| 367 |
bid, lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[active] |
| 368 |
bid += 1 |
| 369 |
else: |
| 370 |
bid = 0 |
| 371 |
|
| 372 |
block = Blockscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#() |
| 373 |
block.expandscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#expand. = True |
| 374 |
block.appendscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#append().("g0 x0 y0") |
| 375 |
block.appendscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#append().("g1 z0") |
| 376 |
block.appendscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#append().(CNCscip-python python bCNC 0.9.14.318 `bCNC.CNC`/CNC#.zsafescip-python python bCNC 0.9.14.318 `bCNC.CNC`/CNC#zsafe().()) |
| 377 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addBlockUndo(bid,block)) |
| 378 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 379 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 380 |
# find location of new block |
| 381 |
while active < selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).size(): |
| 382 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[active][0] == bid: |
| 383 |
break |
| 384 |
active += 1 |
| 385 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).selection_set(active) |
| 386 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).see(active) |
| 387 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).activate(active) |
| 388 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).editscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().() |
| 389 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 390 |
|
| 391 |
# ---------------------------------------------------------------------- |
| 392 |
# Insert a new line below cursor |
| 393 |
# ---------------------------------------------------------------------- |
| 394 |
def insertLinescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(event)=None): |
| 395 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 396 |
if active is None: return |
| 397 |
if len(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.)==0: |
| 398 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).insertBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertBlock().() |
| 399 |
return |
| 400 |
|
| 401 |
bid, lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[active] |
| 402 |
|
| 403 |
active += 1 |
| 404 |
|
| 405 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).insert(active,"") |
| 406 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 407 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).activate(active) |
| 408 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).selection_set(active) |
| 409 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).see(active) |
| 410 |
|
| 411 |
edit = tkExtra.InPlaceEdit(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self), bg=selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).cget("bg")) |
| 412 |
ypos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).yview()[0] |
| 413 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).delete(active) |
| 414 |
|
| 415 |
if edit.value is None: |
| 416 |
# Cancel and leave |
| 417 |
active -= 1 |
| 418 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).activate(active) |
| 419 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).selection_set(active) |
| 420 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).see(active) |
| 421 |
return |
| 422 |
|
| 423 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).insert(active, edit.value) |
| 424 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).selection_set(active) |
| 425 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).activate(active) |
| 426 |
if edit.value and edit.value[0] in ("(","%"): |
| 427 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).itemconfig(active, foreground=COMMENT_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/COMMENT_COLOR.) |
| 428 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).yview_moveto(ypos) |
| 429 |
|
| 430 |
# Add line into code |
| 431 |
|
| 432 |
# Correct pointers |
| 433 |
if lid is None: |
| 434 |
lid = 0 |
| 435 |
else: |
| 436 |
lid += 1 |
| 437 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..insLineUndo(bid, lid, edit.value)) |
| 438 |
|
| 439 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items..insertscip-python python python-stdlib 3.11 builtins/list#insert().(active, (bid, lid)) |
| 440 |
for i in rangescip-python python python-stdlib 3.11 builtins/range#(active+1,len(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.)): |
| 441 |
b,l = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[i] |
| 442 |
if b != bid: break |
| 443 |
if isinstance(l,intscip-python python python-stdlib 3.11 builtins/int#): |
| 444 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[i] = (b,l+1) |
| 445 |
for i in rangescip-python python python-stdlib 3.11 builtins/range#(bid+1, len(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.)): |
| 446 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[i] is not None: |
| 447 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[i] += 1 # shift all blocks below by one |
| 448 |
|
| 449 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#insertLine().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 450 |
|
| 451 |
# ---------------------------------------------------------------------- |
| 452 |
def toggleKeyscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self),eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(event)=None): |
| 453 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: return |
| 454 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 455 |
bid,lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[active] |
| 456 |
if lid is None: |
| 457 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self).toggleExpandscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().() |
| 458 |
else: |
| 459 |
# Go to header |
| 460 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 461 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self).activate(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bid]) |
| 462 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self).selection_set(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 463 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self).see(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 464 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleKey().(self).winfo_toplevel().event_generate("<<ListboxSelect>>") |
| 465 |
|
| 466 |
# ---------------------------------------------------------------------- |
| 467 |
# Button1 clicked |
| 468 |
# ---------------------------------------------------------------------- |
| 469 |
def button1scip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(event)): |
| 470 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self)._doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_double.: return |
| 471 |
|
| 472 |
# Remember if we had the focus before clicking |
| 473 |
# to be used later in editing |
| 474 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self)._hadfocusscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_hadfocus. = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self).focus_get() == selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self) |
| 475 |
|
| 476 |
# from a single click |
| 477 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self)._ystartscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_ystart. = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self).nearest(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(event).y) |
| 478 |
selected = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self).selection_includes(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self)._ystartscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_ystart.) |
| 479 |
loc = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self)._headerLocationscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(event)) |
| 480 |
if loc is None: |
| 481 |
pass |
| 482 |
elif selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(self)._headerLocationscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#button1().(event))<2 and selected: |
| 483 |
return "break" # do not alter selection! |
| 484 |
|
| 485 |
# ---------------------------------------------------------------------- |
| 486 |
# Release button-1. Warning on separation of double or single click or |
| 487 |
# click and drag |
| 488 |
# ---------------------------------------------------------------------- |
| 489 |
def release1scip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(event)): |
| 490 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: return |
| 491 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self)._doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_double.: |
| 492 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self)._doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_double. = False |
| 493 |
return |
| 494 |
|
| 495 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self)._doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_double. = False |
| 496 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 497 |
|
| 498 |
# from a single click |
| 499 |
y = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self).nearest(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(event).y) |
| 500 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self).activate(y) |
| 501 |
if y != selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self)._ystartscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_ystart.: return |
| 502 |
|
| 503 |
loc = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self)._headerLocationscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(event)) |
| 504 |
if loc is None: |
| 505 |
# Normal line |
| 506 |
if active==y: |
| 507 |
# In place edit if we had already the focus |
| 508 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self)._hadfocusscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_hadfocus.: |
| 509 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self).editscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(event)) |
| 510 |
elif loc == 0: |
| 511 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self).toggleExpandscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().() |
| 512 |
elif loc == 1: |
| 513 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#release1().(self).toggleEnablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleEnable().() |
| 514 |
return "break" |
| 515 |
|
| 516 |
# ---------------------------------------------------------------------- |
| 517 |
def doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().(event)): |
| 518 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().(self)._headerLocationscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().(event)) == 2: |
| 519 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().(self).editscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#edit().() |
| 520 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().(self)._doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_double. = True |
| 521 |
else: |
| 522 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#double().(self)._doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_double. = False |
| 523 |
|
| 524 |
# ---------------------------------------------------------------------- |
| 525 |
# Return location where we clicked on header |
| 526 |
# 0 = expand arrow |
| 527 |
# 1 = enable ballot box |
| 528 |
# 2 = name |
| 529 |
# ---------------------------------------------------------------------- |
| 530 |
def _headerLocationscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(event)): |
| 531 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: return None |
| 532 |
# from a single click |
| 533 |
y = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(self).nearest(eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(event).y) |
| 534 |
|
| 535 |
block,line = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[y] |
| 536 |
if line is not None: return None |
| 537 |
|
| 538 |
txt = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(self).get(y) |
| 539 |
if eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(event).x <= selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(self).fontscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#font..measure(txt[:2]): |
| 540 |
return 0 |
| 541 |
elif eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(event).x <= selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_headerLocation().(self).fontscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#font..measure(txt[:5]): |
| 542 |
return 1 |
| 543 |
else: |
| 544 |
return 2 |
| 545 |
|
| 546 |
# ---------------------------------------------------------------------- |
| 547 |
# Toggle expand selection |
| 548 |
# ---------------------------------------------------------------------- |
| 549 |
def toggleExpandscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(event)=None): |
| 550 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: return None |
| 551 |
items = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(intscip-python python python-stdlib 3.11 builtins/int#,selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).curselection())) |
| 552 |
expand = None |
| 553 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 554 |
bactive,lactive = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[active] |
| 555 |
blocks = [] |
| 556 |
undoinfo = [] |
| 557 |
for i in reversedscip-python python python-stdlib 3.11 builtins/reversed#(items): |
| 558 |
bid,lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[i] |
| 559 |
if lid is not None: |
| 560 |
if bid in blocks: continue |
| 561 |
blocks.appendscip-python python python-stdlib 3.11 builtins/list#append().(bid) |
| 562 |
if expand is None: expand = not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].expand |
| 563 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..setBlockExpandUndo(bid, expand)) |
| 564 |
|
| 565 |
if undoinfo: |
| 566 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(undoinfo) |
| 567 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 568 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 569 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bactive] |
| 570 |
for bid in blocks: |
| 571 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).selectBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(bid) |
| 572 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).activate(active) |
| 573 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).see(active) |
| 574 |
|
| 575 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleExpand().(self).winfo_toplevel().event_generate("<<Status>>",data="Toggled Expand of selected objects") |
| 576 |
|
| 577 |
# ---------------------------------------------------------------------- |
| 578 |
def _toggleEnablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self), enablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(enable)=None): |
| 579 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: return None |
| 580 |
items = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(intscip-python python python-stdlib 3.11 builtins/int#,selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).curselection())) |
| 581 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 582 |
ypos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).yview()[0] |
| 583 |
undoinfo = [] |
| 584 |
blocks = [] |
| 585 |
for i in items: |
| 586 |
bid,lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[i] |
| 587 |
if lid is not None: |
| 588 |
if bid in blocks: continue |
| 589 |
pos = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bid] |
| 590 |
else: |
| 591 |
pos = i |
| 592 |
|
| 593 |
blocks.appendscip-python python python-stdlib 3.11 builtins/list#append().(bid) |
| 594 |
block = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid] |
| 595 |
if block.name() in ("Header", "Footer"): continue |
| 596 |
if enablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(enable) is None: enablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(enable) = not block.enable |
| 597 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..setBlockEnableUndo(bid, enablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(enable))) |
| 598 |
|
| 599 |
sel = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).selection_includes(pos) |
| 600 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).delete(pos) |
| 601 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).insert(pos, block.header()) |
| 602 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).itemconfig(pos, background=BLOCK_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/BLOCK_COLOR.) |
| 603 |
if not block.enable: |
| 604 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).itemconfig(pos, foreground=DISABLE_COLORscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/DISABLE_COLOR.) |
| 605 |
if sel: selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).selection_set(pos) |
| 606 |
|
| 607 |
if undoinfo: |
| 608 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..calculateEnableMargins() |
| 609 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(undoinfo) |
| 610 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).activate(active) |
| 611 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).yview_moveto(ypos) |
| 612 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(self).winfo_toplevel().event_generate("<<ListboxSelect>>") |
| 613 |
|
| 614 |
# ---------------------------------------------------------------------- |
| 615 |
def enablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#enable().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#enable().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#enable().(event)=None): |
| 616 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#enable().(self)._toggleEnablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(True) |
| 617 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#enable().(self).winfo_toplevel().event_generate("<<Status>>",data="Enabled selected objects") |
| 618 |
|
| 619 |
# ---------------------------------------------------------------------- |
| 620 |
def disablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#disable().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#disable().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#disable().(event)=None): |
| 621 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#disable().(self)._toggleEnablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().(False) |
| 622 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#disable().(self).winfo_toplevel().event_generate("<<Status>>",data="Disabled selected objects") |
| 623 |
|
| 624 |
# ---------------------------------------------------------------------- |
| 625 |
# toggle state enable/disable |
| 626 |
# ---------------------------------------------------------------------- |
| 627 |
def toggleEnablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleEnable().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleEnable().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleEnable().(event)=None): |
| 628 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleEnable().(self)._toggleEnablescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_toggleEnable().() |
| 629 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#toggleEnable().(self).winfo_toplevel().event_generate("<<Status>>",data="Toggled Visibility of selected objects") |
| 630 |
|
| 631 |
# ---------------------------------------------------------------------- |
| 632 |
# comment uncomment row |
| 633 |
# ---------------------------------------------------------------------- |
| 634 |
def commentRowscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(event)=None): |
| 635 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: return |
| 636 |
all_items = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items. |
| 637 |
sel_items = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(intscip-python python python-stdlib 3.11 builtins/int#,selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(self).curselection())) |
| •638 |
mreg = rescip-python python python-stdlib 3.11 re/__init__:.compilescip-python python python-stdlib 3.11 re/compile().(r"^\((.*)\)$") |
| 639 |
change = False |
| 640 |
for i in sel_items: |
| 641 |
my_item = all_items[i] |
| 642 |
if my_item[1] is not None: |
| 643 |
change = True |
| 644 |
#check for () |
| 645 |
line = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[my_item[0]][my_item[1]] |
| 646 |
m = mreg.searchscip-python python python-stdlib 3.11 re/Pattern#search().(line) |
| 647 |
if m is None: |
| 648 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[my_item[0]][my_item[1]] = "("+line+")" |
| 649 |
else: |
| 650 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[my_item[0]][my_item[1]] = m.groupscip-python python python-stdlib 3.11 re/Match#group().(1) |
| 651 |
if change: selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#commentRow().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 652 |
|
| 653 |
# ---------------------------------------------------------------------- |
| 654 |
# splitBlocks |
| 655 |
# ---------------------------------------------------------------------- |
| 656 |
def joinBlocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(event)=None): |
| 657 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: return |
| 658 |
all_items = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items. |
| 659 |
sel_items = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(intscip-python python python-stdlib 3.11 builtins/int#,selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self).curselection())) |
| 660 |
change = True |
| 661 |
bl = Blockscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[sel_items[0]].name()) |
| 662 |
for bid in sel_items: |
| 663 |
for line in selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid]: |
| 664 |
bl.appendscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#append().(line) |
| 665 |
bl.appendscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#append().("( ---------- cut-here ---------- )") |
| 666 |
del bl[-1] |
| 667 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addBlockUndo(bid+1,bl)) |
| 668 |
if change: selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 669 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self).deleteBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().() |
| 670 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#joinBlocks().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 671 |
|
| 672 |
# ---------------------------------------------------------------------- |
| 673 |
# splitBlocks |
| 674 |
# ---------------------------------------------------------------------- |
| 675 |
def splitBlocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(event)=None): |
| 676 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.: return |
| 677 |
all_items = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items. |
| 678 |
sel_items = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(intscip-python python python-stdlib 3.11 builtins/int#,selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).curselection())) |
| 679 |
change = True |
| 680 |
newblocks = [] |
| 681 |
for bid in sel_items: |
| 682 |
bl = Blockscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].name()) |
| 683 |
for line in selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid]: |
| 684 |
if line == "( ---------- cut-here ---------- )": |
| 685 |
#newblocks.append(bl) |
| 686 |
#self.insertBlock(bl) |
| 687 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addBlockUndo(bid+1,bl)) |
| 688 |
bl = Blockscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].name()) |
| 689 |
else: |
| 690 |
bl.appendscip-python python bCNC 0.9.14.318 `bCNC.CNC`/Block#append().(line) |
| 691 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addBlockUndo(bid+1,bl)) |
| 692 |
#newblocks.append(bl) |
| 693 |
#self.gcode.extend(newblocks) |
| 694 |
if change: selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 695 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).deleteBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#deleteBlock().() |
| 696 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#splitBlocks().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 697 |
|
| 698 |
# ---------------------------------------------------------------------- |
| 699 |
# change color of a block |
| 700 |
# ---------------------------------------------------------------------- |
| 701 |
def changeColorscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(event)=None): |
| 702 |
items = listscip-python python python-stdlib 3.11 builtins/list#(mapscip-python python python-stdlib 3.11 builtins/map#(intscip-python python python-stdlib 3.11 builtins/int#,selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).curselection())) |
| 703 |
if not items: |
| 704 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).winfo_toplevel().event_generate("<<Status>>",data="Nothing is selected") |
| 705 |
return |
| 706 |
|
| 707 |
# Find initial color |
| 708 |
bid,lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[items[0]] |
| 709 |
|
| 710 |
try: |
| 711 |
rgb, color = tkExtra.askcolor( |
| 712 |
title=_("Color"), |
| 713 |
initialcolor=selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].color, |
| 714 |
parent=selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self)) |
| 715 |
except TclErrorscip-python python python-stdlib 3.11 tkinter/__init__:: |
| 716 |
color = None |
| 717 |
if color is None: return |
| 718 |
|
| 719 |
blocks = [] |
| 720 |
undoinfo = [] |
| 721 |
for i in reversedscip-python python python-stdlib 3.11 builtins/reversed#(items): |
| 722 |
bid,lid = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[i] |
| 723 |
if lid is not None: |
| 724 |
if bid in blocks: continue |
| 725 |
blocks.appendscip-python python python-stdlib 3.11 builtins/list#append().(bid) |
| 726 |
oldColor = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].color |
| 727 |
undoinfo.appendscip-python python python-stdlib 3.11 builtins/list#append().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..setBlockColorUndo(bid, oldColor)) |
| 728 |
|
| 729 |
if undoinfo: |
| 730 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(undoinfo) |
| 731 |
for bid in blocks: |
| 732 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].color = color |
| 733 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 734 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#changeColor().(self).winfo_toplevel().event_generate("<<Status>>",data="Changed color of block") |
| 735 |
|
| 736 |
# ---------------------------------------------------------------------- |
| 737 |
# Select items in the form of (block, item) |
| 738 |
# ---------------------------------------------------------------------- |
| 739 |
def selectscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self), itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(items), doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(double)=False, clearscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(clear)=False, togglescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(toggle)=True): |
| 740 |
if clearscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(clear): |
| 741 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 742 |
togglescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(toggle) = False |
| 743 |
first = None |
| 744 |
|
| 745 |
for bi in itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(items): |
| 746 |
bid,lid = bi |
| 747 |
try: |
| 748 |
block = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid] |
| 749 |
except: |
| 750 |
continue |
| 751 |
|
| 752 |
if doublescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(double): |
| 753 |
if block.expand: |
| 754 |
# select whole block |
| 755 |
y = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bid] |
| 756 |
else: |
| 757 |
# select all blocks with the same name |
| 758 |
name = block.nameNop() |
| 759 |
for i,bl in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks): |
| 760 |
if name == bl.nameNop(): |
| 761 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).selection_set(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[i]) |
| 762 |
continue |
| 763 |
|
| 764 |
elif not block.expand or lid is None: |
| 765 |
# select whole block |
| 766 |
y = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bid] |
| 767 |
|
| 768 |
elif isinstance(lid,intscip-python python python-stdlib 3.11 builtins/int#): |
| 769 |
# find line of block |
| 770 |
y = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bid]+1 + lid |
| 771 |
|
| 772 |
else: |
| 773 |
raise |
| 774 |
#continue |
| 775 |
|
| 776 |
if y is None: continue |
| 777 |
|
| 778 |
if togglescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(toggle): |
| 779 |
select = not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).selection_includes(y) |
| 780 |
else: |
| 781 |
select = True |
| 782 |
|
| 783 |
if select: |
| 784 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).selection_set(y) |
| 785 |
if first is None: first = y |
| 786 |
elif togglescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(toggle): |
| 787 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).selection_clear(y) |
| 788 |
|
| 789 |
if first is not None: |
| 790 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).activate(first) |
| 791 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(self).see(first) |
| 792 |
|
| 793 |
# ---------------------------------------------------------------------- |
| 794 |
# Select whole block lines if expanded |
| 795 |
# ---------------------------------------------------------------------- |
| 796 |
def selectBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(self), bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(bid)): |
| 797 |
start = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(bid)] |
| 798 |
while True: |
| 799 |
bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(bid) += 1 |
| 800 |
if bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(bid) >= len(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.): |
| 801 |
end = ENDscip-python python python-stdlib 3.11 tkinter/__init__: |
| 802 |
break |
| 803 |
elif selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(bid)] is not None: |
| 804 |
end = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[bidscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(bid)]-1 |
| 805 |
break |
| 806 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(self).selection_set(start,end) |
| 807 |
|
| 808 |
# ---------------------------------------------------------------------- |
| 809 |
def selectBlocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlocks().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlocks().(self), blocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlocks().(blocks)): |
| 810 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlocks().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 811 |
for bid in blocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlocks().(blocks): |
| 812 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlocks().(self).selectBlockscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectBlock().(bid) |
| 813 |
|
| 814 |
# ---------------------------------------------------------------------- |
| 815 |
def selectAllscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectAll().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectAll().(self)): |
| 816 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectAll().(self).selection_set(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 817 |
|
| 818 |
# ---------------------------------------------------------------------- |
| 819 |
def selectClearscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectClear().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectClear().(self)): |
| 820 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectClear().(self).selection_clear(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 821 |
|
| 822 |
# ---------------------------------------------------------------------- |
| 823 |
def selectInvertscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectInvert().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectInvert().(self)): |
| 824 |
for i in rangescip-python python python-stdlib 3.11 builtins/range#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectInvert().(self).size()): |
| 825 |
if selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectInvert().(self).selection_includes(i): |
| 826 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectInvert().(self).selection_clear(i) |
| 827 |
else: |
| 828 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectInvert().(self).selection_set(i) |
| 829 |
|
| 830 |
# ---------------------------------------------------------------------- |
| 831 |
# Select all blocks with the same name of the selected layer |
| 832 |
# ---------------------------------------------------------------------- |
| 833 |
def selectLayerscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectLayer().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectLayer().(self)): |
| 834 |
for bid in selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectLayer().(self).getSelectedBlocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelectedBlocks().(): |
| 835 |
name = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectLayer().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode.[bid].nameNop() |
| 836 |
for i,bl in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectLayer().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks): |
| 837 |
if name == bl.nameNop(): |
| 838 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectLayer().(self).selection_set(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#selectLayer().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.[i]) |
| 839 |
|
| 840 |
# ---------------------------------------------------------------------- |
| 841 |
# Return list of [(blocks,lines),...] currently being selected |
| 842 |
# ---------------------------------------------------------------------- |
| 843 |
def getSelectionscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelection().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelection().(self)): |
| 844 |
return [selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelection().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[intscip-python python python-stdlib 3.11 builtins/int#(i)] for i in selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelection().(self).curselection()] |
| 845 |
|
| 846 |
# ---------------------------------------------------------------------- |
| 847 |
# Return all blocks that at least an item is selected |
| 848 |
# ---------------------------------------------------------------------- |
| 849 |
def getSelectedBlocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelectedBlocks().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelectedBlocks().(self)): |
| 850 |
blocks = {} |
| 851 |
for i in selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelectedBlocks().(self).curselection(): |
| 852 |
block,line = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelectedBlocks().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[intscip-python python python-stdlib 3.11 builtins/int#(i)] |
| 853 |
blocks[block] = True |
| 854 |
return listscip-python python python-stdlib 3.11 builtins/list#(sortedscip-python python python-stdlib 3.11 builtins/sorted().(blocks.keysscip-python python python-stdlib 3.11 builtins/dict#keys().())) |
| 855 |
|
| 856 |
# ---------------------------------------------------------------------- |
| 857 |
# Return list of [(blocks,lines),...] currently being selected |
| 858 |
# Filtering all items that the block is also selected |
| 859 |
# ---------------------------------------------------------------------- |
| 860 |
def getCleanSelectionscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getCleanSelection().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getCleanSelection().(self)): |
| 861 |
items = [selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getCleanSelection().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[intscip-python python python-stdlib 3.11 builtins/int#(i)] for i in selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getCleanSelection().(self).curselection()] |
| 862 |
if not items: return items |
| 863 |
blocks = {} |
| 864 |
i = 0 |
| 865 |
while i<len(items): |
| 866 |
bid,lid = items[i] |
| 867 |
if lid is None: |
| 868 |
blocks[bid] = True |
| 869 |
i += 1 |
| 870 |
elif blocks.getscip-python python python-stdlib 3.11 builtins/dict#get().(bid,False): |
| 871 |
del items[i] |
| 872 |
else: |
| 873 |
i += 1 |
| 874 |
return items |
| 875 |
|
| 876 |
# ---------------------------------------------------------------------- |
| 877 |
def getActivescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getActive().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getActive().(self)): |
| 878 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getActive().(self).index(ACTIVEscip-python python python-stdlib 3.11 tkinter/__init__:) |
| 879 |
if active is None: return None |
| 880 |
if not selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getActive().(self).selection_includes(active): |
| 881 |
try: |
| 882 |
active = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getActive().(self).curselection()[0] |
| 883 |
except: |
| 884 |
return (0,None) |
| 885 |
return selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getActive().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.[intscip-python python python-stdlib 3.11 builtins/int#(active)] |
| 886 |
|
| 887 |
# ---------------------------------------------------------------------- |
| 888 |
# Move selected items upwards |
| 889 |
# ---------------------------------------------------------------------- |
| 890 |
def orderUpscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().(event)=None): |
| 891 |
items = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().(self).getCleanSelectionscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getCleanSelection().() |
| 892 |
if not items: return |
| 893 |
sel = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..orderUp(items) |
| 894 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 895 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().(self).selectscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(sel,clearscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(clear)=True,togglescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(toggle)=False) |
| 896 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderUp().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 897 |
return "break" |
| 898 |
|
| 899 |
# ---------------------------------------------------------------------- |
| 900 |
# Move selected items downwards |
| 901 |
# ---------------------------------------------------------------------- |
| 902 |
def orderDownscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().(event)=None): |
| 903 |
items = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().(self).getCleanSelectionscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getCleanSelection().() |
| 904 |
if not items: return |
| 905 |
sel = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..orderDown(items) |
| 906 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 907 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().(self).selectscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(sel,clearscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(clear)=True,togglescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#select().(toggle)=False) |
| 908 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#orderDown().(self).winfo_toplevel().event_generate("<<Modified>>") |
| 909 |
return "break" |
| 910 |
|
| 911 |
# ---------------------------------------------------------------------- |
| 912 |
# Invert selected blocks |
| 913 |
# ---------------------------------------------------------------------- |
| 914 |
def invertBlocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#invertBlocks().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#invertBlocks().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#invertBlocks().(event)=None): |
| 915 |
blocks = selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#invertBlocks().(self).getSelectedBlocksscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#getSelectedBlocks().() |
| 916 |
if not blocks: return |
| 917 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#invertBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..addUndo(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#invertBlocks().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..invertBlocksUndo(blocks)) |
| 918 |
selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#invertBlocks().(self).fillscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#fill().() |
| 919 |
# do not send a modified message, no need to redraw |
| 920 |
return "break" |
| 921 |
|
| 922 |
# ---------------------------------------------------------------------- |
| 923 |
# Dump list and code, check for mismatch |
| 924 |
# ---------------------------------------------------------------------- |
| 925 |
def dumpscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#dump().(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#dump().(self), eventscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#dump().(event)=None): |
| 926 |
if not CNCscip-python python bCNC 0.9.14.318 `bCNC.CNC`/CNC#.developerscip-python python bCNC 0.9.14.318 `bCNC.CNC`/CNC#developer.: return |
| 927 |
printscip-python python python-stdlib 3.11 builtins/print().("*** LIST ***") |
| 928 |
for i,sel in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#dump().(self).get(0,ENDscip-python python python-stdlib 3.11 tkinter/__init__:)): |
| 929 |
printscip-python python python-stdlib 3.11 builtins/print().(i,sel.encode("ascii","replace")) #TODO: do we need .encode()??? |
| 930 |
|
| 931 |
printscip-python python python-stdlib 3.11 builtins/print().("\n*** ITEMS ***") |
| 932 |
for i,item in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#dump().(self)._itemsscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_items.): |
| 933 |
printscip-python python python-stdlib 3.11 builtins/print().(i,item) |
| 934 |
|
| 935 |
printscip-python python python-stdlib 3.11 builtins/print().("\n*** CODE ***") |
| 936 |
for i, block in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#dump().(self).gcodescip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#gcode..blocks): |
| 937 |
printscip-python python python-stdlib 3.11 builtins/print().("Block:",i,block.name()) |
| 938 |
for j,line in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(block): |
| 939 |
printscip-python python python-stdlib 3.11 builtins/print().(" %3d %s"%(j,line)) |
| 940 |
|
| 941 |
printscip-python python python-stdlib 3.11 builtins/print().("\nBLOCKPOS=",selfscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#dump().(self)._blockPosscip-python python bCNC 0.9.14.318 `bCNC.CNCList`/CNCListbox#_blockPos.) |