Gremlin

More
15 Dec 2012 21:26 - 15 Dec 2012 21:36 #27765 by BigJohnT
Replied by BigJohnT on topic Gremlin
I'm attempting to load gremlin into my GUI at run time with this:

import linuxcnc, hal, gremlin
self.grem = gremlin
self.plot.pack_start(self.grem)
self.plot.reorder_child(self.grem, 1)

And I get this error:
File "/usr/bin/gui7", line 41, in __init__
self.plot.pack_start(self.grem)
TypeError: Gtk.Box.pack_start() argument 1 must be gtk.Widget, not module

I successfully loaded a label into the correct spot so I know that much is ok.

More guessing and now I get this:

self.grem = gremlin.Gremlin()
TypeError: __init__() takes exactly 2 arguments (1 given)

Even more guessing and now I get this:

File "/usr/bin/gui7", line 40, in __init__
self.grem = gremlin.Gremlin(self.plot)
File "/usr/lib/pymodules/python2.6/gremlin.py", line 81, in __init__
self.get_geometry()
File "/usr/lib/pymodules/python2.6/gremlin.py", line 245, in get_geometry
temp = self.inifile.find("DISPLAY", "GEOMETRY")
AttributeError: 'gtk.HBox' object has no attribute 'find'
Exception AttributeError: "'Gremlin' object has no attribute '_dlists'" in <bound method Gremlin.__del__ of <Gremlin object at 0x9e725cc (GtkDrawingArea at 0x9f10858)>> ignored

I think I'm making progress but don't know... not sure what the AttributeError is about...


John
Last edit: 15 Dec 2012 21:36 by BigJohnT.

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

More
15 Dec 2012 22:10 #27767 by BigJohnT
Replied by BigJohnT on topic Gremlin
Ok, I think I spotted something. The Gremlin class init needs the path to the ini file... now to figure out how to supply that.

John

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

More
16 Dec 2012 02:59 - 16 Dec 2012 03:04 #27776 by cmorley
Replied by cmorley on topic Gremlin

A query re Gremlin and python for you or Chris, John

It has a method self.clear_live_plotter() which I want to bind to a keyboard combination to make it work in the same way as Axis

I have wasted a lot of time trying to get XXX.bind("Ctrl k", self.clear_live_plotter()) to work, but have been unable to determine what should replace XXX

Reading docs it just needs to be the frame window or widget, but everything I have tried errors with
File "/usr/local/bin/gremlin", line 27, in __init__
XXX.bind("<Control-k>", self.clear_live_plotter())
AttributeError: 'XXX' object has no attribute 'bind'

or similar

Any ideas?

regards


There is no bind method in pygtk that is from Tk I think( you found it in AXIS I'm thinking)

Looking in the net I see Pygtk has accelerators for this.
Here are samples I have not used but found: (by the way zetcode.com is a very good reference for different languages)
zetcode.com/tutorials/gtktutorial/menusandtoolbars/
www.islascruz.org/html/index.php?Blog/Si...eyboard-accelerators
www.pygtk.org/pygtk2tutorial/sec-WidgetAccelerators.html

Hope that helps
Last edit: 16 Dec 2012 03:04 by cmorley.

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

More
16 Dec 2012 03:17 #27777 by cmorley
Replied by cmorley on topic Gremlin

Ok, I think I spotted something. The Gremlin class init needs the path to the ini file... now to figure out how to supply that.

John


John if you look at hal_gremlin this might help you do what you wish.
Hal_gremlin is a "wrapper' around gremlin so it can be used in gladevcp.

for instance here is how it creates an instance of gremlin:

def __init__(self, *a, **kw):
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
inifile = linuxcnc.ini(inifile)
gremlin.Gremlin.__init__(self, inifile)

self.gstat = GStat()
self.gstat.connect('file-loaded', lambda w, f: self._load(f))
self.show()

it get the inifile info and calls gremlin init directly
after that it creates an instance of GStat and connects it to self_load to automatically load the current program.
GStat is a object that keeps track of some of linuxcnc's info and emits signals based on them.

Not sure if that helps you. It's all a bit above my complete understanding - so I have to do a lot of testing too!

Chris M

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

More
16 Dec 2012 04:07 - 16 Dec 2012 04:08 #27778 by cmorley
Replied by cmorley on topic Gremlin

[quote="
There is no bind method in pygtk that is from Tk I think( you found it in AXIS I'm thinking)

Looking in the net I see Pygtk has accelerators for this.
Here are samples I have not used but found: (by the way zetcode.com is a very good reference for different languages)
zetcode.com/tutorials/gtktutorial/menusandtoolbars/
www.islascruz.org/html/index.php?Blog/Si...eyboard-accelerators
www.pygtk.org/pygtk2tutorial/sec-WidgetAccelerators.html

Hope that helps


I tested this in Gscreen it worked:

accel_group = gtk.AccelGroup()
accel_group.connect_group(ord('q'), gtk.gdk.CONTROL_MASK,
gtk.ACCEL_LOCKED, gtk.main_quit)
self.widgets.window1.add_accel_group(accel_group)

self.widgets.window1 is my reference to the main window
changing gtk.main_quit to any other callback should work fine too

Chris M
Last edit: 16 Dec 2012 04:08 by cmorley.

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

More
16 Dec 2012 04:30 #27779 by BigJohnT
Replied by BigJohnT on topic Gremlin

Ok, I think I spotted something. The Gremlin class init needs the path to the ini file... now to figure out how to supply that.

John


John if you look at hal_gremlin this might help you do what you wish.
Hal_gremlin is a "wrapper' around gremlin so it can be used in gladevcp.

for instance here is how it creates an instance of gremlin:

def __init__(self, *a, **kw):
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
inifile = linuxcnc.ini(inifile)
gremlin.Gremlin.__init__(self, inifile)

self.gstat = GStat()
self.gstat.connect('file-loaded', lambda w, f: self._load(f))
self.show()

it get the inifile info and calls gremlin init directly
after that it creates an instance of GStat and connects it to self_load to automatically load the current program.
GStat is a object that keeps track of some of linuxcnc's info and emits signals based on them.

Not sure if that helps you. It's all a bit above my complete understanding - so I have to do a lot of testing too!

Chris M


Real quick testing keeps giving me errors but looking at gremlin-run I think I see some hints there...

Thanks
John

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

More
16 Dec 2012 19:22 #27782 by ArcEye
Replied by ArcEye on topic Gremlin

There is no bind method in pygtk that is from Tk I think( you found it in AXIS I'm thinking)

I tested this in Gscreen it worked:

accel_group = gtk.AccelGroup()
accel_group.connect_group(ord('q'), gtk.gdk.CONTROL_MASK,
gtk.ACCEL_LOCKED, gtk.main_quit)
self.widgets.window1.add_accel_group(accel_group)

self.widgets.window1 is my reference to the main window
changing gtk.main_quit to any other callback should work fine too

Chris M


Thank Chris, I will play with it this afternoon hopefully.

I just think of it all as python, wasn't thinking that gtk was different to Tk, but of course there are loads of different python bindings based on various windowing libraries.

Once I get that sorted, I can resume something more productive

cheers

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

More
17 Dec 2012 19:53 - 17 Dec 2012 19:55 #27799 by ArcEye
Replied by ArcEye on topic Gremlin
Well I tried.

I created an accel group
accel_group = gtk.AccelGroup()
accel_group.connect_group(ord('k'), gtk.gdk.CONTROL_MASK,gtk.ACCEL_LOCKED, callback1)
self.vbox.add_accel_group(accel_group)
and a callback
def callback1(accel_group, self.vbox, ord('k'), gtk.gdk.CONTROL_MASK):
        self.clear_live_plotter()
but I get a very unhelpful error, which leaves me no wiser as to what the syntax error is
(the caret appears under self.vbox, but if you just put vbox, it will be under ord('k') - can't figure that)
File "/usr/local/bin/gremlin", line 37
def callback1(accel_group, self.vbox, ord('k'), gtk.gdk.CONTROL_MASK):
^
SyntaxError: invalid syntax


I somewhat suspect that even if I got gremlin to accept the accelerator, it would only work if the user had immediately before initiated a mouse event and thereby passed focus to the
container widget and gremlin.
That being so I will stick with the default right button double click to clear the plot and possibly later try setting up an action for Qt which raises a mouse event for the container widget and see what happens then.

regards
Last edit: 17 Dec 2012 19:55 by ArcEye.

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

More
19 Dec 2012 22:47 - 19 Dec 2012 22:50 #27866 by BigJohnT
Replied by BigJohnT on topic Gremlin
I got some help from the mailing list on how to use gremlin! As you can see gremlin loads without errors...







I still have some work to do on reporting file errors and a few other things but it works and now I understand how to load it... details as I sort them out.

John
Attachments:
Last edit: 19 Dec 2012 22:50 by BigJohnT.

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

More
19 Dec 2012 23:19 #27867 by ArcEye
Replied by ArcEye on topic Gremlin
Well done - persistence wins out

If you want to reduce the size of the font and lose the DTG reading to increase visibility, the options are in gremlin.py

I hard coded them but you probably can change the properties from code.

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

Time to create page: 0.176 seconds
Powered by Kunena Forum