如何在不同行中放置 ttk Notebook 的选项卡? [英] How to have tabs of a ttk Notebook in different rows?
问题描述
在下面的程序中,我在单个笔记本页面中有许多选项卡.当标签数增加外观更改时.那么如何将标签放在不同的行中
In the below program i have many tabs in a single notebook page. when the number of tabs increases the look changes. So how to put the tabs in different rows
如附图所示,我在一行中有许多选项卡,但我希望在下面一行中显示来自 JJJJ
的一些选项卡.
As in attached image, I have many tabs in a single row, but I want some tabs say from JJJJ
in a below row.
如何在不同的行中设置标签以及如何在选中时为标签提供不同的颜色(突出显示标签)?
How to set tabs in different row also how to give different colors to tab(highlight the tab) when selected?
title = 'Trial Tool window'
import sys
sys.path[:0] = ['../../..']
import Tkinter
import Pmw
class MyButton(Tkinter.Button):
def __init__(self, master=None, cnf={}, **kw):
self.__toggle = 0
kw['background'] = 'green'
kw['activebackground'] = 'red'
apply(Tkinter.Button.__init__, (self, master, cnf), kw)
class Demo:
def __init__(self, parent):
# Create and pack the NoteBook.
notebook = Pmw.NoteBook(parent)
notebook.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
page = notebook.add('AAAA')
notebook.tab('AAAA').focus_set()
# Create the "Toolbar" contents of the page.
group = Pmw.Group(page, tag_text = 'XYZ')
group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
b1 = Tkinter.Checkbutton(group.interior(), text = 'Show tool')
b1.grid(row = 0, column = 0)
# Add all other Channel pages.
page = notebook.add('BBBB')
page = notebook.add('CCCC')
page = notebook.add('DDDD')
page = notebook.add('EEEE')
page = notebook.add('FFFF')
page = notebook.add('GGGG')
page = notebook.add('HHHH')
page = notebook.add('IIII')
page = notebook.add('JJJJ')
page = notebook.add('KKKK')
page = notebook.add('LLLL')
page = notebook.add('MMMM')
page = notebook.add('NNNN')
page = notebook.add('OOOO')
page = notebook.add('PPPP')
page = notebook.add('QQQQ')
page = notebook.add('RRRR')
notebook.setnaturalsize()
######################################################################
# Create demo in root window for testing.
if __name__ == '__main__':
root = Tkinter.Tk()
Pmw.initialise(root)
root.title(title)
widget = Demo(root)
exitButton = MyButton(root, text = 'Exit', command = root.destroy)
exitButton.pack()
root.mainloop()![enter image description here][2]
推荐答案
ttk 不可能做到这一点,无论如何这是一个可怕的设计.相反,创建一个选项对话框",您可以在其中将列表或树视图放在侧面的面板中,并使用它在许多子页面中进行选择.然后,您可以使用没有选项卡的笔记本,或者简单地在包含子页面的不同框架中切换以响应对选择窗格的点击.
It is not possible with ttk to do this and it is a horrible design anyway. Instead, create an "options dialog" where you put either a list or a treeview in a panel on the side and use that to select among your many subpages. You can then use a notebook without tabs or simply switch in different frames containing your child pages in response to clicks on the selection pane.
在谷歌图片中搜索选项对话框"以查看此方案的任意数量的实现.从可用性的角度来看,多行标签是一个非常糟糕的设计.
Search google images for "options dialog" to see any number of implementations of this scheme. Multiple rows of tabs is a really bad design from a usability perspective.
我提供此链接到 耻辱堂 以阻止任何人考虑选项卡式对话框上的多行.
I offer this link to the Hall of Shame to discourage anyone from considering mutiple rows on a tabbed dialog.
这篇关于如何在不同行中放置 ttk Notebook 的选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!