graph-tool Digest, Vol 103, Issue 2

Could you give me a little sample code, if you is not too much trouble?

I just found a function *key_press_callback *from GraphWidget. Im new in
Python so its hard to understand its work by myself without doc. I'll be
very greatefull to you)

06.08.16 13:00, graph-tool-request(a) пишет:

attachment.html (3.87 KB)


If you want to learn how to create pop up windows, menus, etc. for GTK3 I
would suggest having a look at:

The way I did it is to call graph_widget = GraphWidget() and then attach it
to a window created based on the tutorial mentioned above. That allows you
to add menus, tool bars, staus bars etc as you please.

Regarding having the SW respond to keyboard commands, you can do it by
using the "key_press_call_back" parameter. This is a function that is
called every time a key is pressed:

For example:
graph_widget = GraphWidget(g, ....,
key_press_callback=key_pressed_callback) # note i omitted lots of other

where key_pressed_callback is a funtion defined as:

def_key_pressed_callback(self, widget, g, key, selected_vertices, pos,
vprops, eprops):
    if chr(key) == 'd':
        print("User pressed:" + chr(key))

Hope that helps

attachment.html (4.87 KB)