Gmoccapy - A new screen for linuxcnc
21 Aug 2017 11:22 #97812
by remrendes
Replied by remrendes on topic Gmoccapy - A new screen for linuxcnc
Thanks!
Please Log in or Create an account to join the conversation.
02 Sep 2017 14:38 #98374
by Patrik T
Replied by Patrik T on topic Gmoccapy - A new screen for linuxcnc
I have tried some more to gain control over the Gremlin preview from a custom panel.
I can import your widgets method.But this does not work:Not surprising it gives the warning:
TypeError: unbound method __getattr__() must be called with Widgets instance as first argument (got HandlerClass instance instead)
I am only importing the class, I need an instance. I have tried, but not been able to get a reference to any instance outside of the custom panel's top level window.
I feels like the reference has to me sent to my HandlerClass when it is created.
Is there any way to pass an instance reference to Gmoccapy when the custom panel is added into Gmoccapy?
Patrik
I can import your widgets method.
from gmoccapy import widgets
class HandlerClass:
def __init__(self, halcomp, builder, useropts):
print("%s\n" % widgets.Widgets.__getattr__(self, 'gremlin'))
TypeError: unbound method __getattr__() must be called with Widgets instance as first argument (got HandlerClass instance instead)
I am only importing the class, I need an instance. I have tried, but not been able to get a reference to any instance outside of the custom panel's top level window.
I feels like the reference has to me sent to my HandlerClass when it is created.
Is there any way to pass an instance reference to Gmoccapy when the custom panel is added into Gmoccapy?
Patrik
Please Log in or Create an account to join the conversation.
02 Sep 2017 16:09 #98380
by newbynobi
Replied by newbynobi on topic Gmoccapy - A new screen for linuxcnc
Hallo Patrik,
you may change the gmoccapy.py file to expose the Node-ID from gremlin, or you try the way to get first the parrent window like may be so:
toplevel = mywidget.get_toplevel()
and then search in that window for the node ID of gremlin.
All that is only an idea, as I have not tested anythink like that.
Please keep us informed, if you do find a solution.
Norbert
you may change the gmoccapy.py file to expose the Node-ID from gremlin, or you try the way to get first the parrent window like may be so:
toplevel = mywidget.get_toplevel()
and then search in that window for the node ID of gremlin.
All that is only an idea, as I have not tested anythink like that.
Please keep us informed, if you do find a solution.
Norbert
Please Log in or Create an account to join the conversation.
02 Sep 2017 18:54 #98383
by Patrik T
Replied by Patrik T on topic Gmoccapy - A new screen for linuxcnc
I tried get_toplevel() but it seems I cannot get outside of the custom panel's window,
What is the path to Gmoccapy.py?
Is it read only?
What is the path to Gmoccapy.py?
Is it read only?
Please Log in or Create an account to join the conversation.
02 Sep 2017 19:10 #98384
by andypugh
This sounds a bit like the problem I had with embedded tabs in Touchy. In that case the containing GUI needed to send signals to the embedded GUI, there is no way that an embedded tab can "climb up the tree" to the containing GUI.
github.com/LinuxCNC/linuxcnc/commit/1bcd...b3ae236486cb45cd0e9e
(Did that system get added to Gmoccapy?)
Replied by andypugh on topic Gmoccapy - A new screen for linuxcnc
toplevel = mywidget.get_toplevel()
and then search in that window for the node ID of gremlin.
This sounds a bit like the problem I had with embedded tabs in Touchy. In that case the containing GUI needed to send signals to the embedded GUI, there is no way that an embedded tab can "climb up the tree" to the containing GUI.
github.com/LinuxCNC/linuxcnc/commit/1bcd...b3ae236486cb45cd0e9e
(Did that system get added to Gmoccapy?)
Please Log in or Create an account to join the conversation.
07 Sep 2017 21:41 #98645
by Patrik T
Replied by Patrik T on topic Gmoccapy - A new screen for linuxcnc
I got the Gremlin instance id from Gmoccapy to the subprocess. In Gmoccapy I could get the instance back from the id, but in the subprocess the same code did not run. It crashed so hard a try: except: statement could not catch the error
Gave up on that and solved it by adding the desired features in Gmoccapy directly.
Gave up on that and solved it by adding the desired features in Gmoccapy directly.
Please Log in or Create an account to join the conversation.
08 Sep 2017 11:50 - 08 Sep 2017 11:51 #98666
by newbynobi
Replied by newbynobi on topic Gmoccapy - A new screen for linuxcnc
Plesse post the changes you did, i will rewiew them and check if it can be integraler as standard code
Norbert
Norbert
Last edit: 08 Sep 2017 11:51 by newbynobi.
Please Log in or Create an account to join the conversation.
08 Sep 2017 23:38 #98715
by Patrik T
Replied by Patrik T on topic Gmoccapy - A new screen for linuxcnc
Thanks, but you do not have to do that. It is just adding a few pins that clear and zoom the Gremlin view.
Please Log in or Create an account to join the conversation.
08 Sep 2017 23:41 #98717
by andypugh
If you wanted them, then why do you assume that nobody else wants them?
This is Open Source, and Active open source. If one user wants it, we tend to assume that two or more users want it.
Replied by andypugh on topic Gmoccapy - A new screen for linuxcnc
Thanks, but you do not have to do that. It is just adding a few pins that clear and zoom the Gremlin view.
If you wanted them, then why do you assume that nobody else wants them?
This is Open Source, and Active open source. If one user wants it, we tend to assume that two or more users want it.
Please Log in or Create an account to join the conversation.
08 Sep 2017 23:54 - 09 Sep 2017 13:24 #98718
by Patrik T
Replied by Patrik T on topic Gmoccapy - A new screen for linuxcnc
Point taken.
On line 450
On line 4148
On line 450
#My edit
###################################################################
cnc_ini = linuxcnc.ini(os.environ['INI_FILE_NAME'])
self.gx = 0
self.gy = 0
self.d_zoom = self.widgets.gremlin.get_zoom_distance()
self.pan_speed = float(cnc_ini.find('GREMLIN_JOY', 'PAN_SPEED') or 50)
self.zoom_speed = float(cnc_ini.find('GREMLIN_JOY', 'ZOOM_SPEED') or 0.5)
###################################################################
On line 4148
#################################################################
# Gremlin, zoom, pan, clear.
#################################################################
def _on_gremlin_io(self, hal_pin, data=None):
halpin = hal_pin.get()
# print("gremlin_io pin changed to %d." % halpin)
if halpin == 0:
return
elif halpin == 1:
self.gx = self.gx + self.gremlin_joyz_pos.get() * self.pan_speed
self.gy = self.gy + self.gremlin_joyx_pos.get() * self.pan_speed
self.widgets.gremlin.pan(self.gx, self.gy)
elif halpin == 2:
self.d_zoom = self.widgets.gremlin.get_zoom_distance() * (1 + self.gremlin_joyx_pos.get() * self.zoom_speed)
if self.d_zoom < 0.1:
self.d_zoom = 0.1
self.widgets.gremlin.set_zoom_distance(self.d_zoom)
elif halpin == 3:
self.widgets.gremlin.clear_live_plotter()
self.widgets.gremlin.set_zoom_distance(self.d_zoom)
self.widgets.gremlin.pan(self.gx, self.gy)
elif halpin == 4:
self.d_zoom = self.widgets.gremlin.get_zoom_distance()
self.widgets.gremlin.pan(0, 0)
hal_pin.set(0)
# We need extra HAL pins here is where we do it.
# we make pins for the hardware buttons witch can be placed around the
# screen to activate the coresponding buttons on the GUI
def _init_hal_pins( self ):
#################################################################
# My pins.
#################################################################
self.gremlin_joyx_pos = hal_glib.GPin(self.halcomp.newpin('gremlin-joyx-pos', hal.HAL_FLOAT, hal.HAL_IN))
self.gremlin_joyz_pos = hal_glib.GPin(self.halcomp.newpin('gremlin-joyz-pos', hal.HAL_FLOAT, hal.HAL_IN))
self.gremlin_io = hal_glib.GPin(self.halcomp.newpin('gremlin-io', hal.HAL_S32, hal.HAL_IO))
self.gremlin_io.connect('value-changed', self._on_gremlin_io)
#################################################################
Last edit: 09 Sep 2017 13:24 by Patrik T. Reason: Added a code line.
The following user(s) said Thank You: KCJ
Please Log in or Create an account to join the conversation.
Time to create page: 0.148 seconds