I'm trying to setup a window with a notebook and some pages. Within the pages, there will be some entries (see example code).
I'd like to handle the tab key and arrow keys on my own. I don't want the arrow up key to jump to the page title, I don't want the arrow left / right key to cycle through the pages. I don't want the tab key to cycle through the entries.
Connecting to the key-press signal and checking for tab or arrow keys does not really work.
I tried to change the focus chain, but it still focusses on the page title or cycles through the pages with left / rigth arrow.
Any help / idea is highly appreciated.
#!/usr/bin/env python
import pygtk
import gtk
class NotebookExample:
def __init__(self):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_size_request(200,200)
notebook = gtk.Notebook()
notebook.set_tab_pos(gtk.POS_TOP)
notebook.show()
hbox1 = gtk.HBox()
notebook.append_page(hbox1, gtk.Label("Page1"))
hbox2 = gtk.HBox()
notebook.append_page(hbox2, gtk.Label("Page2"))
window.add(notebook)
entry1 = gtk.Entry()
entry2 = gtk.Entry()
entry3 = gtk.Entry()
entry1.set_width_chars(5)
entry2.set_width_chars(5)
entry3.set_width_chars(5)
hbox1.pack_start(entry1, False, False, 10)
hbox1.pack_start(entry2, False, False, 10)
hbox1.pack_start(entry3, False, False, 10)
hbox1.set_focus_chain([entry2, entry3])
window.show_all()
def main():
gtk.main()
return 0
if __name__ == "__main__":
NotebookExample()
main()