LinuxCNC Features - a kind of NGCGUI

More
13 years 4 months ago #35247 by Nick
Hi!

Sorry for another delay :).
I've almost solved the problem with creating gladevcp widget.

It appears that gladevcp objects are stored and linked into two different location, so it was not enough just adding new files, creating links was also needed.

Another problem I met - after embedding widget into axis TreeView does not react on it's usual keypresses. Up/Down/Left/Right does not work as they work in standalone version. If I add 'key_press_event' to TreeView it sees keypress events, but I have no clue how to bring back standard behavior.

Another thing - I can not force Axis to load created file. I can only force it to reload already opened file by executing axis-remote --reload. NGCGUI uses something like
if ![catch {send axis "remote open_file_name $f"} msg] { ...
How can it be done from python? Or are there any other ways to do it?

PS I've add subroutines path search from the path defined in ini file.

Here's how it looks now:

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

More
13 years 4 months ago #35275 by cmorley
No links should be require.
programs that end in .py or .glade that are in the gladevcp folder should just work. it may require a make clean; make but it shouldn't

Not sure about the reload problem. You might look at pyngcgui in another thread.
There are problems passing key events from AXIS to gladeVCP panels - might look in the manual to see if there is advice.

Chris M

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

More
13 years 4 months ago #35276 by Nick
I saw this from GladeVCP manual:

We believe key handling works OK, but since it is new code, we’re telling about it you so you can watch out for problems; please let us know of errors or odd behavior. This is the story:

Axis uses the TkInter widget set. GladeVCP applications use Gtk widgets and run in a separate process context. They are hooked into Axis with the Xembed protocol. This allows a child application like GladeVCP to properly fit in a parent’s window, and - in theory - have integrated event handling.

However, this assumes that both parent and child application properly support the Xembed protocol, which Gtk does, but TkInter doesn’t. A consequence of this is that certain keys would not be forwarded from a GladeVCP panel to Axis properly under all circumstances. One of these situations was the case when an Entry, or SpinButton widget had focus: in this case, for instance an Escape key would not have been forwarded to Axis and cause an abort as it should, with potentially disastrous consequences.

Therefore, key events in GladeVCP are explicitly handled, and selectively forwarded to Axis, to assure that such situations cannot arise. For details, see the keyboard_forward() function in lib/python/gladevcp/xembed.py.


But I thought that it means that GladeVCP will froward some events to Axis. More over I added on_key_press event and saw that TreeView gets this events, just do not handle it in default mode by moving the cursor.

No links should be require.
programs that end in .py or .glade that are in the gladevcp folder should just work. it may require a make clean; make but it shouldn't

Hmmm... Probably it is because I've tried to use it with already installed linuxcnc, and not built from source one.

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

More
13 years 4 months ago #35278 by Nick
About opening file:
I've found that axis-remote has open file function, but it is not described in Usage and unsuspected...
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...73e1fe8f;hb=HEAD#l65

if mode == UNSPECIFIED:
mode = OPEN

Is there any reason why it is not made the same as --mdi, i.e.
axis-remote --open filename ?


Concerning keybindings it seems to be deeper than event forwarding. I've removed any signal connects from xembed.py, and still have no effect...

Do you know why widgets do not take focus? Treeview is drawn like it is not focused...

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

More
13 years 4 months ago - 13 years 4 months ago #35287 by Nick
New results :)

I've made a hack to solve keypress problem. This hack handles keypress.
Code:
keyname = gtk.gdk.keyval_name(event.keyval) #self.treeview.emit("expand-collapse-cursor-row", True, True, False) selection = self.treeview.get_selection() (model, pathlist) = selection.get_selected_rows() path = pathlist[0] if len(pathlist) > 0 else None if keyname == "Up" : if path : rect = self.treeview.get_cell_area(path, self.col_value) path = self.treeview.get_path_at_pos(rect[0],rect[1]-1) if path : path = path[0] self.treeview.set_cursor(path, focus_column=self.col_value, start_editing=False) return True if keyname == "Down" : if path : rect = self.treeview.get_cell_area(path, self.col_value) path = self.treeview.get_path_at_pos(rect[0],rect[1]+rect[3]+1) if path : path = path[0] self.treeview.set_cursor(path, focus_column=self.col_value, start_editing=False) return True if keyname == "Left" : if path!= None : self.treeview.collapse_row(path) return True if keyname == "Right" : if path!= None : self.treeview.expand_row(path,False) return True if keyname == "Return" : if path!= None : iter = model.get_iter(path) self.treeview.set_cursor_on_cell(path, focus_column=self.col_value, focus_cell=self.cell_value, start_editing=True) return True
I had to make a hack for moving elements up and down because somebody (probably top level window) handles "cursor-moved" event... :huh:

Almost the last thing is drag and drop. It works in standalone mode, but after embedding into axis, right after drag is started somebody steels Focus from treeview - so it wont accept drag-drop event, or even drag-move (only drag-failed, which does not give any info about position of fail) :(
Code:
<gtk.gdk.Event at 0x8cdb980: GDK_MOTION_NOTIFY x=115.00, y=16.00> <gtk.TreeView object at 0x8a66914 (GtkTreeView at 0x8abe1a8)> <gtk.gdk.Event at 0x8cdb980: GDK_LEAVE_NOTIFY x=0.00, y=0.00, mode=GDK_CROSSING_GTK_GRAB> <gtk.TreeView object at 0x8a66914 (GtkTreeView at 0x8abe1a8)> <gtk.gdk.Event at 0x8cdb980: GDK_LEAVE_NOTIFY x=0.00, y=0.00, mode=GDK_CROSSING_GTK_GRAB> <gtk.TreeView object at 0x8a66914 (GtkTreeView at 0x8abe1a8)> <gtk.gdk.Event at 0x8cdb980: GDK_LEAVE_NOTIFY x=0.00, y=0.00, mode=GDK_CROSSING_GTK_GRAB> <gtk.TreeView object at 0x8a66914 (GtkTreeView at 0x8abe1a8)> <gtk.gdk.Event at 0x8cdb980: GDK_GRAB_BROKEN> <gtk.TreeView object at 0x8a66914 (GtkTreeView at 0x8abe1a8)>
Last edit: 13 years 4 months ago by Nick.

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

More
13 years 4 months ago - 13 years 4 months ago #35424 by Nick
I've "solved" drag/drop problem by adding navigation buttons :)
But it could be much easier to use drag/drop...

Features are almost ready for the first tests :)

Last edit: 13 years 4 months ago by Nick.

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

Time to create page: 0.142 seconds
Powered by Kunena Forum