Custom Widget Trouble
16 Sep 2024 15:16 #310263
by joshopoke
Custom Widget Trouble was created by joshopoke
Hi all, I've been working on a custom VCP using gscreen and Glade. So far I have a semi-working VCP (not all the widgets are linked to their respective functions yet). I've been working on a simple custom widget that displays an axis position and a homed indicator LED. I realise this would be simpler to achieve just using stock widgets in Glade, but I wanted to have a practice run for if I make more complex widgets down the line. I took bits and pieces from the existing widgets found in linuxcnc/lib/python/gladevcp/ to try and get something working.
I managed to get the widget running and displaying correctly when run straight from the python code, then for a small window managed to get it to show up successfully in glade too. However I then somehow broke it to where it no longer appeared in glade, and then broke it even further so that it throws this error when running from python:
Can anyone tell me what exactly it is that can cause this error to occur? I've been running tests and googling to no avail. For bonus points, if anyone can tell me the difference between the linuxcnc/lib/python/gladevcp/ directory and the /lib/python3/dist-packages/gladevcp in terms of development (both directories have identical contents apart from the hal_python.xml file that is required for listing custom widgets).
I've attached all the files that I think might be relevant to the problem (but let me know if I missed anything). Thanks!
I managed to get the widget running and displaying correctly when run straight from the python code, then for a small window managed to get it to show up successfully in glade too. However I then somehow broke it to where it no longer appeared in glade, and then broke it even further so that it throws this error when running from python:
/usr/lib/python3/dist-packages/gi/types.py:217: Warning: cannot register existing type 'LED_DRO'
_gi.type_register(cls, namespace.get('__gtype_name__'))
Traceback (most recent call last):
File "/opt/linuxcnc/lib/python/gladevcp/led_dro.py", line 21, in <module>
class LED_DRO(Gtk.Bin):
File "/usr/lib/python3/dist-packages/gi/types.py", line 226, in __init__
super(GObjectMeta, cls).__init__(name, bases, dict_)
File "/usr/lib/python3/dist-packages/gi/types.py", line 205, in __init__
cls._type_register(cls.__dict__)
File "/usr/lib/python3/dist-packages/gi/types.py", line 217, in _type_register
_gi.type_register(cls, namespace.get('__gtype_name__'))
RuntimeError: could not create new GType: LED_DRO (subclass of GtkBin)
Can anyone tell me what exactly it is that can cause this error to occur? I've been running tests and googling to no avail. For bonus points, if anyone can tell me the difference between the linuxcnc/lib/python/gladevcp/ directory and the /lib/python3/dist-packages/gladevcp in terms of development (both directories have identical contents apart from the hal_python.xml file that is required for listing custom widgets).
I've attached all the files that I think might be relevant to the problem (but let me know if I missed anything). Thanks!
Please Log in or Create an account to join the conversation.
28 Sep 2024 09:04 #310948
by andypugh
Replied by andypugh on topic Custom Widget Trouble
Having the files in both locations might be the cause of the problem, I don't know if that is normal. (I am on a train at the moment, and though I did bring a second laptop with LinuxCNC on it, that one doesn't have Glade)
But, I am fairly sure that the built-in LinuxCNC DRO widgets have a built-in display of homing state, in that they change colour.
I realise that neither of these paragraphs answer your actual question.
But, I am fairly sure that the built-in LinuxCNC DRO widgets have a built-in display of homing state, in that they change colour.
I realise that neither of these paragraphs answer your actual question.
Please Log in or Create an account to join the conversation.
Moderators: HansU
Time to create page: 0.139 seconds