如何在 pygtk 中对齐左侧的笔记本栏?
how to align notebook bar on left side in pygtk?
我在将左侧的笔记本栏与 pygtk 中的默认顶部对齐时遇到问题
# starting with notebook from here
self.notebook = Gtk.Notebook()
self.add(self.notebook)
self.page1 = Gtk.Box()
self.page1.set_border_width(10)
self.notebook.append_page(self.page1, Gtk.Label('page 1'))
self.page1.add(Gtk.Label('Nvidia'))
self.page2 = Gtk.Box()
self.page2.set_border_width(10)
self.page2.add(Gtk.Label('A page with an image for a Title.'))
#self.notebook.append_page(self.page2,Gtk.Image.new_from_icon_name("wifi",Gtk.IconSize.MENU))
self.notebook.append_page(self.page2,Gtk.Label('Wifi'))
我怎样才能在笔记本页眉上同时拥有图标和标签
下面是一个解决这两个问题的例子:
#!/usr/bin/env python3
from gi.repository import Gtk
class Window(Gtk.Window):
def __init__(self):
super().__init__()
self.connect('delete-event', Gtk.main_quit)
content = Gtk.Label(label='Page content')
label_box = Gtk.HBox()
label_box.pack_start(
Gtk.Image.new_from_icon_name('text-x-generic', 1),
False, False, 5)
label_box.pack_start(Gtk.Label(label='Page 1'), True, True, 0)
label_box.show_all()
notebook = Gtk.Notebook()
notebook.append_page(content, label_box)
notebook.set_tab_pos(Gtk.PositionType.LEFT)
self.add(notebook)
self.show_all()
if __name__ == '__main__':
Window()
Gtk.main()
我在将左侧的笔记本栏与 pygtk 中的默认顶部对齐时遇到问题
# starting with notebook from here
self.notebook = Gtk.Notebook()
self.add(self.notebook)
self.page1 = Gtk.Box()
self.page1.set_border_width(10)
self.notebook.append_page(self.page1, Gtk.Label('page 1'))
self.page1.add(Gtk.Label('Nvidia'))
self.page2 = Gtk.Box()
self.page2.set_border_width(10)
self.page2.add(Gtk.Label('A page with an image for a Title.'))
#self.notebook.append_page(self.page2,Gtk.Image.new_from_icon_name("wifi",Gtk.IconSize.MENU))
self.notebook.append_page(self.page2,Gtk.Label('Wifi'))
我怎样才能在笔记本页眉上同时拥有图标和标签
下面是一个解决这两个问题的例子:
#!/usr/bin/env python3
from gi.repository import Gtk
class Window(Gtk.Window):
def __init__(self):
super().__init__()
self.connect('delete-event', Gtk.main_quit)
content = Gtk.Label(label='Page content')
label_box = Gtk.HBox()
label_box.pack_start(
Gtk.Image.new_from_icon_name('text-x-generic', 1),
False, False, 5)
label_box.pack_start(Gtk.Label(label='Page 1'), True, True, 0)
label_box.show_all()
notebook = Gtk.Notebook()
notebook.append_page(content, label_box)
notebook.set_tab_pos(Gtk.PositionType.LEFT)
self.add(notebook)
self.show_all()
if __name__ == '__main__':
Window()
Gtk.main()