我正在使用 PyGTK 和gtk.Assistant
. gtk.ScrolledWindow
在一个页面上,我在一个(我想要垂直滚动条,因为列表包含大约 35 个项目)中放置了一个树视图(一列,只是字符串)。一切正常;唯一让我烦恼的是我无法从文档中弄清楚如何设置滚动窗口的大小。目前一次只显示三个项目;我想将此数字设置为 10 左右。
下面是代码。正如您所看到的,我尝试使用 agtk.Adjustment
来影响滚动窗口的大小,但是再次 - 我无法从文档中检索所需的信息,我实际上不知道应该在那里输入什么值。
self.page7 = gtk.VBox()
# The gtk.Adjustment:
page_size = gtk.Adjustment(lower=10, page_size=100) # just used some arbitrary numbers here >_<
scrolled_win = gtk.ScrolledWindow(page_size)
scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # only display scroll bars when required
self.character_traits_treeview = gtk.TreeView()
self.character_traits_treestore = gtk.TreeStore(str)
self.character_traits_treeview.set_model(self.character_traits_treestore)
tc = gtk.TreeViewColumn("Character traits")
self.character_traits_treeview.append_column(tc)
cr = gtk.CellRendererText()
tc.pack_start(cr, True)
tc.add_attribute(cr, "text", 0)
self.character_trait_selection = self.character_traits_treeview.get_selection()
self.character_trait_selection.connect('changed', self.check_number_of_character_trait_selections)
self.character_trait_selection.set_mode(gtk.SELECTION_MULTIPLE)
self.make_character_traits_treestore()
# adding the treeview to the scrolled window:
scrolled_win.add(self.character_traits_treeview)
self.page7.pack_start(scrolled_win, False, False, 0)
self.assistant.append_page(self.page7)
self.assistant.set_page_title(self.page7, "Step 7: Select 2-3 character traits")
self.assistant.set_page_type(self.page7, gtk.ASSISTANT_PAGE_CONTENT)
self.assistant.set_page_complete(self.page7, False)
def check_number_of_character_trait_selections(self, blah):
# ...
def make_character_traits_treestore(self):
# ...
我知道我应该 RTFM,但由于我无法确定它的头部或尾部,并且进一步搜索也无济于事,我只是希望这里有人能给我一个提示。
提前非常感谢!
PS:以下是链接: