Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This will solve the tab number switching problem.</p> <pre><code>from gi.repository import Gtk tabs = Gtk.Notebook() tabs.set_scrollable(True) button = Gtk.Button() button.set_label('hi!') button.set_relief(Gtk.ReliefStyle.NONE) #here we use a grid to allow more widgets in the tab label. box = Gtk.Grid(orientation=Gtk.Orientation.HORIZONTAL) box.add(button) box.show_all() #a general tab number switcher def on_this_tab_clicked(button, tabs, pagenum): tabs.set_current_page(pagenum) #any button on a tab needs numbers in its callback argument #as well as a argument for the tab object(Gtk.Notebook) button.connect("clicked", on_this_tab_clicked, tabs, 0) #Here we add the acclerator. accels = Gtk.AccelGroup() #parse it so it's easy to read key, mod = Gtk.accelerator_parse("&lt;Alt&gt;1") button.add_accelerator("activate", accels, key, mod, Gtk.AccelFlags.VISIBLE) tab_content = Gtk.Label() tab_content.set_text('hi!') #place the box(Gtk.Grid) in the second argument of append_page tabs.append_page(tab_content, box) tabs.set_tab_reorderable(tab_content, True) #do everything with successive buttons exactly like the first button button2 = Gtk.Button() button2.set_label('bye!') button2.set_relief(Gtk.ReliefStyle.NONE) box2 = Gtk.Grid(orientation=Gtk.Orientation.HORIZONTAL) box2.add(button2) box2.show_all() button2.connect("clicked", on_this_tab_clicked, tabs, 1) key2, mod2 = Gtk.accelerator_parse("&lt;Alt&gt;2") button2.add_accelerator("activate", accels, key2, mod2, Gtk.AccelFlags.VISIBLE) tab_content2 = Gtk.Label() tab_content2.set_text('bye!') tabs.append_page(tab_content2, box2) tabs.set_tab_reorderable(tab_content2, True) window = Gtk.Window() window.set_default_size(200, 200) window.add(tabs) window.add_accel_group(accels) window.connect("delete-event", Gtk.main_quit) window.show_all() Gtk.main() </code></pre> <p>Here are some better links for this. <a href="https://developer.gnome.org/gtk3/3.5/GtkNotebook.html#gtk-notebook-set-current-page" rel="nofollow">Gtk.Notebook set_current_page</a> <a href="https://developer.gnome.org/gtk3/3.5/gtk3-Keyboard-Accelerators.html" rel="nofollow">Gtk Accelerators</a> These links are good. Just use and translate anything that says something like:</p> <p>gtk_function_name(object, args)</p> <p>into:</p> <p>gtk.object.function(args)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload