Switch between AXIS tabs with GladeVCP button?

More
30 Jan 2019 10:05 #125267 by phillc54

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.

The following user(s) said Thank You: tommylight, rodw

Please Log in or Create an account to join the conversation.

More
30 Jan 2019 12:18 #125276 by cmorley
Perfect please do!

Chris M
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
30 Jan 2019 14:46 - 30 Jan 2019 14:47 #125293 by pferrick
Holy ^*%$*^% !!! That is fantastic, Phill! I can hardly wait to get home from work to try this out!

Patrick
Last edit: 30 Jan 2019 14:47 by pferrick.

Please Log in or Create an account to join the conversation.

More
30 Jan 2019 22:11 - 30 Jan 2019 22:13 #125346 by pferrick
Thanks again Phill for the quick answer. I tried putting the code you posted into my .axisrc and python files, and had the following error:

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
Last edit: 30 Jan 2019 22:13 by pferrick.

Please Log in or Create an account to join the conversation.

More
30 Jan 2019 22:24 - 30 Jan 2019 22:36 #125347 by phillc54

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])

I don't think it is possible to call root_window through GladeVCP, only from axis.py or .axisrc (or a USER_COMMAND_FILE)

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.
Last edit: 30 Jan 2019 22:36 by phillc54. Reason: fingers too fast for brain...

Please Log in or Create an account to join the conversation.

More
30 Jan 2019 23:01 #125349 by BigJohnT

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.

More
30 Jan 2019 23:45 #125352 by tommylight
And you can load gremlin_view as an app from touchy.
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.

More
31 Jan 2019 00:01 #125354 by pferrick
Is Gremiln the backplot used in gmoccapy by default? I find that on my screen at least the backplot doesn't look quite as good in gmoccapy as it does in AXIS.

Patrick

Please Log in or Create an account to join the conversation.

More
31 Jan 2019 00:06 #125355 by pferrick
Hi Phill-

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.

More
31 Jan 2019 00:52 - 31 Jan 2019 04:19 #125361 by phillc54
Create a HAL button for each tab in your GladeVCP panel then use either of the following code snippets in .axisrc
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.
Last edit: 31 Jan 2019 04:19 by phillc54.

Please Log in or Create an account to join the conversation.

Time to create page: 0.094 seconds
Powered by Kunena Forum