- Posts: 4819
- Thank you received: 0
İnstall glade
2 years 2 months ago #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.
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #308445
by Moutomation
Replied by Moutomation on topic İnstall glade
where is this page (I will put axis calibrations on this page)
Attachment not found
Please Log in to join the conversation.
2 years 2 months ago #308447
by Aciera
Replied by Aciera on topic İnstall glade
Here:
Attachment not found
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #308448
by Moutomation
Replied by Moutomation on topic İnstall glade
thanks a lot great
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #308455
by Moutomation
Replied by Moutomation on topic İnstall glade
Can we make this pin persistent?
#<_hal[testpanel.hal_spinbutton1-f]>
#<_hal[testpanel.hal_spinbutton1-f]>
Please Log in to join the conversation.
2 years 2 months ago #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:
then change this line in the [DISPLAY] section of your ini file from:
to this (this will automatically load the handler file when the custom panel is loaded):
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.
to try save this as 'gladevcp-handler.py' to the 'python' folder in your config:
Code:
#!/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:
Code:
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):
Code:
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'
Attachment not found
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.
Attachment not found
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #308464
by Moutomation
Replied by Moutomation on topic İnstall glade
I will try to do it now thank you very much
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #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
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
Please Log in to join the conversation.
2 years 2 months ago #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?
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':
Attachment not found
Finally are you getting any output in the terminal?
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #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.
Attachment not found
Attachment not found
Attachment not found
Please Log in to join the conversation.
Time to create page: 0.069 seconds
