-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusercommand_regularmac_800.py
2627 lines (2388 loc) · 126 KB
/
usercommand_regularmac_800.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import linuxcnc
s = linuxcnc.stat()
s.poll()
rC = root_window.tk.call
rE = root_window.tk.eval
############################################
######## COPY LOTS FROM # PLASMAC2 #########
##############################################
spinBoxes = []
toolButtons = ['machine_estop','machine_power','file_open','reload','program_run',
'program_step','program_pause','program_stop','program_blockdelete',
'program_optpause','view_zoomin','view_zoomout','view_z','view_z2',
'view_x','view_y','view_y2','view_p','rotate','clear_plot']
configPath = os.getcwd()
#configPath = " "
##############################################################################
# NEW CLASSES #
##############################################################################
# class for preferences file
prefP = configparser.ConfigParser
class plasmacPreferences(prefP): # PLASMAC2
optionxform = str
types = {bool: prefP.getboolean,
float: prefP.getfloat,
int: prefP.getint,
str: prefP.get,
repr: lambda self, section, option: eval(prefP.get(self, section, option)),
}
def __init__(self):
prefP.__init__(self, strict=False, interpolation=None)
self.fn = os.path.join(configPath, '{}.prefs'.format(vars.machine.get()))
self.read(self.fn)
##############################################################################
# PREFERENCE FUNCTIONS #
##############################################################################
def getPrefs(prefs, section, option, default=False, type=bool): # PLASMAC2
m = prefs.types.get(type)
if prefs.has_section(section):
if prefs.has_option(section, option):
return m(prefs, section, option)
else:
prefs.set(section, option, str(default))
prefs.write(open(prefs.fn, 'w'))
return default
else:
prefs.add_section(section)
prefs.set(section, option, str(default))
prefs.write(open(prefs.fn, 'w'))
return default
def putPrefs(prefs, section, option, value, type=bool): # PLASMAC2
if prefs.has_section(section):
prefs.set(section, option, str(type(value)))
prefs.write(open(prefs.fn, 'w'))
else:
prefs.add_section(section)
prefs.set(section.upper(), option, str(type(value)))
prefs.write(open(prefs.fn, 'w'))
def removePrefsSect(prefs, section): # PLASMAC2
prefs.remove_section(section)
prefs.write(open(prefs.fn, 'w'))
def sortPrefs(prefs): # PLASMAC2
prefs._sections = OrderedDict(sorted(prefs._sections.items(), key=lambda t: int(t[0].rsplit('_',1)[1]) ))
prefs.write(open(prefs.fn, 'w'))
PREF = plasmacPreferences()
# class for popup dialogs # PLASMAC2
class plasmacDialog:
def __init__(self, func, title, msg, system=None):
dlg = self.dlg = Tkinter.Toplevel(root_window, bg=colorBack)
dlg.attributes('-type', 'dock')
rE('tk::PlaceWindow {} center'.format(dlg))
dlg.wait_visibility()
dlg.grab_set()
dlg.protocol("WM_DELETE_WINDOW", lambda:self.dlg_complete(False, False))
dlg.title(title)
frm = Tkinter.Frame(dlg, bg=colorBack, bd=2, relief='flat')
ttl = Tkinter.Label(frm, text=title, fg=colorBack, bg=colorFore)
ttl.pack(fill='x')
if func == 'rfl':
self.leadIn = Tkinter.BooleanVar()
self.leadLength = Tkinter.StringVar()
self.leadAngle = Tkinter.StringVar()
f1 = Tkinter.Frame(frm, bg=colorBack)
lbl1 = Tkinter.Label(f1, text=_('Use Leadin:'), fg=colorFore, bg=colorBack, width=12, anchor='e')
lbl1.pack(side='left')
leadinDo = Tkinter.Checkbutton(f1, fg=colorFore, bg=colorBack, variable=self.leadIn, indicatoron=False, width=2, bd=1)
leadinDo.configure(highlightthickness=0, activebackground=colorBack, selectcolor=colorActive, relief='raised', overrelief='raised')
leadinDo.pack(side='left')
f1.pack(padx=4, pady=4, anchor='w')
f2 = Tkinter.Frame(frm, bg=colorBack)
lbl2 = Tkinter.Label(f2, text=_('Leadin Length:'), fg=colorFore, bg=colorBack, width=12, anchor='e')
lbl2.pack(side='left')
leadinLength = Tkinter.Spinbox(f2, fg=colorFore, bg=colorBack, textvariable=self.leadLength, width=10)
leadinLength.configure(font=(fontName, fontSize), highlightthickness=0)
leadinLength.pack(side='left')
f2.pack(padx=4, pady=4, anchor='w')
f3 = Tkinter.Frame(frm, bg=colorBack)
lbl3 = Tkinter.Label(f3, text=_('Leadin Angle:'), fg=colorFore, bg=colorBack, width=12, anchor='e')
lbl3.pack(side='left')
leadinAngle = Tkinter.Spinbox(f3, fg=colorFore, bg=colorBack, textvariable=self.leadAngle, width=10)
leadinAngle.configure(font=(fontName, fontSize), highlightthickness=0)
leadinAngle.pack(side='left')
f3.pack(padx=4, pady=4, anchor='w')
self.leadIn.set(False)
if s.linear_units == 1:
leadinLength.config(width=10, from_=1, to=25, increment=1, format='%0.0f', wrap=1)
self.leadLength.set(5)
else:
leadinLength.config(width=10, from_=0.05, to=1, increment=0.05, format='%0.2f', wrap=1)
self.leadLength.set(0.2)
leadinAngle.config(width=10, from_=-359, to=359, increment=1, format='%0.0f', wrap=1)
self.leadAngle.set(0)
else:
label = Tkinter.Label(frm, text=msg, fg=colorFore, bg=colorBack)
label.pack(padx=4, pady=4)
if func in ['entry', 'touch']:
self.entry = Tkinter.Entry(frm, justify='right', fg=colorFore, bg=colorBack)
self.entry.configure(highlightthickness=0, selectforeground=colorBack, selectbackground=colorFore)
self.entry.pack(padx=4, pady=4)
self.entry.focus_set()
if func == 'touch':
self.entry.insert('end', '0.0')
opl = Tkinter.Label(frm, text=_('Coordinate System'), fg=colorFore, bg=colorBack)
opl.pack(padx=4, pady=4)
self.c = c = StringVar(t)
c.set(system)
self.opt = Tkinter.OptionMenu(frm, c, *all_systems[:])
self.opt.configure(fg=colorFore, bg=colorBack, activebackground=colorBack, highlightthickness=0)
self.opt.children['menu'].configure(fg=colorFore, bg=colorBack, activeforeground=colorBack, activebackground=colorFore)
self.opt.pack(padx=4, pady=4)
bbox = Tkinter.Frame(frm, bg=colorBack)
if func == 'rfl':
b1Text = _('Load')
b2Text = _('Cancel')
if func in ['info', 'error', 'warn']:
b1Text = _('OK')
b2Text = None
elif func in ['yesno']:
b1Text = _('Yes')
b2Text = _('No')
elif func in ['entry', 'touch']:
b1Text = _('OK')
b2Text = _('Cancel')
b1 = Tkinter.Button(bbox, text=b1Text, command=lambda:self.dlg_complete(True, func), width=8)
b1.configure(fg=colorFore, bg=colorBack, activebackground=colorBack, highlightthickness=0)
b1.pack(side='left')
if b2Text:
b2 = Tkinter.Button(bbox, text=b2Text, command=lambda:self.dlg_complete(False, func), width=8)
b2.configure(fg=colorFore, bg=colorBack, activebackground=colorBack, highlightthickness=0)
b2.pack(side='left', padx=(8,0))
bbox.pack(padx=4, pady=4)
frm.pack()
def dlg_complete(self, value, func):
if func == 'rfl':
self.reply = value, self.leadIn.get(), float(self.leadLength.get()), float(self.leadAngle.get())
elif func in ['entry']:
# text = None if not self.entry.get() else self.entry.get()
self.reply = value, self.entry.get()
elif func in ['touch']:
# text = None if not self.entry.get() else self.entry.get()
self.reply = value, self.entry.get(), self.c.get()
else:
self.reply = value
self.dlg.destroy()
##################################
####### GCODE PRE ###################
########################################
def auto_tab_raise():
#pVars.editmode.set(True)
#print(pVars.editmode.get())
keybind_edit()
#edit_full()
#load_editfile()
#rC(".toolbar.program_run","configure","-state","normal")
#rC(".toolbar.program_step","configure","-state","normal")
#rC('.menu','entryconfig','Setup','-state','disabled')
root_window.unbind('<Down>')
root_window.unbind('<Up>')
root_window.unbind('<KP_Down>')
root_window.unbind('<KP_Up>')
root_window.bind('<Down>', select_next_line)
root_window.bind('<Up>', select_prev_line)
def auto_tab_lower():
#save_editfile()
root_window.unbind('<Down>')
root_window.unbind('<Up>')
keybind_edit_restore()
bind_axis('Down', 'Up', 1)
bind_axis("KP_Down", "KP_Up", 1)
#pVars.editsize.set(False)
#edit_lower()
#pVars.editmode.set(False)
#print(pVars.editmode.get())
#rC(".toolbar.program_run","configure","-state","disabled")
#rC(".toolbar.program_step","configure","-state","disabled")
#rC('.menu','entryconfig','Setup','-state','normal')
def tab_auto():
if s.task_mode == 2:
#rC('.pane.top.tabs','itemconfigure','manual','-state','disabled')
#rC('.pane.top.tabs','itemconfigure','mdi','-state','disabled')
rC('.pane.top.tabs','itemconfigure','edit','-state','disabled')
#rC('.pane.top.tabs','itemconfigure','edit')
#rC('.menu','entryconfig','Setup','-state','disabled')
rC('.pane.top.tabs','raise','auto')
else:
#rC('.pane.top.tabs','itemconfigure','manual','-state','normal')
#rC('.pane.top.tabs','itemconfigure','mdi','-state','normal')
rC('.pane.top.tabs','itemconfigure','edit','-state','normal')
#rC('.menu','entryconfig','Setup','-state','normal')
############################################
####### MOVE THE GCODE ##############
############################################
# remove bottom pane
rC('.pane','forget','.pane.bottom')
# new auto tab with gcode text
rC('.pane.top.tabs','insert','end','auto','-text',' Auto ','-raisecmd','auto_tab_raise','-leavecmd','auto_tab_lower')
rC('.pane.top.tabs.fauto','configure','-borderwidth',2)
rC('frame','.pane.top.tabs.fauto.t','-borderwidth',2,'-relief','sunken','-highlightthickness','1')
rC('text','.pane.top.tabs.fauto.t.text','-borderwidth','0','-exportselection','0','-highlightthickness','0','-relief','flat','-takefocus','0','-undo','0','-height','30','-wrap','word')
rC('bind','.pane.top.tabs.fauto.t.text','<Configure>','goto_sensible_line')
rC('scrollbar','.pane.top.tabs.fauto.t.sb','-width',25,'-borderwidth','0','-highlightthickness','0')
rC('.pane.top.tabs.fauto.t.text','configure','-state','normal','-yscrollcommand',['.pane.top.tabs.fauto.t.sb','set'])
rC('.pane.top.tabs.fauto.t.sb','configure','-command',['.pane.top.tabs.fauto.t.text','yview'])
rC('pack','.pane.top.tabs.fauto.t.sb','-fill','y','-side','left')
rC('pack','.pane.top.tabs.fauto.t.text','-expand','1','-fill','both','-side','top')
rC('pack','.pane.top.tabs.fauto.t','-fill','both')
# create a new widget list so we can "move" the gcode text
widget_list_new = []
for widget in widget_list:
if '.t.text' in widget[2]:
widget = ('text', Text, '.pane.top.tabs.fauto.t.text')
widget_list_new.append(widget)
widget_list_new.append(('edit', Text, '.pane.top.tabs.fedit.t.text'))
widget_list_new.append(('buttonFrame', Frame, '.fbuttons'))
widgets = nf.Widgets(root_window,*widget_list_new)
# copied from axis.py (line 3857) to assign the "new" widgets.text to t
t = widgets.text
t.bind('<Button-3>', rClicker)
t.tag_configure("ignored", background="#ffffff", foreground="#808080")
t.tag_configure("lineno", foreground="#808080")
t.tag_configure("executing", background="#804040", foreground="#ffffff")
t.bind("<Button-1>", select_line)
t.bind("<Double-Button-1>", release_select_line)
t.bind("<B1-Motion>", lambda e: "break")
t.bind("<B1-Leave>", lambda e: "break")
t.bind("<Button-4>", scroll_up)
t.bind("<Button-5>", scroll_down)
t.configure(state="disabled")
######################################
########## Addition to GCODE #######
######################################
rC('labelframe','.pane.top.tabs.fauto.program')
rC('pack','.pane.top.tabs.fauto.program','-before','.pane.top.tabs.fauto.t','-fill','x')
rC('label','.pane.top.tabs.fauto.program.name','-text','file','-justify','left','-padx',16,'-anchor','ne')
rC('label','.pane.top.tabs.fauto.program.time','-textvariable','runJ','-justify','right','-padx',16)
rC('checkbutton','.pane.top.tabs.fauto.program.size','-text',' AUTO ','-command','edit_size','-variable','editsize')
rC('pack','.pane.top.tabs.fauto.program.size','-side','left')
rC('pack','.pane.top.tabs.fauto.program.name','-side','left')
rC('pack','.pane.top.tabs.fauto.program.time','-side','right')
######################################
####### end Addition to GCODE #######
######################################
############################################
####### MOVE THE GCODE/new key binds ######
############################################
def select_next_line(self):
if o.highlight_line is None:
i = 1
else:
i = max(o.last_line, o.highlight_line + 1)
o.set_highlight_line(i)
o.tkRedraw()
##############################################
##### and do select_prev also #############
########################################
def select_prev_line(self):
if o.highlight_line is None:
i = o.last_line
else:
i = max(1, o.highlight_line - 1)
o.set_highlight_line(i)
o.tkRedraw()
############################################
############################################
####### end MOVE THE GCODE ##############
############################################
#########
#########################################################################
####### EDIT TAB ######
#########
##################################
edittext = ('.pane.top.tabs.fedit.t.text')
def edit_size():
rC('grid','propagate','.pane.top.tabs',0)
if pVars.editsize.get()==True:
rC('grid','remove','.pane.top.right')
if pVars.winSize.get() == 'medium':
rC('grid','.pane.top.tabs','-sticky','nesw','-columnspan',2,'-rowspan',1)
else:
rC('grid','.pane.top.tabs','-sticky','nesw','-columnspan',2)
#rC('grid','columnconfigure',ftop,0,'-weight',0,'-minsize',tabSizeW)
else:
if pVars.winSize.get() == 'medium':
rC('grid','.pane.top.tabs','-sticky','nesw','-columnspan',1,'-rowspan',15)
else:
rC('grid','.pane.top.tabs','-sticky','nesw','-columnspan',1)
rC('grid','.pane.top.right','-sticky','nesw','-columnspan',1)
def edit_full():
rC('grid','remove','.pane.top.right')
rC('grid','.pane.top.tabs','-sticky','nesw','-columnspan',2)
def edit_lower():
rC('grid','.pane.top.tabs','-sticky','nesw','-columnspan',1)
rC('grid','.pane.top.right','-sticky','nesw','-columnspan',1)
def keybind_edit():
### UNBIND
root_window.unbind("l")#, commands.toggle_override_limits)
root_window.unbind("o")#, commands.open_file)
root_window.unbind("s")#, commands.task_resume)
root_window.unbind("t")#, commands.task_step)
root_window.unbind("p")#, commands.task_pause)
root_window.unbind("R")#, commands.task_reverse)
root_window.unbind("F")#, commands.task_forward)
root_window.unbind("v")#, commands.cycle_view)
root_window.unbind("r")#, commands.task_run)
root_window.unbind("B")#, commands.brake_on)
root_window.unbind("b")#, commands.brake_off)
root_window.unbind("x")#, lambda event: activate_ja_widget("x"))
root_window.unbind("y")#, lambda event: activate_ja_widget("y"))
root_window.unbind("z")#, lambda event: activate_ja_widget("z"))
root_window.unbind("a")#, lambda event: activate_ja_widget("a"))
root_window.unbind("c")#, lambda event: jogspeed_continuous())
root_window.unbind("d")#, lambda event: widgets.rotate.invoke())
root_window.unbind("i")#, lambda event: jogspeed_incremental())
root_window.unbind("I")#, lambda event: jogspeed_incremental(-1))
root_window.unbind("`")#, lambda event: activate_ja_widget_or_set_feedrate(0))
root_window.unbind("1")#, lambda event: activate_ja_widget_or_set_feedrate(1))
root_window.unbind("2")#, lambda event: activate_ja_widget_or_set_feedrate(2))
root_window.unbind("3")#, lambda event: activate_ja_widget_or_set_feedrate(3))
root_window.unbind("4")#, lambda event: activate_ja_widget_or_set_feedrate(4))
root_window.unbind("5")#, lambda event: activate_ja_widget_or_set_feedrate(5))
root_window.unbind("6")#, lambda event: activate_ja_widget_or_set_feedrate(6))
root_window.unbind("7")#, lambda event: activate_ja_widget_or_set_feedrate(7))
root_window.unbind("8")#, lambda event: activate_ja_widget_or_set_feedrate(8))
root_window.unbind("9")#, lambda event: activate_ja_widget_or_set_feedrate(9))
root_window.unbind("0")#, lambda event: activate_ja_widget_or_set_feedrate(10))
root_window.unbind("!")#, "set metric [expr {!$metric}]; redraw")
root_window.unbind("@")#, commands.toggle_display_type)
root_window.unbind("#")#, commands.toggle_coord_type)
root_window.unbind("$")#, commands.toggle_teleop_mode)
root_window.unbind("<Home>")#, commands.home_joint)
root_window.unbind("<End>")#, commands.touch_off_system)
root_window.unbind(".")#, commands.toggle_coord_type)
root_window.unbind(",")#, commands.toggle_teleop_mode)
root_window.unbind(";")#, commands.toggle_coord_type)
root_window.unbind("'")#, commands.toggle_teleop_mode)
def keybind_edit_restore():
########bind
root_window.bind("l", commands.toggle_override_limits)
root_window.bind("o", commands.open_file)
root_window.bind("s", commands.task_resume)
root_window.bind("t", commands.task_step)
root_window.bind("p", commands.task_pause)
root_window.bind("R", commands.task_reverse)
root_window.bind("F", commands.task_forward)
root_window.bind("v", commands.cycle_view)
root_window.bind("r", commands.task_run)
root_window.bind("B", commands.brake_on)
root_window.bind("b", commands.brake_off)
root_window.bind("x", lambda event: activate_ja_widget("x"))
root_window.bind("y", lambda event: activate_ja_widget("y"))
root_window.bind("z", lambda event: activate_ja_widget("z"))
root_window.bind("a", lambda event: activate_ja_widget("a"))
root_window.bind("c", lambda event: jogspeed_continuous())
root_window.bind("d", lambda event: widgets.rotate.invoke())
root_window.bind("i", lambda event: jogspeed_incremental())
root_window.bind("I", lambda event: jogspeed_incremental(-1))
root_window.bind("`", lambda event: activate_ja_widget_or_set_feedrate(0))
root_window.bind("1", lambda event: activate_ja_widget_or_set_feedrate(1))
root_window.bind("2", lambda event: activate_ja_widget_or_set_feedrate(2))
root_window.bind("3", lambda event: activate_ja_widget_or_set_feedrate(3))
root_window.bind("4", lambda event: activate_ja_widget_or_set_feedrate(4))
root_window.bind("5", lambda event: activate_ja_widget_or_set_feedrate(5))
root_window.bind("6", lambda event: activate_ja_widget_or_set_feedrate(6))
root_window.bind("7", lambda event: activate_ja_widget_or_set_feedrate(7))
root_window.bind("8", lambda event: activate_ja_widget_or_set_feedrate(8))
root_window.bind("9", lambda event: activate_ja_widget_or_set_feedrate(9))
root_window.bind("0", lambda event: activate_ja_widget_or_set_feedrate(10))
root_window.bind("!", "set metric [expr {!$metric}]; redraw")
root_window.bind("@", commands.toggle_display_type)
root_window.bind("#", commands.toggle_coord_type)
root_window.bind("$", commands.toggle_teleop_mode)
root_window.bind("<Home>", commands.home_joint)
root_window.bind("<End>", commands.touch_off_system)
#root_window.bind('<1>', select_next_line)
#root_window.bind('<2>', select_prev_line)
def load_editfile():
print (s.file)
open_filea = open(s.file,'r')
rC('.pane.top.tabs.fedit.t.text','delete','1.0','end')
rC('.pane.top.tabs.fedit.t.text','insert','end',open_filea.read())
pVars.editfile.set(s.file)
#print(pVars.editfile.get())
rC('.pane.top.tabs.fedit.t.text','edit','reset')
def save_editfile():
print (s.file)
open_filea = open(s.file,'w')
edit_gcode = rC('.pane.top.tabs.fedit.t.text','get','1.0','end-1c')
open_filea.write(edit_gcode)
reload_file()
return 1
def edit_tab_raise():
pVars.editmode.set(True)
#print(pVars.editmode.get())
keybind_edit()
#edit_full()
load_editfile()
rC(".toolbar.program_run","configure","-state","disabled")
rC(".toolbar.program_step","configure","-state","disabled")
def edit_tab_lower():
save_editfile()
keybind_edit_restore()
pVars.editsize.set(False)
edit_lower()
pVars.editmode.set(False)
#print(pVars.editmode.get())
rC(".toolbar.program_run","configure","-state","normal")
rC(".toolbar.program_step","configure","-state","normal")
def print_file():
print ('breakin')
rC('.pane.top.tabs.fedit.t.text','insert','insert', '%K')
return "break"
# new edit tab with gcode text
rC('.pane.top.tabs','insert','end','edit','-text',' edit ','-raisecmd','edit_tab_raise','-leavecmd','edit_tab_lower')
rC('.pane.top.tabs.fedit','configure','-borderwidth',2)
rC('frame','.pane.top.tabs.fedit.t','-borderwidth',2,'-relief','sunken','-highlightthickness','1')
rC('text','.pane.top.tabs.fedit.t.text','-borderwidth','0','-relief','flat','-takefocus','1','-undo','1','-height','30','-wrap','word')
#rC('bind','.pane.top.tabs.fedit.t.text','<Configure>','goto_sensible_line')
rC('scrollbar','.pane.top.tabs.fedit.t.sb','-width',25,'-borderwidth','0','-highlightthickness','0')
rC('.pane.top.tabs.fedit.t.text','configure','-yscrollcommand',['.pane.top.tabs.fedit.t.sb','set'])
rC('.pane.top.tabs.fedit.t.sb','configure','-command',['.pane.top.tabs.fedit.t.text','yview'])
rC('pack','.pane.top.tabs.fedit.t.sb','-fill','y','-side','left')
rC('pack','.pane.top.tabs.fedit.t.text','-expand','1','-fill','both','-side','right')
rC('pack','.pane.top.tabs.fedit.t','-fill','both')
rC('button','.pane.top.tabs.fedit.edit','-text','edit','-command','load_editfile')
rC('button','.pane.top.tabs.fedit.save','-text','save','-command','save_editfile')
#rC('pack','.pane.top.tabs.fedit.edit','-side','left')
#rC('pack','.pane.top.tabs.fedit.save','-side','left')
######################################
########## Addition to EDIT #######
######################################
rC('labelframe','.pane.top.tabs.fedit.program')
rC('pack','.pane.top.tabs.fedit.program','-before','.pane.top.tabs.fedit.t','-fill','x')
rC('label','.pane.top.tabs.fedit.program.name','-text','file','-justify','left','-padx',16)
rC('checkbutton','.pane.top.tabs.fedit.program.size','-text',' EDIT ','-command','edit_size','-variable','editsize')
rC('pack','.pane.top.tabs.fedit.program.size','-side','left')
rC('pack','.pane.top.tabs.fedit.program.name','-side','left')
######################################
####### end Addition to EDIT #######
######################################
#########
##################################
####### end EDIT TAB ######
#########
##################################
##### probe #@######
# new probe tab in top.tabs
rC('.pane.top.tabs','insert','end','probe','-text',' PROBE ')
rC('.pane.top.tabs.fprobe','configure','-borderwidth',2)
# pagesmanager for probe pages
rC('PagesManager','.pane.top.tabs.fprobe.pages')
for probepage in ['bore','boss','web','slot','edge','z','setting']:
rC('.pane.top.tabs.fprobe.pages','add',probepage)
# buttons to control pages
rC('frame','.pane.top.tabs.fprobe.buttons')
# ~ for n in range(0,6):
# ~ rC('button','.pane.top.tabs.fprobe.buttons.' + str(n) , '-text','ass' + str(n))
# ~ rC('pack','.pane.top.tabs.fprobe.buttons.' + str(n),'-fill','both','-side','left','-expand',1)
for probebutt in ['bore','boss','web','slot','edge','z','setting']:
#rC('button','.pane.top.tabs.fprobe.buttons.' + probebutt , '-text','ass' + probebutt)
rC('button','.pane.top.tabs.fprobe.buttons.' + probebutt , '-text',probebutt)
rC('pack','.pane.top.tabs.fprobe.buttons.' + probebutt,'-fill','both','-side','left','-expand',1)
# setting page
rC('frame','.pane.top.tabs.fprobe.pages.fsetting.axis','-borderwidth',2,'-relief','sunken','-highlightthickness','1')
v = StringVar()
v.set("x")
rC('radiobutton','.pane.top.tabs.fprobe.pages.fsetting.axis.edgex','-text','+X','-variable',v,'-value','x','-indicatoron','false')
rC('radiobutton','.pane.top.tabs.fprobe.pages.fsetting.axis.edgenx','-text','-X','-variable',v,'-value','-x','-indicatoron','false')
rC('radiobutton','.pane.top.tabs.fprobe.pages.fsetting.axis.edgey','-text','+Y','-variable',v,'-value','y','-indicatoron','false')
rC('radiobutton','.pane.top.tabs.fprobe.pages.fsetting.axis.edgeny','-text','-Y','-variable',v,'-value','-y','-indicatoron','false')
rC('label','.pane.top.tabs.fprobe.pages.fsetting.axis.edgel','-text','EDGE')
rC('pack','.pane.top.tabs.fprobe.pages.fsetting.axis.edgel','-side','left')
rC('pack','.pane.top.tabs.fprobe.pages.fsetting.axis.edgeny','-side','right')
rC('pack','.pane.top.tabs.fprobe.pages.fsetting.axis.edgey','-side','right')
rC('pack','.pane.top.tabs.fprobe.pages.fsetting.axis.edgenx','-side','right')
rC('pack','.pane.top.tabs.fprobe.pages.fsetting.axis.edgex','-side','right')
rC('pack','.pane.top.tabs.fprobe.pages.fsetting.axis','-fill','both')
rC('pack','.pane.top.tabs.fprobe.buttons','-fill','x','-expand',1,'-side','bottom')
rC('pack','.pane.top.tabs.fprobe.pages','-fill','both','-side','top')
rC('.pane.top.tabs.fprobe.pages','raise','setting')
###### end probe #####
##############################################################################
# MONKEYPATCHED FUNCTIONS # PLASMAC2 #
##############################################################################
def get_coordinate_font(large): # PLASMAC2
global coordinate_font
global coordinate_linespace
global coordinate_charwidth
global fontbase
#coordinate_font = 'monospace {}'.format(fontSize)
coordinate_font = ngcFont
if coordinate_font not in font_cache:
font_cache[coordinate_font] = \
glnav.use_pango_font(coordinate_font, 0, 128)
fontbase, coordinate_charwidth, coordinate_linespace = \
font_cache[coordinate_font]
##############################################################################
# USER BUTTON #
##############################################################################
def set_toggle_pins(pin): # PLASMAC2
pin['state'] = hal.get_value(pin['pin'])
if pin['state']:
rC('.fbuttons.button' + pin['button'],'configure','-bg',colorActive)
else:
rC('.fbuttons.button' + pin['button'],'configure','-bg',colorBack)
#if pin['runcritical']:
# rC('.fbuttons.button' + pin['button'],'configure','-bg',colorWarn)
#else:
# rC('.fbuttons.button' + pin['button'],'configure','-bg',colorBack)
##############################################################################
# USER BUTTON FUNCTIONS #
##############################################################################
def validate_hal_pin(halpin, button, usage): # PLASMAC2
title = _('HAL PIN ERROR')
valid = pBit = False
for pin in halPinList:
if halpin in pin['NAME']:
pBit = isinstance(pin['VALUE'], bool)
valid = True
break
if not valid:
msg0 = _('does not exist for user button')
notifications.add('error', '{}:\n{} {} #{}'.format(title, halpin, msg0, button))
if not pBit:
msg0 = _('must be a bit pin for user button')
notifications.add('error', '{}:\n{} {} #{}'.format(title, usage, msg0, button))
valid = False
return valid
def validate_ini_param(code, button): # plasmac
title = _('PARAMETER ERROR')
valid = [False, None]
try:
parm = code[code.index('{') + len('') + 1: code.index('}')]
value = inifile.find(parm.split()[0], parm.split()[1]) or None
if value:
valid = [True, code.replace('{{{}}}'.format(parm), value)]
except:
pass
if not valid[0]:
msg0 = _('invalid parameter')
msg1 = _('for user button')
notifications.add('error', '{}:\n{} {} {} #{}'.format(title, msg0, code, msg1, button))
return valid
def button_action(button, pressed): # plasmac
if int(pressed):
user_button_pressed(button, buttonCodes[int(button)])
else:
user_button_released(button, buttonCodes[int(button)])
def user_button_setup(): # plasmac
global buttonNames, buttonCodes, togglePins, criticalButtons#, fontSize#, pulsePins, machineBounds, criticalButtons
# global probeButton, probeText, torchButton, torchText, cChangeButton
singleCodes = []#'ohmic-test','cut-type','single-cut','manual-cut','probe-test', \
# 'torch-pulse','change-consumables','framing','latest-file']
buttonNames = {0:{'name':None}}
buttonCodes = {0:{'code':None}}
criticalButtons = []
row = 1
for n in range(1,20):
bLabel = None
bName = getPrefs(PREF,'BUTTONS', str(n) + ' Name', '', str)
bCode = getPrefs(PREF,'BUTTONS', str(n) + ' Code', '', str)
outCode = {'code':None}
# if bCode.strip() == 'ohmic-test' and not 'ohmic-test' in [(v['code']) for k, v in buttonCodes.items()]:
# outCode['code'] = 'ohmic-test'
# elif bCode.strip() == 'cut-type' and not 'cut-type' in buttonCodes:
# bName = bName.split(',')
# if len(bName) == 1:
# text = _('Pierce\Only') if '\\' in bName[0] else _('Pierce Only')
# bName.append(text)
# outCode = {'code':'cut-type', 'text':bName}
# elif bCode.strip() == 'single-cut' and not 'single-cut' in buttonCodes:
# outCode['code'] = 'single-cut'
# elif bCode.strip() == 'manual-cut' and not 'manual-cut' in buttonCodes:
# outCode['code'] = 'manual-cut'
# elif bCode.startswith('probe-test') and not 'probe-test' in [(v['code']) for k, v in buttonCodes.items()]:
# if bCode.split()[0].strip() == 'probe-test' and len(bCode.split()) < 3:
# codes = bCode.strip().split()
# outCode = {'code':'probe-test', 'time':10}
# probeButton = str(n)
# probeText = bName.replace('\\', '\n')
# if len(codes) == 2:
# try:
# value = int(float(codes[1]))
# outCode['time'] = value
# except:
# outCode['code'] = None
# elif bCode.startswith('torch-pulse') and not 'torch-pulse' in [(v['code']) for k, v in buttonCodes.items()]:
# if bCode.split()[0].strip() == 'torch-pulse' and len(bCode.split()) < 3:
# codes = bCode.strip().split()
# outCode = {'code':'torch-pulse', 'time':1.0}
# torchButton = str(n)
# torchText = bName.replace('\\', '\n')
# if len(codes) == 2:
# try:
# value = round(float(codes[1]), 1)
# outCode['time'] = value
# except:
# outCode['code'] = None
# elif bCode.startswith('change-consumables ') and not 'change-consumables' in [(v['code']) for k, v in buttonCodes.items()]:
# codes = re.sub(r'([xyf]|[XYF])\s+', r'\1', bCode) # remove any spaces after x, y, and f
# codes = codes.lower().strip().split()
# if len(codes) > 1 and len(codes) < 5:
# outCode = {'code':'change-consumables', 'X':None, 'Y':None, 'F':None}
# for l in 'xyf':
# for c in range(1, len(codes)):
# if codes[c].startswith(l):
# try:
# value = round(float(codes[c].replace(l,'')), 3)
# outCode['XYF'['xyf'.index(l)]] = value
# except:
# outCode['code'] = None
# if (not outCode['X'] and not outCode['Y']) or not outCode['F']:
# outCode['code'] = None
# else:
# buff = 10 * hal.get_value('halui.machine.units-per-mm') # keep 10mm away from machine limits
# for axis in 'XY':
# if outCode[axis]:
# if outCode['{}'.format(axis)] < machineBounds['{}-'.format(axis)] + buff:
# outCode['{}'.format(axis)] = machineBounds['{}-'.format(axis)] + buff
# elif outCode['{}'.format(axis)] > machineBounds['{}+'.format(axis)] - buff:
# outCode['{}'.format(axis)] = machineBounds['{}+'.format(axis)] - buff
# if outCode['code']:
# cChangeButton = str(n)
# elif bCode.startswith('framing') and not 'framing' in [(v['code']) for k, v in buttonCodes.items()]:
# codes = re.sub(r'([f]|[F])\s+', r'\1', bCode) # remove any spaces after f
# codes = codes.lower().strip().split()
# if codes[0] == 'framing' and len(codes) < 4:
# outCode = {'code':'framing', 'F':False, 'Z':False}
# for c in range(1, len(codes)):
# if codes[c].startswith('f'):
# try:
# value = round(float(codes[c].replace('f','')), 3)
# outCode['F'] = value
# except:
# outCode['code'] = None
# elif codes[c] == 'usecurrentzheight':
# outCode['Z'] = True
# else:
# outCode['code'] = None
# elif bCode.startswith('load '):
# if len(bCode.split()) > 1 and len(bCode.split()) < 3:
# codes = bCode.strip().split()
# if os.path.isfile(os.path.join(open_directory, codes[1])):
# outCode = {'code':'load', 'file':os.path.join(open_directory, codes[1])}
# elif bCode.startswith('latest-file') and not 'latest-file' in [(v['code']) for k, v in buttonCodes.items()]:
# if len(bCode.split()) < 3:
# codes = bCode.strip().split()
# outCode = {'code':'latest-file', 'dir':None}
# if len(codes) == 1:
# outCode['dir'] = open_directory
# elif len(codes) == 2 and os.path.isdir(codes[1]):
# outCode['dir'] = codes[1]
# else:
# outCode['code'] = None
# elif bCode.startswith('pulse-halpin '):
# if len(bCode.split()) > 1 and len(bCode.split()) < 4:
# codes = bCode.strip().split()
# if validate_hal_pin(codes[1], n, 'pulse-halpin'):
# outCode = {'code':'pulse-halpin', 'pin':codes[1], 'time':1.0}
# outCode['pin'] = codes[1]
# try:
# value = round(float(codes[2]), 1)
# outCode['time'] = value
# pulsePins[str(n)] = {'button':str(n), 'pin':outCode['pin'], 'text':None, 'timer':0, 'counter':0, 'state':False}
# except:
# outCode = {'code':None}
if bCode.startswith('toggle-halpin '):
if len(bCode.split()) > 1 and len(bCode.split()) < 4:
codes = bCode.strip().split()
if validate_hal_pin(codes[1], n, 'toggle-halpin'):
outCode = {'code':'toggle-halpin', 'pin':codes[1], 'critical':False}
outCode['pin'] = codes[1]
if len(codes) == 3 and codes[2] == 'runcritical':
outCode['critical'] = True
criticalButtons.append(n)
togglePins[str(n)] = {'button':str(n), 'pin':outCode['pin'], 'state':hal.get_value(outCode['pin']), 'runcritical':outCode['critical']}
elif bCode and bCode not in singleCodes:
codes = bCode.strip().split('\\')
codes = [x.strip() for x in codes]
outCode['code'] = []
for cn in range(len(codes)):
if codes[cn][0] == '%':
if WHICH(codes[cn].split()[0][1:]) is not None:
outCode['code'].append(['shell', codes[cn][1:]])
else:
outCode = {'code': None}
elif codes[cn][:2].lower() == 'o<':
outCode['code'].append(['ocode', codes[cn]])
elif codes[cn][0].lower() in 'gm':
if not '{' in codes[cn]:
outCode['code'].append(['gcode', codes[cn]])
else:
reply = validate_ini_param(codes[cn], n)
if reply[0]:
outCode['code'].append(['gcode', reply[1]])
else:
outCode = {'code': None}
break
else:
outCode = {'code': None}
break
else:
outCode = {'code':None}
if not rC('winfo','exists','.fbuttons.button' + str(n)):
ubuttSize = int( int(fontSize) - 2)
#print(ubuttSize)
rC('button','.fbuttons.button' + str(n),'-takefocus',0,'-width',ubuttSize)
if bName and outCode['code']:
bHeight = 2
if type(bName) == list:
bHeight = max(len(bName[0].split('\\')), len(bName[1].split('\\')))
bName = bName[0]
else:
bHeight = len(bName.split('\\'))
bLabel = bName.replace('\\', '\n')
ubuttSize = int( int(fontSize) - 2)
rC('.fbuttons.button' + str(n),'configure','-text',bLabel,'-height',bHeight,'-bg',colorBack,'-wraplength',60,'-width',ubuttSize)
#print(ubuttSize)
# change to pack
#rC('grid','.fbuttons.button{}'.format(n),'-column',row,'-row',0,'-sticky','nsew','-padx',(2,0),'-pady',(2,0))
rC('pack','.fbuttons.button{}'.format(n),'-side','left','-fill','both','-expand',1)
rC('bind','.fbuttons.button{}'.format(n),'<ButtonPress-1>','button_action {} 1'.format(n))
rC('bind','.fbuttons.button{}'.format(n),'<ButtonRelease-1>','button_action {} 0'.format(n))
row += 1
elif bName or bCode:
title = _('USER BUTTON ERROR')
msg0 = _('is invalid code for user button')
notifications.add('error', '{}:\n"{}" {} #{}'.format(title, bCode, msg0, n))
bName = None
outCode = {'code':None}
#print (bHeight)
buttonNames[n] = {'name':bName}
buttonCodes[n] = outCode
user_button_load()
def user_button_pressed(button, code): # plasmac
global colorBack, activeFunction
# global probePressed, probeStart, probeTimer, probeButton
# global torchPressed, torchStart, torchTimer, torchButton
if rC('.fbuttons.button' + button,'cget','-state') == 'disabled' or not code:
return
from subprocess import Popen,PIPE
# ~ if code['code'] == 'ohmic-test':
# ~ hal.set_p('plasmac.ohmic-test','1')
# ~ #FIXME: TEMPORARY PRINT FOR REPORTING WINDOW SIZES
# ~ print('Width={} Height={}'.format(rC('winfo','width',root_window), rC('winfo','height',root_window)))
# ~ elif code['code'] == 'cut-type':
# ~ pass # actioned from button_release
# ~ elif code['code'] == 'single-cut':
# ~ pass # actioned from button_release
# ~ elif code['code'] == 'manual-cut':
# ~ manual_cut(None)
# ~ elif code['code'] == 'probe-test' and not hal.get_value('halui.program.is-running'):
# ~ if probeTimer:
# ~ probeTimer = 0
# ~ elif not hal.get_value('plasmac.z-offset-counts'):
# ~ activeFunction = True
# ~ probePressed = True
# ~ probeStart = time.time()
# ~ probeTimer = code['time']
# ~ hal.set_p('plasmac.probe-test','1')
# ~ rC('.fbuttons.button' + probeButton,'configure','-text',str(int(probeTimer)))
# ~ rC('.fbuttons.button' + probeButton,'configure','-bg',colorActive)
# ~ elif code['code'] == 'torch-pulse':
# ~ if torchTimer:
# ~ torchTimer = 0
# ~ elif not hal.get_value('plasmac.z-offset-counts'):
# ~ torchPressed = True
# ~ torchStart = time.time()
# ~ torchTimer = code['time']
# ~ hal.set_p('plasmac.torch-pulse-time','{}'.format(torchTimer))
# ~ hal.set_p('plasmac.torch-pulse-start','1')
# ~ rC('.fbuttons.button' + torchButton,'configure','-text',str(int(torchTimer)))
# ~ rC('.fbuttons.button' + torchButton,'configure','-bg',colorActive)
# ~ elif code['code'] == 'change-consumables' and not hal.get_value('plasmac.breakaway'):
# ~ if hal.get_value('axis.x.eoffset-counts') or hal.get_value('axis.y.eoffset-counts'):
# ~ hal.set_p('plasmac.consumable-change', '0')
# ~ hal.set_p('plasmac.x-offset', '0')
# ~ hal.set_p('plasmac.y-offset', '0')
# ~ rC('.fbuttons.button' + button,'configure','-bg',colorBack)
# ~ activeFunction = False
# ~ else:
# ~ activeFunction = True
# ~ xPos = s.position[0] if code['X'] is None else code['X']
# ~ yPos = s.position[1] if code['Y'] is None else code['Y']
# ~ hal.set_p('plasmac.xy-feed-rate', str(code['F']))
# ~ hal.set_p('plasmac.x-offset', '{:.0f}'.format((xPos - s.position[0]) / hal.get_value('plasmac.offset-scale')))
# ~ hal.set_p('plasmac.y-offset', '{:.0f}'.format((yPos - s.position[1]) / hal.get_value('plasmac.offset-scale')))
# ~ hal.set_p('plasmac.consumable-change', '1')
# ~ rC('.fbuttons.button' + button,'configure','-bg',colorOrange)
# ~ elif code['code'] == 'framing':
# ~ pass # actioned from button_release
# ~ elif code['code'] == 'load':
# ~ pass # actioned from button_release
# ~ elif code['code'] == 'latest-file':
# ~ pass # actioned from button_release
# ~ elif code['code'] == 'pulse-halpin' and hal.get_value('halui.program.is-idle'):
# ~ hal.set_p(code['pin'], str(not hal.get_value(code['pin'])))
# ~ if not pulsePins[button]['timer']:
# ~ pulsePins[button]['text'] = rC('.fbuttons.button' + button,'cget','-text')
# ~ pulsePins[button]['timer'] = code['time']
# ~ pulsePins[button]['counter'] = time.time()
# ~ else:
# ~ pulsePins[button]['timer'] = 0
# ~ rC('.fbuttons.button' + button,'configure','-text',pulsePins[button]['text'])
if code['code'] == 'toggle-halpin' and hal.get_value('halui.program.is-idle'):
hal.set_p(code['pin'], str(not hal.get_value(code['pin'])))
else:
for n in range(len(code['code'])):
if code['code'][n][0] == 'shell':
Popen(code['code'][n][1], stdout=PIPE, stderr=PIPE, shell=True)
elif code['code'][n][0] in ['gcode', 'ocode']:
if manual_ok():
ensure_mode(linuxcnc.MODE_MDI)
commands.send_mdi_command(code['code'][n][1])
def user_button_released(button, code): # plasmac
# global cutType, probePressed, torchPressed
if rC('.fbuttons.button' + button,'cget','-state') == 'disabled' or not code: return
# if code['code'] == 'ohmic-test':
# hal.set_p('plasmac.ohmic-test','0')
# elif code['code'] == 'cut-type':
# if not hal.get_value('halui.program.is-running'):
# cutType ^= 1
# if cutType:
# comp['cut-type'] = 1
# text = code['text'][1].replace('\\', '\n')
# color = colorOrange
# else:
# comp['cut-type'] = 0
# text = code['text'][0].replace('\\', '\n')
# color = colorBack
# rC('.fbuttons.button' + button,'configure','-bg',color,'-text',text)
# reload_file()
# elif code['code'] == 'single-cut':
# single_cut()
# elif code['code'] == 'manual-cut':
# pass
# elif code['code'] == 'probe-test':
# probePressed = False
# elif code['code'] == 'torch-pulse':
# torchPressed = False
# elif code['code'] == 'change-consumables':
# pass
# elif code['code'] == 'framing':
# if not code['F']:
# code['F'] = int(rC('.runs.material.cut-feed-rate', 'get'))
# frame_job(code['F'], code['Z'])
# elif code['code'] == 'load':
# commands.open_file_name(code['file'])
# elif code['code'] == 'latest-file':
# files = GLOB('{}/*.ngc'.format(code['dir']))
# latest = max(files, key=os.path.getctime)
# commands.open_file_name(latest)
# elif code['code'] == 'pulse-halpin':
# pass
# elif code['code'] == 'toggle-halpin':
# pass
else:
pass
def user_button_add(): # plasmac
for n in range(1, 20):
if not rC('winfo','ismapped',fsetup + '.tabs.fbutt.r.ubuttons.frame.num' + str(n)):
rC('grid',fsetup + '.tabs.fbutt.r.ubuttons.frame.num' + str(n),'-column',0,'-row',n,'-sticky','ne','-padx',(4,0),'-pady',(0,4))
rC('grid',fsetup + '.tabs.fbutt.r.ubuttons.frame.name' + str(n),'-column',1,'-row',n,'-sticky','nw','-padx',(4,0),'-pady',(0,4))
rC('grid',fsetup + '.tabs.fbutt.r.ubuttons.frame.code' + str(n),'-column',2,'-row',n,'-sticky','new','-padx',(4,4),'-pady',(0,4))
break
##cbbox = rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','bbox',"all")
##rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','configure','-scrollregion',(cbbox))
#cbbox = rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','bbox',("ALL"))
#rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','configure','-scrollregion',(0,0,50,500))
###rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','yview','moveto',1.0)
#print(rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','bbox',("all")))
#print(rC('winfo','children', fsetup + '.tabs.fbutt.r.ubuttons.frame'))
def user_button_load(): # plasmac
hide_buttonframe()
#rC(fsetup + '.tabs.fbutt.r.torch.enabled','delete',0,'end')
#rC(fsetup + '.tabs.fbutt.r.torch.disabled','delete',0,'end')
#rC(fsetup + '.tabs.fbutt.r.torch.enabled','insert','end',getPrefs(PREF,'BUTTONS', 'Torch enabled', 'Torch\Enabled', str))
#rC(fsetup + '.tabs.fbutt.r.torch.disabled','insert','end',getPrefs(PREF,'BUTTONS','Torch disabled', 'Torch\Disabled', str))
for n in range(1, 20):
rC('grid','forget',fsetup + '.tabs.fbutt.r.ubuttons.frame.num' + str(n))
rC('grid','forget',fsetup + '.tabs.fbutt.r.ubuttons.frame.name' + str(n))
rC('grid','forget',fsetup + '.tabs.fbutt.r.ubuttons.frame.code' + str(n))
rC(fsetup + '.tabs.fbutt.r.ubuttons.frame.name' + str(n),'delete',0,'end')
rC(fsetup + '.tabs.fbutt.r.ubuttons.frame.code' + str(n),'delete',0,'end')
if getPrefs(PREF,'BUTTONS', str(n) + ' Name', '', str) or getPrefs(PREF,'BUTTONS', str(n) + ' Code', '', str):
rC(fsetup + '.tabs.fbutt.r.ubuttons.frame.name' + str(n),'insert','end',getPrefs(PREF,'BUTTONS', str(n) + ' Name', '', str))
rC(fsetup + '.tabs.fbutt.r.ubuttons.frame.code' + str(n),'insert','end',getPrefs(PREF,'BUTTONS', str(n) + ' Code', '', str))
rC('grid',fsetup + '.tabs.fbutt.r.ubuttons.frame.num' + str(n),'-column',0,'-row',n,'-sticky','ne','-padx',(4,0),'-pady',(0,4))
rC('grid',fsetup + '.tabs.fbutt.r.ubuttons.frame.name' + str(n),'-column',1,'-row',n,'-sticky','nw','-padx',(4,0),'-pady',(0,4))
rC('grid',fsetup + '.tabs.fbutt.r.ubuttons.frame.code' + str(n),'-column',2,'-row',n,'-sticky','new','-padx',(4,4),'-pady',(0,4))
color_user_buttons()
#rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','create','window',0,0,'-anchor','nw','-window',fsetup + '.tabs.fbutt.r.ubuttons.frame')
##cbbox = rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','bbox',"all")
##rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','configure','-scrollregion',(cbbox))
hide_buttonframe()
#print(rC(fsetup + '.tabs.fbutt.r.ubuttons.frame','bbox',("all")))
#print(rC('winfo','children', fsetup + '.tabs.fbutt.r.ubuttons.frame'))
def user_button_save():