Call o-sub with toggle button

More
7 years 11 months ago #119860 by cmorley
EMBED_TAB_COMMAND = gladevcp -x {XID} -u myui.py myui.ui

Try that - ui file must be last IIRC
also if you run linuxcnc from the terminal then you can see it the button
toggles the print statement - letting us know if at least that part works.

Chris M

Please Log in to join the conversation.

More
7 years 11 months ago #119864 by FedX
Replied by FedX on topic Call o-sub with toggle button
When i start the code from terminal i get some failures:
Code:
**** GMOCCAPY INFO : postgui halfile = custom_postgui.hal ****: gladevcp: trouble looking for handlers in 'myui': HandlerClass instance has no attribute 'builder' Traceback (most recent call last): File "/usr/bin/gladevcp", line 122, in load_handlers objlist = h(halcomp,builder,useropts) File "./myui.py", line 20, in get_handlers return [HandlerClass(halcomp,builder,useropts)] File "./myui.py", line 9, in __init__ self.mdi_1 = self.builder.get_object('on_mdi_camon_activate') AttributeError: HandlerClass instance has no attribute 'builder' /usr/bin/gladevcp:212: RuntimeWarning: missing handler 'on_Cam_active_toggled' builder.connect_signals(handlers) /usr/bin/gladevcp:212: RuntimeWarning: missing handler 'on_mdi_camon_activate' builder.connect_signals(handlers) /usr/bin/gladevcp:212: RuntimeWarning: missing handler 'on_mdi_camoff_activate' builder.connect_signals(handlers)

And i have another big problem.. when a axis hits a limit joint then gmoccapy completeley freezes.., in axis i get just get a warning that one of the limit switches hits an end is that a known problem i couldnt find something

Please Log in to join the conversation.

More
7 years 11 months ago #119871 by cmorley
Oops sorry:
change the two lines to (note i removed self.):
Code:
self.mdi_1 = builder.get_object('on_mdi_camon_activate') self.mdi_2 = builder.get_object('on_mdi_camoff_activate')

I don't know anything about freezing at limit stops - other then needing to push a ignore limits button to move off the limit.
does a pop message come?
Does the GUI actually freeze on all input or is it you just can't do certain things anymore.

Chris M

Please Log in to join the conversation.

More
7 years 11 months ago #119882 by rodw
Replied by rodw on topic Call o-sub with toggle button
On the gmoccappy jog screen, there should be an ignore limits tickbox to allow you to jog off a limit switch.

In reality, the known problem is with your machine configuration as you should never be able to hit a limit switch in normal operation. You need to change your ini file settings so the joint and axis lengths fall inside the limit switches.

Please Log in to join the conversation.

More
7 years 11 months ago #119894 by FedX
Replied by FedX on topic Call o-sub with toggle button
When the limit switches are active at startup and im starting the machine without overwriting the limits, then the whole GUI freezes and crashes. Normally i should get a warning when trying to activate the machine, this is like axis act. My machine isn't connected at the moment for testing the camera and new GUI stuff, thats why linuxCNC thinks my machine is at limit. But i think gmoccapy shouldn't act like this anyways.. I'll attach a screenshot later and the terminal text.

so next problem with the handler code is the widget argument:
Code:
TypeError: on_Cam_active_toggled() takes exactly 3 arguments (2 given)

when i only call
Code:
def on_Cam_active_toggled(self, state): print 'Button 1 toggled. state: ', state if state: self.mdi_1.emit('activate') else: self.mdi_2.emit('activate')

the button "works", but when toggled first time it prints the same state as it gets untoggled
Code:
Button 1 toggled. state: <gtk.ToggleButton object at 0x8de55a4 (GtkToggleButton at 0x85da990)> Traceback (most recent call last): File "./myui.py", line 9, in on_Cam_active_toggled self.mdi_1.emit('activate') AttributeError: 'NoneType' object has no attribute 'emit' Button 1 toggled. state: <gtk.ToggleButton object at 0x8de55a4 (GtkToggleButton at 0x85da990)> Traceback (most recent call last): File "./myui.py", line 9, in on_Cam_active_toggled self.mdi_1.emit('activate') AttributeError: 'NoneType' object has no attribute 'emit'

and another question: should it really be self.mdi_1.emit('activate') or the signal name of mdi command: self.mdi_1.emit('on_mdi_camon_activate')

I'll try to understand the Gtk.ToggleButton, at the moment its really hard for me to understand all these Gtk/ Python stuff, ive never used python before

Please Log in to join the conversation.

More
7 years 11 months ago #119899 by cmorley
I apologize - it's been awhile since using gladevcp:

here is an example that will work (I tested it)

add the test.py and test.glade file to your config folder.

add these line to your INI under the heading [DISPLAY}:

EMBED_TAB_NAME = test
EMBED_TAB_LOCATION = hbtb_MDI
EMBED_TAB_COMMAND = gladevcp -x {XID} -u test.py test.glade


When you press the button it will display a message box with text about which action is running.

Chris M

Please Log in to join the conversation.

More
7 years 11 months ago #119929 by FedX
Replied by FedX on topic Call o-sub with toggle button
yes its finally working thank you!
do you have some recommended pages to learn more about python and gtk3 ? I would like to understand these functions and calls

Please Log in to join the conversation.

More
7 years 11 months ago #119935 by cmorley
Yaay - sorry about the long road there.

GladeVCP uses python2 and GTK2 in a library called PyGTK2

PyGTK2 tutorials on the net that I found useful:
georgejhunt.com/olpc/pydebug/Pygtk2Tutor...2tutorial/index.html
zetcode.com/gui/pygtk/

Python 2 is pretty easy to learn the basics pretty much any source is good.

Much of GladeVCP programming is boiler code with a few basic function.

Chris M

Please Log in to join the conversation.

More
7 years 11 months ago #120155 by FedX
Replied by FedX on topic Call o-sub with toggle button
OK i want to so something more. To get a better accuracity of the camera, i want to set it to the same height for different heights of workpieces. To do this i want to use a pop up which appears when pressing the toggle button first time. To do so i would use a gtk.dialog with a spin button.
Lets say camera height without workpiece is g53 z -100, and the workpiece has a height of 20, then the camera height should go to g53 z-100+20
That means that i have to give my .ngc the value entered to the spin button. Ist it possible to read values from .py to .ngc Files?

A nice Feature would be to use a Tool offset z for the absolute starting height of -100, because im using these offset values to calculate the x and y values of camera Offset. but i didnt find a way to move the g43 tool Offset in g53 coordinates. I use these ngc files to do so wiki.linuxcnc.org/cgi-bin/wiki.pl?Axis_Embed_Video

Best regards

Please Log in to join the conversation.

More
7 years 11 months ago #120162 by rodw
Replied by rodw on topic Call o-sub with toggle button

FedX wrote: . Ist it possible to read values from .py to .ngc Files?

Best regards


M66 En L0 will retrieve an analog pin (0-3) and store it in parameter #5399
linuxcnc.org/docs/html/gcode/m-code.html#mcode:m66

So you just need to define a pin in your python script and connect it to the analog pin motion.analog-in-nn

Please Log in to join the conversation.

Time to create page: 0.102 seconds
Powered by Kunena Forum