[英]Python/Tkinter: Using the new ttk.Notebook widget (custom font, trapping tab focus/mouseover)
I'm using the new ttk.Notebook widget available in Python 2.7 and Python 3.1. 我正在使用Python 2.7和Python 3.1中提供的新的ttk.Notebook小部件。
I'm struggling with the following tasks: 我正在努力完成以下任务:
How to change the font associated with notebook tab captions. 如何更改与笔记本选项卡标题关联的字体。 I want to use a named font object whose size a user controls.
我想使用用户控制大小的命名字体对象。 (Could a ttk.Style help me here?)
(ttk.Style可以在这里帮助我吗?)
How can I bind to tab specific keyboard focus (<FocusIn>), mouseover events (<Enter>), and rightclicks (<Button-3>). 如何绑定到选项卡特定的键盘焦点(<FocusIn>),鼠标悬停事件(<Enter>)和右键单击(<Button-3>)。 I have a total fail trying to bind to tab specific keyboard focus and mouseover events.
我完全无法尝试绑定到选项卡特定的键盘焦点和鼠标悬停事件。 I can bind to a <Button-3> rightclick, but I can't figure out how to determine the tab a user clicked on.
我可以绑定到<Button-3>右键单击,但是我不知道如何确定用户单击的选项卡。 Using .identify( event.x, event.y ) returns the string 'label' vs. a widget reference.
使用.identify(event.x,event.y)返回字符串'label'和小部件引用。
Is there a way to give tabs an id (the documentation hints at this via tab_id) so we can reference tabs independent of their physical position in an array of tabs? 有没有一种方法可以给标签赋予ID(文档通过tab_id进行提示),以便我们可以独立于标签在标签阵列中的物理位置来引用标签?
Thank you, Malcolm 谢谢马尔科姆
We're actually answering these questions in the Tkinter mailing list ; 我们实际上是在Tkinter 邮件列表中回答这些问题; in fact, I have mixed feelings about saying anything in Stackoverflow apart from, "See the mailing list".
实际上,除了在“请参阅邮件列表”之外,我对在Stackoverflow中说什么都感到mixed贬不一。 It's surely fair to note, though, that this answers the question about fonts, and this heads a thread on tab events.
不过,确实可以肯定地注意到, 这回答了有关字体的问题,并且这是制表符事件的主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.