Switch between AXIS tabs with GladeVCP button?
09 Feb 2019 03:43 #126032
by pferrick
Replied by pferrick on topic Switch between AXIS tabs with GladeVCP button?
Thanks, Phill...I will try this soon. By the way, since I keep bumping into things that work better (or at all) in the master branch...I have to ask:
What, exactly, is the master branch?!
Where would I find details about getting it, and what downside (if any) am I looking at if I do so?
I don't recall seeing anything about it on the usual sites, which I suppose might mean that it's something I had better avoid!!!!
regards,
Patrick
What, exactly, is the master branch?!
Where would I find details about getting it, and what downside (if any) am I looking at if I do so?
I don't recall seeing anything about it on the usual sites, which I suppose might mean that it's something I had better avoid!!!!
regards,
Patrick
Please Log in or Create an account to join the conversation.
09 Feb 2019 03:56 #126035
by pferrick
Replied by pferrick on topic Switch between AXIS tabs with GladeVCP button?
OK, a quick search of the forum turns up plenty of answers to the middle question, ie. installing...but not too much about why one might run it.
Just wondering.
PKF
Just wondering.
PKF
Please Log in or Create an account to join the conversation.
09 Feb 2019 05:02 #126036
by phillc54
I guess you would use master if you had a requirement that was not met by 2.7 ...
Master may not be stable as it is being altered/added to frequently and some would say not to use it in production machines while some use it all the time and have done so for quite some time. I use master on a mill and two lathes and am currently (slowly) making a plasma cutting table that will also use master.
Like most things, I think it just comes down to personal choice.
Probably the best way to try it is to clone the git repo and build a run in place version, that way you can leave your original 2.7 installation as is. Just keep a copy of your linuxcnc folder (all your configs) somewhere as a backup. When you first run an existing 2.7 config with master it will perform an update (if you answer in the affirmative) to the config files and will also make a backup copy of the originals.
Building LinuxCNC
Cheers, Phill.
Replied by phillc54 on topic Switch between AXIS tabs with GladeVCP button?
OK, a quick search of the forum turns up plenty of answers to the middle question, ie. installing...but not too much about why one might run it.
Just wondering.
I guess you would use master if you had a requirement that was not met by 2.7 ...
Master may not be stable as it is being altered/added to frequently and some would say not to use it in production machines while some use it all the time and have done so for quite some time. I use master on a mill and two lathes and am currently (slowly) making a plasma cutting table that will also use master.
Like most things, I think it just comes down to personal choice.
Probably the best way to try it is to clone the git repo and build a run in place version, that way you can leave your original 2.7 installation as is. Just keep a copy of your linuxcnc folder (all your configs) somewhere as a backup. When you first run an existing 2.7 config with master it will perform an update (if you answer in the affirmative) to the config files and will also make a backup copy of the originals.
Building LinuxCNC
Cheers, Phill.
Please Log in or Create an account to join the conversation.
12 Feb 2019 03:31 #126245
by pferrick
Replied by pferrick on topic Switch between AXIS tabs with GladeVCP button?
Hi Phill-
Thanks again for the expert advice. Things are humming along nicely (well, with the exception of my deleting a critical RTAI file that I have to figure out how to resurrect! But that's another story...)
A couple of other (low priority) questions occur to me regarding switching AXIS tabs "remotely":
1. Is it true that in master, I might be able to go beyond the 4-tab limit imposed by the timing? It's working great with 4 buttons / 4 tabs but ideally I'd like to have 8 tabs and 8 buttons...! I'm wondering if perhaps master goes about polling differently which might help with this?
2. Is there a any way (in master) that I might switch tabs via GladeVCP other than in .axisrc? Again, not critical but it would be great if when, for example I loaded a file with an IconFileView (on a tab) it also raised the backplot tab.
I'm leaning toward trying master alongside 2.7, and I guess I'm looking for more reasons to take the plunge...!
tnx,
Patrick
Thanks again for the expert advice. Things are humming along nicely (well, with the exception of my deleting a critical RTAI file that I have to figure out how to resurrect! But that's another story...)
A couple of other (low priority) questions occur to me regarding switching AXIS tabs "remotely":
1. Is it true that in master, I might be able to go beyond the 4-tab limit imposed by the timing? It's working great with 4 buttons / 4 tabs but ideally I'd like to have 8 tabs and 8 buttons...! I'm wondering if perhaps master goes about polling differently which might help with this?
2. Is there a any way (in master) that I might switch tabs via GladeVCP other than in .axisrc? Again, not critical but it would be great if when, for example I loaded a file with an IconFileView (on a tab) it also raised the backplot tab.
I'm leaning toward trying master alongside 2.7, and I guess I'm looking for more reasons to take the plunge...!
tnx,
Patrick
Please Log in or Create an account to join the conversation.
12 Feb 2019 04:24 - 12 Feb 2019 04:25 #126248
by phillc54
Replied by phillc54 on topic Switch between AXIS tabs with GladeVCP button?
The last lot of code I posted shows how to do more than 4 tabs in 2.7, it just splits the tabs up into groups of 4 and runs through one group each poll (normally about 0.1 secs between polls).
In master i did eight tabs but I don't know the limit.
The difference is master uses the python hal library while in 2.7 we need to call the command line hal through Popen which is much slower...
I don't know if GladeVCP can access the tcl/tk part of Axis, Chris M would be the better person to ask about that.
The .axisrc file is read by all configs, if you use multiple configs on one machine (or even just one) you can use a USER_COMMAND_FILE ( see @ the end of the DISPLAY section ) rather than .axisrc and then keep a file for each config in the config directory.
Cheers, Phill.
In master i did eight tabs but I don't know the limit.
The difference is master uses the python hal library while in 2.7 we need to call the command line hal through Popen which is much slower...
I don't know if GladeVCP can access the tcl/tk part of Axis, Chris M would be the better person to ask about that.
The .axisrc file is read by all configs, if you use multiple configs on one machine (or even just one) you can use a USER_COMMAND_FILE ( see @ the end of the DISPLAY section ) rather than .axisrc and then keep a file for each config in the config directory.
Cheers, Phill.
Last edit: 12 Feb 2019 04:25 by phillc54. Reason: typo
Please Log in or Create an account to join the conversation.
15 Feb 2019 22:38 #126588
by pferrick
Replied by pferrick on topic Switch between AXIS tabs with GladeVCP button?
Hi Chris-
With much help from Phill I've managed to get things arranged so that I can switch AXIS tabs with a GladeVCP button, with the following in my .axisrc:
which works great. I'm wondering if you know of any way to raise the Preview tab from python code attached to various user tabs? I tried adding that last root_window call to file.py (which goes along with my 'File Open' tab) like this:
but that didn't work, and produced this error:
Traceback (most recent call last):
File "./Python/file.py", line 26, in on_file_selected
root_window.tk.call('.pane.top.right','raise','user_2')
NameError: global name 'root_window' is not defined
It's certainly not critical that the Preview tab be raised automatically after choosing a g-code file, but it would be very convenient!
Thanks,
Patrick
With much help from Phill I've managed to get things arranged so that I can switch AXIS tabs with a GladeVCP button, with the following in my .axisrc:
from subprocess import Popen, PIPE
scanNumber = 0
def user_live_update():
global scanNumber
try:
happy = hal.component_exists('gladevcp')
if happy:
if scanNumber == 0:
if Popen('halcmd getp gladevcp.backplot',stdout=PIPE,shell=True).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.right','raise','preview')
if Popen('halcmd getp gladevcp.probe',stdout=PIPE,shell=True).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.right','raise','user_0')
if Popen('halcmd getp gladevcp.toolchange',stdout=PIPE,shell=True).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.right','raise','user_1')
scanNumber = 1
else:
if Popen('halcmd getp gladevcp.file',stdout=PIPE,shell=True).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.right','raise','user_2')
scanNumber = 0
except Exception:
traceback.print_exc()
which works great. I'm wondering if you know of any way to raise the Preview tab from python code attached to various user tabs? I tried adding that last root_window call to file.py (which goes along with my 'File Open' tab) like this:
import subprocess
class HandlerClass:
def __init__(self, halcomp, builder, useropts):
# make a class reference to builder
# (self.ANYTHING is available anywhere in the HandlerClas class)
self.builder = builder
# make a class reference to the open vcp_action
self.open = builder.get_object('open')
# change a property in the iconchooser so all programs show
# this shouldn't be required - it's a bug
#builder.get_object('file').set_property("filetypes", '*')
# This is a callback function from the icon chooser selected in the GLADE signal editor
# in GTK the first variable is always the widget that owned the signal that called this function
# any other variables depend on the widget, in this case icon view sends the path
def on_file_selected(self, widget, path):
if path:
print path
subprocess.call('axis-remote %s' % path, shell=True)
root_window.tk.call('.pane.top.right','raise','user_2') <===== I added this line
# boiler code
def get_handlers(halcomp,builder,useropts):
return [HandlerClass(halcomp,builder,useropts)]
but that didn't work, and produced this error:
Traceback (most recent call last):
File "./Python/file.py", line 26, in on_file_selected
root_window.tk.call('.pane.top.right','raise','user_2')
NameError: global name 'root_window' is not defined
It's certainly not critical that the Preview tab be raised automatically after choosing a g-code file, but it would be very convenient!
Thanks,
Patrick
Please Log in or Create an account to join the conversation.
16 Feb 2019 00:56 #126594
by cmorley
Replied by cmorley on topic Switch between AXIS tabs with GladeVCP button?
yes none of the references in the .axisrc file are available to gladevcp - they are two different programs - that's why we use HAL pins and Popen to comunicate between them.
You could make a HAL pin to request tab change, and have AXIS monitor it.
A HAL IO pin is probably the easiest to use.
Have Gladevcp set it true to change to the plot tab when the file is loaded.
have AXIS monitor it - if it's true set the tab visible and then set the pin false again.
hmm or guessing by your code - you have a Gladevcp button for plot tab already - you could 'press' the button programmatically when the file loads.
I'll get back to you with sample code for pressing buttons programmatically later.
Chris M
You could make a HAL pin to request tab change, and have AXIS monitor it.
A HAL IO pin is probably the easiest to use.
Have Gladevcp set it true to change to the plot tab when the file is loaded.
have AXIS monitor it - if it's true set the tab visible and then set the pin false again.
hmm or guessing by your code - you have a Gladevcp button for plot tab already - you could 'press' the button programmatically when the file loads.
I'll get back to you with sample code for pressing buttons programmatically later.
Chris M
Please Log in or Create an account to join the conversation.
16 Feb 2019 02:51 #126595
by pferrick
Replied by pferrick on topic Switch between AXIS tabs with GladeVCP button?
Hey- Those are two good ideas, Chris. I think I get what you mean about .axisrc- it's a chunk of python code that AXIS runs, whereas file.py is python code run by GladeVCP.
Two completely separate processes. Correct me if I'm wrong about that please.
However, I don't believe there's anything in file.py that raises the tab containing file.glade (embedded with several others alongside AXIS via the ini file). Ahh, so if we can get any old GladeVCP button to fire off the same signal that the 'Plot' button does (which triggers the code in .axisrc to raise the plot tab)...voila. Y'know, I think this is really starting to sink in!
Thanks again.
Patrick
Two completely separate processes. Correct me if I'm wrong about that please.
However, I don't believe there's anything in file.py that raises the tab containing file.glade (embedded with several others alongside AXIS via the ini file). Ahh, so if we can get any old GladeVCP button to fire off the same signal that the 'Plot' button does (which triggers the code in .axisrc to raise the plot tab)...voila. Y'know, I think this is really starting to sink in!
Thanks again.
Patrick
Please Log in or Create an account to join the conversation.
16 Feb 2019 02:54 #126596
by cmorley
Replied by cmorley on topic Switch between AXIS tabs with GladeVCP button?
Try this (need to change the button name)
import subprocess
class HandlerClass:
def __init__(self, halcomp, builder, useropts):
# make a class reference to builder
# (self.ANYTHING is available anywhere in the HandlerClas class)
self.builder = builder
# make a class reference to the open vcp_action
self.open = builder.get_object('open')
# change a property in the iconchooser so all programs show
# this shouldn't be required - it's a bug
#builder.get_object('file').set_property("filetypes", '*')
# This is a callback function from the icon chooser selected in the GLADE signal editor
# in GTK the first variable is always the widget that owned the signal that called this function
# any other variables depend on the widget, in this case icon view sends the path
def on_file_selected(self, widget, path):
if path:
print path
subprocess.call('axis-remote %s' % path, shell=True)
# switch tab by 'clicking' button
self.builder.get_object('BUTTON_NAME_HERE').emit('clicked')
# boiler code
def get_handlers(halcomp,builder,useropts):
return [HandlerClass(halcomp,builder,useropts)]
Please Log in or Create an account to join the conversation.
16 Feb 2019 03:01 #126597
by cmorley
This code in axisrc:Leads me to beleive you already have something in gladevcp that switches the plot tab? I assumed it's a button.
The code i posted shows how to click that button programmatically, which will change the HAL pin, which should make .axisrc change the plot.
If I assumed everything correctly
Replied by cmorley on topic Switch between AXIS tabs with GladeVCP button?
Absolutely rightHey- Those are two good ideas, Chris. I think I get what you mean about .axisrc- it's a chunk of python code that AXIS runs, whereas file.py is python code run by GladeVCP.
Two completely separate processes. Correct me if I'm wrong about that please.
However, I don't believe there's anything in file.py that raises the tab containing file.glade (embedded with several others alongside AXIS via the ini file). Ahh, so if we can get any old GladeVCP button to fire off the same signal that the 'Plot' button does (which triggers the code in .axisrc to raise the plot tab)...voila. Y'know, I think this is really starting to sink in!
This code in axisrc:
f Popen('halcmd getp gladevcp.backplot',stdout=PIPE,shell=True).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.right','raise','preview')
The code i posted shows how to click that button programmatically, which will change the HAL pin, which should make .axisrc change the plot.
If I assumed everything correctly
Please Log in or Create an account to join the conversation.
Time to create page: 0.260 seconds