GUI Modification Code Snippets / Toolbox
- snowgoer540
- Topic Author
- Offline
- Moderator
Less
More
- Posts: 2388
- Thank you received: 779
09 Apr 2023 14:08 #268672
by snowgoer540
GUI Modification Code Snippets / Toolbox was created by snowgoer540
This thread is intended to be a collection of code snippets for modifying the PathPilot GUI. In an effort to try to keep this thread clean, please keep discussion about the code snippets in separate threads.
Other than the code, please include the version it was applied to, what the code does, where it's applied, and known issues/barriers with the code, etc.
Other than the code, please include the version it was applied to, what the code does, where it's applied, and known issues/barriers with the code, etc.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
09 Apr 2023 14:14 #268674
by Vmax549
Replied by Vmax549 on topic GUI Modification Code Snippets / Toolbox
I LOVE IT ( TP
Please Log in or Create an account to join the conversation.
09 Apr 2023 15:23 - 09 Apr 2023 15:25 #268679
by Vmax549
Replied by Vmax549 on topic GUI Modification Code Snippets / Toolbox
These are code snippits to build Hotkeys in PathPilot. There are usefull in all version 2.0 and up.
To use you DO have to modify PathPilot's tormach_mill_ui.py file. IF you mess up with the mod it CAN
and will crash PathPilot on loading. Then you will need to know HOW to go back and fix it. That part is
a seperate discussion (
To use open the tormach_mill_ui.py file. I use Gedit to edit the file. Do a search of the file for the
words " # Escape key for stop ". That will put you in the area you need to modify. It is IN one of PathPilot's
Monitoring LOOPS. That way PathPilot sees it all the time.
WARNING: PathPilot is extremly case and indent sensitive. Look at the sections of code above and below where you are
working to make sure everything lines up.
Then Make sure you save the file ( Been there done that.
What the hotkey does is when you press it it switches you directly to that page without having to use a mouse. I included the text file
to make it easier to cut and paste.
I hope it is useful, ( TP
Insert the code snipit after that section.
# Escape key for stop
if kv == gtk.keysyms.Escape:
self.error_handler.log("ESC key - queueing stop button event")
self.enqueue_button_press_release(self.button_list)
self.tool_descript_entry.shutdown_view()
tooltipmgr.TTMgr().on_esc_key()
return True
### Insert code after this section
# F5 key for Main page
if kv == gtk.keysyms.F5:
self.error_handler.log("F5 key-Goto Main page")
ui_misc.set_current_notebook_page_by_id(UI.notebook, 'notebook_main_fixed')
self.window.show()
return True
# F6 key for work Probe page
if kv == gtk.keysyms.F6:
self.error_handler.log("F6 key-Goto File page")
ui_misc.set_current_notebook_page_by_id(UI.notebook, 'notebook_file_util_wrapping_eventbox')
self.window.show()
return True
# F7 key for Alarm Status page
if kv == gtk.keysyms.F7:
self.error_handler.log("F7 key-Goto Tool Offsets Page")
self.window.show()
return True
# F8 key for tool offsets page
if kv == gtk.keysyms.F8:
self.error_handler.log("F8 key-Goto Probe page")
ui_misc.set_current_notebook_page_by_id(UI.notebook,"probe_fixed")
self.window.show()
return True
# F9 key for Main page
if kv == gtk.keysyms.F9:
self.error_handler.log("F9 key-Goto Status page")
ui_misc.set_current_notebook_page_by_id(UI.notebook, 'alarms_fixed')
self.window.show()
return True
# F10 key for work offsets page
if kv == gtk.keysyms.F10:
self.error_handler.log("F10 key-Goto Work Offsets page")
ui_misc.set_current_notebook_page_by_id(self.notebook, 'notebook_offsets_fixed')
ui_misc.set_current_notebook_page_by_id(self.offsets_notebook, 'work_offsets_fixed')
self.window.show()
return True
# F11 key for Alarm Status page
if kv == gtk.keysyms.F11:
self.error_handler.log("F11 key-Goto Tool Offsets Page")
ui_misc.set_current_notebook_page_by_id(self.notebook, 'notebook_offsets_fixed')
ui_misc.set_current_notebook_page_by_id(self.offsets_notebook, 'tool_offsets_fixed')
self.window.show()
return True
To use you DO have to modify PathPilot's tormach_mill_ui.py file. IF you mess up with the mod it CAN
and will crash PathPilot on loading. Then you will need to know HOW to go back and fix it. That part is
a seperate discussion (
To use open the tormach_mill_ui.py file. I use Gedit to edit the file. Do a search of the file for the
words " # Escape key for stop ". That will put you in the area you need to modify. It is IN one of PathPilot's
Monitoring LOOPS. That way PathPilot sees it all the time.
WARNING: PathPilot is extremly case and indent sensitive. Look at the sections of code above and below where you are
working to make sure everything lines up.
Then Make sure you save the file ( Been there done that.
What the hotkey does is when you press it it switches you directly to that page without having to use a mouse. I included the text file
to make it easier to cut and paste.
I hope it is useful, ( TP
Insert the code snipit after that section.
# Escape key for stop
if kv == gtk.keysyms.Escape:
self.error_handler.log("ESC key - queueing stop button event")
self.enqueue_button_press_release(self.button_list)
self.tool_descript_entry.shutdown_view()
tooltipmgr.TTMgr().on_esc_key()
return True
### Insert code after this section
# F5 key for Main page
if kv == gtk.keysyms.F5:
self.error_handler.log("F5 key-Goto Main page")
ui_misc.set_current_notebook_page_by_id(UI.notebook, 'notebook_main_fixed')
self.window.show()
return True
# F6 key for work Probe page
if kv == gtk.keysyms.F6:
self.error_handler.log("F6 key-Goto File page")
ui_misc.set_current_notebook_page_by_id(UI.notebook, 'notebook_file_util_wrapping_eventbox')
self.window.show()
return True
# F7 key for Alarm Status page
if kv == gtk.keysyms.F7:
self.error_handler.log("F7 key-Goto Tool Offsets Page")
self.window.show()
return True
# F8 key for tool offsets page
if kv == gtk.keysyms.F8:
self.error_handler.log("F8 key-Goto Probe page")
ui_misc.set_current_notebook_page_by_id(UI.notebook,"probe_fixed")
self.window.show()
return True
# F9 key for Main page
if kv == gtk.keysyms.F9:
self.error_handler.log("F9 key-Goto Status page")
ui_misc.set_current_notebook_page_by_id(UI.notebook, 'alarms_fixed')
self.window.show()
return True
# F10 key for work offsets page
if kv == gtk.keysyms.F10:
self.error_handler.log("F10 key-Goto Work Offsets page")
ui_misc.set_current_notebook_page_by_id(self.notebook, 'notebook_offsets_fixed')
ui_misc.set_current_notebook_page_by_id(self.offsets_notebook, 'work_offsets_fixed')
self.window.show()
return True
# F11 key for Alarm Status page
if kv == gtk.keysyms.F11:
self.error_handler.log("F11 key-Goto Tool Offsets Page")
ui_misc.set_current_notebook_page_by_id(self.notebook, 'notebook_offsets_fixed')
ui_misc.set_current_notebook_page_by_id(self.offsets_notebook, 'tool_offsets_fixed')
self.window.show()
return True
Last edit: 09 Apr 2023 15:25 by Vmax549.
The following user(s) said Thank You: tommylight, Dorro1971
Please Log in or Create an account to join the conversation.
09 Apr 2023 19:52 - 09 Apr 2023 23:05 #268706
by Vmax549
Replied by Vmax549 on topic Code Snippet to TOOGLE the jog incr/cont by pressing F12
This is a code snippets to build a Hotkey for toggling the JOG incr/cont in PathPilot. It is usefull in all version 2.0 and up.
To use you DO have to modify PathPilot's tormach_mill_ui.py file. IF you mess up with the mod it CAN
and will crash PathPilot on loading. Then you will need to know HOW to go back and fix it. That part is
a seperate discussion (
To use open the tormach_mill_ui.py file. I use Gedit to edit the file. Do a search of the file for the
words " # Escape key for stop ". That will put you in the area you need to modify. It is IN one of PathPilot's
Monitoring LOOPS. That way PathPilot sees it all the time.
WARNING: PathPilot is extremly case and indent sensitive. Look at the sections of code above and below where you are
working to make sure everything lines up.
Then Make sure you save the file ( Been there done that.
What the hotkey does is when you press it it TOOGLES the Jog incr/cont directly without having to use a mouse. ( TP
To use you DO have to modify PathPilot's tormach_mill_ui.py file. IF you mess up with the mod it CAN
and will crash PathPilot on loading. Then you will need to know HOW to go back and fix it. That part is
a seperate discussion (
To use open the tormach_mill_ui.py file. I use Gedit to edit the file. Do a search of the file for the
words " # Escape key for stop ". That will put you in the area you need to modify. It is IN one of PathPilot's
Monitoring LOOPS. That way PathPilot sees it all the time.
WARNING: PathPilot is extremly case and indent sensitive. Look at the sections of code above and below where you are
working to make sure everything lines up.
Then Make sure you save the file ( Been there done that.
What the hotkey does is when you press it it TOOGLES the Jog incr/cont directly without having to use a mouse. ( TP
# F12 key for tool offsets page
if kv == gtk.keysyms.F12:
self.error_handler.log("F12 key-Toogle Jog to INCR or Cont ")
self.enqueue_button_press_release(self.button_list['jog_inc_cont'])
self.window.show()
return True
Last edit: 09 Apr 2023 23:05 by Vmax549.
The following user(s) said Thank You: Dorro1971
Please Log in or Create an account to join the conversation.
09 Apr 2023 20:55 #268712
by Vmax549
Replied by Vmax549 on topic Path Pilot Rigid PECK tapping
Here is a Sub Routine that lets you PECK rigid tap if your machine can do rigid tapping. Copy the file to your Sub Routine folder. It can be used in a Gcode File or from the MDI. To Call it is o<rtp> call [ ] [ ] [ ] where the 3 bracketsets are parameters. They read from left to right as 1 2 3. 1= thread depth, 2 = thread pitch and 3 = peck depth.
In the example call you would declare it as o<rtp> call [-.500] [.050] [-.1] . That would tap to -.500 using a pitch of .050 and a peck depth of -.1. It starts from the current positions of XYZ and taps down to -.1 and retracts then repeats down to -.2 and retracts , etc,etc. When the distance left to tap is less than peck value it taps to the max depth and retracts.
This is NOT a canned cycle so it is a 1 shot call. Taps one hole. It is strictly a test article to proof the function.
It can be very useful with reduced HP spindles and working with sticky,gummy or hard materials. You can also deep tap 1 thread at a time letting the coolant flush the chips out of the hole as you go.
o<rtp> sub
(Rigid Peck Tapping 2023-03-26 09:54:08 )
M3 S100
M8
#<zbot> = #1 ( -.500 Z thread depth)
#<pitch> = #2 ( .050 K thread pitch)
#<zpec> = #3 ( -.1 Q peck depth)
#<ztap> = 0 (Current Tap Depth)
o100 while[#<ztap> GE #<zbot>]
o101 if[[#<zbot> - #<ztap>] LT #<zpec>]
#<ztap> = #<ztap>
o101 else
#<ztap> = #<zbot>
o101 endif
G33.1 Z#<ztap> K#<pitch>
#<ztap> = [#<ztap> + #<zpec>]
o100 endwhile
M9
M5
o<rtp> endsub
M30
In the example call you would declare it as o<rtp> call [-.500] [.050] [-.1] . That would tap to -.500 using a pitch of .050 and a peck depth of -.1. It starts from the current positions of XYZ and taps down to -.1 and retracts then repeats down to -.2 and retracts , etc,etc. When the distance left to tap is less than peck value it taps to the max depth and retracts.
This is NOT a canned cycle so it is a 1 shot call. Taps one hole. It is strictly a test article to proof the function.
It can be very useful with reduced HP spindles and working with sticky,gummy or hard materials. You can also deep tap 1 thread at a time letting the coolant flush the chips out of the hole as you go.
o<rtp> sub
(Rigid Peck Tapping 2023-03-26 09:54:08 )
M3 S100
M8
#<zbot> = #1 ( -.500 Z thread depth)
#<pitch> = #2 ( .050 K thread pitch)
#<zpec> = #3 ( -.1 Q peck depth)
#<ztap> = 0 (Current Tap Depth)
o100 while[#<ztap> GE #<zbot>]
o101 if[[#<zbot> - #<ztap>] LT #<zpec>]
#<ztap> = #<ztap>
o101 else
#<ztap> = #<zbot>
o101 endif
G33.1 Z#<ztap> K#<pitch>
#<ztap> = [#<ztap> + #<zpec>]
o100 endwhile
M9
M5
o<rtp> endsub
M30
Attachments:
The following user(s) said Thank You: Dorro1971
Please Log in or Create an account to join the conversation.
01 May 2023 07:34 #270386
by Vmax549
Replied by Vmax549 on topic Path Pilot Rigid PECK tapping
Here is a section of code that creates hotkeys to change the Work Offsets G54 -G59.3. When in use use the Ctrl_NUMBER to shift the work offset.
Ctrl_4 = G54
Ctrl_5 = G55
Ctrl_6 = G56
etc
etc
Ctrl_1 = G59.1
Ctrl_2 = G59.2
Ctrl_3 = G59.3
It works with both keyboard numbers and Keypad(tenkey) numbers
( TP
Ctrl_4 = G54
Ctrl_5 = G55
Ctrl_6 = G56
etc
etc
Ctrl_1 = G59.1
Ctrl_2 = G59.2
Ctrl_3 = G59.3
It works with both keyboard numbers and Keypad(tenkey) numbers
( TP
Attachments:
The following user(s) said Thank You: Dorro1971
Please Log in or Create an account to join the conversation.
15 May 2023 16:31 #271406
by Vmax549
Replied by Vmax549 on topic GUI Modification Code Snippets / Toolbox
For anyone interested in trying Wizards in PP here is the scripts to crate a Wizards Menu in the MDI Admin function.
##### Add to end of Admincmd ***********************
class WizardMenuCmd(AdminCmd):
def __init__(self, name, doc, uibase):
super(WizardMenuCmd, self).__init__(name, doc)
self.uibase = uibase
self._help = 'Load PathPilot Wizards.'
def activate(self, arglist):
# arglist is remaining args in case we need our own parser for that.
self.uibase._run_mdi_admin_program()
##### End of Add to AdminCMD **************************************************
##### Add The file Wizard_Menu.py to the TMC scripts folder *******************************
#!/usr/bin/env python
# coding=utf-8
#
import os
from Tkinter import *
import tkFileDialog
from tkFileDialog import askopenfilename
path = "/home/operator/gcode/wizards"
filename = tkFileDialog.askopenfilename(initialdir = ""+path,
title = "Select a Wizard File",
filetypes = (("Wizard Files","*.ppw*"),("All Files","*.py")))
os.chdir("/home/operator/gcode/wizards/")
os.system(""+filename )
##### End of add to file folder **************************************************
##### Add to end of Admincmd ***********************
class WizardMenuCmd(AdminCmd):
def __init__(self, name, doc, uibase):
super(WizardMenuCmd, self).__init__(name, doc)
self.uibase = uibase
self._help = 'Load PathPilot Wizards.'
def activate(self, arglist):
# arglist is remaining args in case we need our own parser for that.
self.uibase._run_mdi_admin_program()
##### End of Add to AdminCMD **************************************************
##### Add The file Wizard_Menu.py to the TMC scripts folder *******************************
#!/usr/bin/env python
# coding=utf-8
#
import os
from Tkinter import *
import tkFileDialog
from tkFileDialog import askopenfilename
path = "/home/operator/gcode/wizards"
filename = tkFileDialog.askopenfilename(initialdir = ""+path,
title = "Select a Wizard File",
filetypes = (("Wizard Files","*.ppw*"),("All Files","*.py")))
os.chdir("/home/operator/gcode/wizards/")
os.system(""+filename )
##### End of add to file folder **************************************************
Attachments:
Please Log in or Create an account to join the conversation.
06 Jun 2023 01:40 - 06 Jun 2023 02:03 #272995
by gerritv
Replied by gerritv on topic GUI Modification Code Snippets / Toolbox
For the Wizard Menu, you also need to add:
admincmd.WizardMenuCmd(name='WIZARD_MENU', doc=True, uibase=self)
to the end of init_admin_commands in ui_common.py (around line 3896 in V2.9.4)
And the line self.uibase._run_mdi_admin_program()'
needs to read self.uibase._run_mdi_admin_program() as well as setting the Execute flag on Wizard_Menu.py
Last, any script you intend to run must have #!/usr/bin/env python at top of file. the wizrds on github won't run unless you make this change.
Thank you vmax549 for making this happen, it is very useful.
Gerrit
admincmd.WizardMenuCmd(name='WIZARD_MENU', doc=True, uibase=self)
to the end of init_admin_commands in ui_common.py (around line 3896 in V2.9.4)
And the line self.uibase._run_mdi_admin_program()'
needs to read self.uibase._run_mdi_admin_program() as well as setting the Execute flag on Wizard_Menu.py
Last, any script you intend to run must have #!/usr/bin/env python at top of file. the wizrds on github won't run unless you make this change.
Thank you vmax549 for making this happen, it is very useful.
Gerrit
Last edit: 06 Jun 2023 02:03 by gerritv.
Please Log in or Create an account to join the conversation.
18 Jul 2023 16:53 #275748
by Whitebarn
Replied by Whitebarn on topic GUI Modification Code Snippets / Toolbox
Hi, where do you enter this information? Great work by the way! I've been looking for this info for a while!
Please Log in or Create an account to join the conversation.
18 Jul 2023 23:48 #275775
by gerritv
Replied by gerritv on topic GUI Modification Code Snippets / Toolbox
see top of this post: forum.linuxcnc.org/pathpilot/48745-gui-m...ppets-toolbox#271406
Please Log in or Create an account to join the conversation.
Moderators: cncbasher
Time to create page: 0.098 seconds