İnstall glade

More
23 Aug 2024 07:18 #308442 by Aciera
Replied by Aciera on topic İnstall glade
If you mean the 'Calibration' program from the bottom row in the settings page of gmoccapy, that is one of the external programs common to all GUIs. The source code for that can be found in the '/tcl' folder.
The following user(s) said Thank You: Moutomation

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

More
23 Aug 2024 07:57 - 23 Aug 2024 07:58 #308445 by Moutomation
Replied by Moutomation on topic İnstall glade
where is this page (I will put axis calibrations on this page)
 
Attachments:
Last edit: 23 Aug 2024 07:58 by Moutomation.

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

More
23 Aug 2024 08:40 - 23 Aug 2024 08:40 #308447 by Aciera
Replied by Aciera on topic İnstall glade
Here:
 
 
Attachments:
Last edit: 23 Aug 2024 08:40 by Aciera.

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

More
23 Aug 2024 09:07 #308448 by Moutomation
Replied by Moutomation on topic İnstall glade
thanks a lot great

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

More
23 Aug 2024 11:04 - 23 Aug 2024 13:32 #308455 by Moutomation
Replied by Moutomation on topic İnstall glade
Can we make this pin persistent?
#<_hal[testpanel.hal_spinbutton1-f]>

 
Last edit: 23 Aug 2024 13:32 by Moutomation.

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

More
23 Aug 2024 13:46 #308462 by Aciera
Replied by Aciera on topic İnstall glade
the quickest solution I can come up with is to use a handler script that monitors the spinbutton in the custom gladevcp panel and saves the current value to a file if it changes. On opening the gui the script will set the spinbutton value to the value read from that file:

to try save this as 'gladevcp-handler.py' to the 'python' folder in your config:
#!/usr/bin/env python3

import hal
import os

parameter_file = 'gladepanel_parameter.txt'

class HandlerClass:


    def on_value_changed(self,hal_spinbutton1,data=None):
        changed_value = hal_spinbutton1.get_value()
        print(':gladevcp-handler: gladevcp.hal_spinbutton1 value has changed to ', changed_value)
        f = open(parameter_file, 'w')
        f.write(str(changed_value))
        f.close()

    def __init__(self, halcomp,builder,useropts):
        self.halcomp = halcomp
        self.hal_spinbutton1 = builder.get_object("hal_spinbutton1") # builder.get_object(ID of the targeted glade object)
        self.halcomp.newpin("number", hal.HAL_FLOAT, hal.HAL_IN)
        print(':gladevcp-handler: Initialized')
        print(':gladevcp-handler: gladevcp.hal_spinbutton1 value is ', self.hal_spinbutton1.get_value())
        if os.path.isfile(parameter_file):
            with open(parameter_file) as f:
                line = f.readline()
                line_parsed = list(line.strip().split('\t'))
                value = float(line_parsed[0])
                print(':gladevcp-handler: Setting gladevcp.hal_spinbutton1 value to ', value)
                self.hal_spinbutton1.set_value(value)


def get_handlers(halcomp,builder,useropts):
    return [HandlerClass(halcomp,builder,useropts)]

 then change this line in the [DISPLAY] section of your ini file from:
EMBED_TAB_COMMAND = halcmd loadusr -Wn testpanel gladevcp -c testpanel -H ./gladevcp/testpanel.hal -x {XID} ./gladevcp/testpanel.ui

to this (this will automatically load the handler file when the custom panel is loaded):
EMBED_TAB_COMMAND= halcmd loadusr -Wn testpanel gladevcp -c testpanel -u python/gladevcp-handler.py -H ./gladevcp/testpanel.hal -x {XID} ./gladevcp/testpanel.ui

To get this to work with the 'testpanel.ui' I posted earlier you need to open the panel in glade and
1. make sure the 'ID' of the spinbutton to be monitored is 'hal_spinbutton1'

 

2. add the handler to the spinbutton by opening the 'Signals' tab and writing 'on_value_changed' in the 'Handler' column of the 'value-changed' line. With this a value change in the spinbutton widget will call the on_value_changed function in the handler script.

 
Attachments:
The following user(s) said Thank You: Moutomation

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

More
23 Aug 2024 13:49 #308464 by Moutomation
Replied by Moutomation on topic İnstall glade
I will try to do it now thank you very much

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

More
23 Aug 2024 15:19 - 23 Aug 2024 15:20 #308470 by Moutomation
Replied by Moutomation on topic İnstall glade
I tried all the steps many times, I think I'm making a mistake somewhere.
A folder has been automatically created inside the Pythhon folder, its name is __pycache__ and it contains the gladevcp-handler.cpython-311.pyc file.
1-I created a new file in the folder where the configuration files are located. name: gladepanel_parameter.txt
I marked the code you sent me as executable and saved it in the python folder as gladevcp-handler.py.
I replaced the line in my 3-ini file with this code
EMBED_TAB_COMMAND= halcmd loadusr -Wn test panel gladevcp -c test panel -u python/gladevcp-handler.py -H ./gladevcp/testpanel.hal -x {XID} ./gladevcp/testpanel.ui
4-I wrote on_value_cahanged in the vlue_changed section in the glade panel.
5-id=hal_spinbutton1
Last edit: 23 Aug 2024 15:20 by Moutomation.

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

More
23 Aug 2024 15:33 #308471 by Aciera
Replied by Aciera on topic İnstall glade
So what exactly is not working?

Notes:

1. forget the __pycache__ folder, that gets created whenever the script is run. You can even delete it, doesn't matter.

2. You don't need to create 'gladepanel_parameter.txt'. If it does not exist the panel will load the default value set in the .ui and it will be created on the first change.

Open the 'Halshow' tool and check if you see your custom panel and it pins. If so does it also show a pin named 'number':

 


Finally are you getting any output in the terminal?
Attachments:

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

More
23 Aug 2024 15:49 #308472 by Moutomation
Replied by Moutomation on topic İnstall glade
I change the value. When I open it again, I see the value as 10,000 again. 

 
 
Attachments:

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

Moderators: newbynobiHansU
Time to create page: 0.203 seconds
Powered by Kunena Forum