Switch between AXIS tabs with GladeVCP button?
- phillc54
-
- Offline
- Platinum Member
-
- Posts: 5723
- Thank you received: 2095
cmorley wrote:
We should collect your code snippets and add it to the official docs.
Chris, I would be happy to put everything l have together and send it to you if you want.
Cheers, Phill.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
- Posts: 7872
- Thank you received: 2127
Chris M
Please Log in or Create an account to join the conversation.
- pferrick
-
Topic Author
- Offline
- Premium Member
-
- Posts: 89
- Thank you received: 3
Patrick
Please Log in or Create an account to join the conversation.
- pferrick
-
Topic Author
- Offline
- Premium Member
-
- Posts: 89
- Thank you received: 3
File "/usr/bin/axis", line 3524, in <module>
live_plotter.update()
File "/usr/bin/axis", line 867, in update
user_live_update()
File "/home/pferrick/.axisrc", line 20, in user_live_update
if hal.get_value('tab_switch.toggle') and not tabbing:
AttributeError: 'module' object has no attribute 'get_value'
Things got a little out of hand when I tried various modifications to the code in an effort to solve this problem...! It was then that I realized that what I'm after is a bit simpler than what you suggested (which I believe involves cycling through available tabs):
Pressing a GladVCP button named 'probe' (for example) raises a tab with the same name. Likewise for several other buttons/tabs.
I tried the following in my python file after adding a button called probe with the following handler attached to it:
def on_probe_clicked(self,widget,data=None):
root_window.tk.call(notebook,'raise', tabs[1])
which unfortunately did not work, even with the tkinter library imported. Should I expect some variation of this to work, or am I way off base? I'm also confused about why a new hal component is necessary in either case.
thanks,
Patrick
Please Log in or Create an account to join the conversation.
- phillc54
-
- Offline
- Platinum Member
-
- Posts: 5723
- Thank you received: 2095
I don't think it is possible to call root_window through GladeVCP, only from axis.py or .axisrc (or a USER_COMMAND_FILE)pferrick wrote:
I tried the following in my python file after adding a button called probe with the following handler attached to it:
def on_probe_clicked(self,widget,data=None):
root_window.tk.call(notebook,'raise', tabs[1])
What version of LinuxCNC are you running?, hal.get_value() is only available in master. There is a way around this if you are using 2.7.
Cheers, Phill.
Please Log in or Create an account to join the conversation.
- BigJohnT
-
- Offline
- Administrator
-
- Posts: 7000
- Thank you received: 1175
Axis was not designed for a touch screen, Touchy was designed for a touch screen.
As was Gmoccapy, and many folk seem to prefer that to Touchy.
(I like the mandatory physical buttons of Touchy, though the lack of graphical preview is a pity)
I have a backplot tab on my touchy...
JT
Please Log in or Create an account to join the conversation.
- tommylight
-
- Away
- Moderator
-
- Posts: 20068
- Thank you received: 6828
I used that to test if i can use a 7" touch screen for touchy and a 24" monitor for gremlin. It does work.
Please Log in or Create an account to join the conversation.
- pferrick
-
Topic Author
- Offline
- Premium Member
-
- Posts: 89
- Thank you received: 3
Patrick
Please Log in or Create an account to join the conversation.
- pferrick
-
Topic Author
- Offline
- Premium Member
-
- Posts: 89
- Thank you received: 3
Yes, I'm running 2.7.0 Basically I'm looking for the least amount of code that will switch tabs with buttons. Hopefully the way around you mentioned isn't _too_ gory...I'm trying my best to learn from all this code I'm appropriating!
tnx,
Patrick
Please Log in or Create an account to join the conversation.
- phillc54
-
- Offline
- Platinum Member
-
- Posts: 5723
- Thank you received: 2095
Change the HAL pin names in the following code to suit you button HAL pin names.
For 2.7 use this code (this will also work in master branch):
from subprocess import Popen,PIPE
def user_live_update():
try:
happy = hal.component_exists('gladevcp')
if happy:
if Popen(['halcmd','getp','gladevcp.manual-tab'],stdout=PIPE).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.tabs','raise','manual')
if Popen(['halcmd','getp','gladevcp.mdi-tab'],stdout=PIPE).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.tabs','raise','mdi')
if Popen(['halcmd','getp','gladevcp.preview-tab'],stdout=PIPE).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.right','raise','preview')
if Popen(['halcmd','getp','gladevcp.numbers-tab'],stdout=PIPE).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.right','raise','numbers')
if Popen(['halcmd','getp','gladevcp.user0-tab'],stdout=PIPE).communicate()[0].strip() == 'TRUE':
root_window.tk.call('.pane.top.right','raise','user_0')
except:
pass
A better option for master would be:
def user_live_update():
try:
if hal.get_value('gladevcp.manual-tab'):
root_window.tk.call('.pane.top.tabs','raise','manual')
elif hal.get_value('gladevcp.mdi-tab'):
root_window.tk.call('.pane.top.tabs','raise','mdi')
elif hal.get_value('gladevcp.preview-tab'):
root_window.tk.call('.pane.top.right','raise','preview')
elif hal.get_value('gladevcp.numbers-tab'):
root_window.tk.call('.pane.top.right','raise','numbers')
elif hal.get_value('gladevcp.user0-tab'):
root_window.tk.call('.pane.top.right','raise','user_0')
except:
pass
The user_0 tab if it existed would be the first GladeVCP tab that was embedded as shown here
Cheers, Phill.
Please Log in or Create an account to join the conversation.