问题标签 [ttk]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1789 浏览

python - ttk.Button 返回无

我正在尝试使用 ttk.Button 的调用方法,如TkDocs所示(查看“命令回调”),但我不断收到此错误:

AttributeError:“NoneType”对象没有“调用”属性

所以,我在 Interactive Shell 中尝试了这个:

这表明 ttk.Button 返回无。

ttk.Button 是否意味着返回 None。而且,如果是这样,为什么 TkDocs 说有一个调用方法?

0 投票
2 回答
5081 浏览

fonts - 如何更改 ttk::button (主题小部件)中的字体和字体大小?

如何更改主题按钮小部件 ( ttk::button) 中的字体和字体大小?

0 投票
2 回答
3349 浏览

python - Python ttk.Button -command,无需按下按钮即可运行

我正在使用 ttk 在 python 中制作一个小脚本,但我遇到了一个问题,即函数在不应该运行的地方运行。按钮代码如下所示:

功能是这样的:

由于某种原因,该功能在没有按下按钮的情况下运行。为什么?

0 投票
2 回答
1346 浏览

python - 有效地使用 ttk (tk 8.5) Notebook 小部件(滚动标签)

我正在使用 Tkinter 和 Python 开发一个项目。为了拥有原生主题并利用新的小部件,我在 Python 2.6 中使用了 ttk。我的问题是如何允许用户滚动笔记本小部件中的选项卡(a la firefox)。另外,我需要标签右边缘的一部分作为关闭按钮。活动选项卡的框架需要填充可用的水平空间(包括滚动箭头下方)。

我想我可以使用放置几何管理器来做到这一点,但我想知道是否有更好的方法?ttk python 文档没有任何我可以看到的方法来处理这个问题。

编辑:看起来即使尝试使用地点来实现这个也有困难。一方面,我仍然需要滚动标签并将活动面板留在一个地方。

0 投票
2 回答
976 浏览

r - 如何使用 ttk 创建状态行?

如何在窗口底部创建状态行?非活动条目看起来不太好。还有哪些其他选择?

是否可以集成仅按需可见的进度条?

(我在 R 中使用 tk 和 ttk。)

编辑:现在这是我的第二个版本,对我来说效果很好,但我想只按需显示整个状态栏(类似于 Chrome 浏览器中的状态栏)。我怎样才能做到这一点?调用 tklower(f) 没有帮助......

0 投票
4 回答
5346 浏览

python - Tk/ttk python中的帧大小调整问题

我正在使用 Python 2.7 中的 Tkinter/ttk 创建一个 GUI,并且我遇到了一个问题,即一旦将小部件放入其中,Frame 就会自行调整大小。我是 Python 新手,之前没有使用过 Tkinter。

例子:

如果我像这样在其中放置一个小部件,将产生一个 300x300 的带凹槽的框架:

框架将缩小以适合按钮。有什么方法可以强制框架不调整大小?

0 投票
2 回答
3176 浏览

python - Python 2.7:通过 Ttk 的主题“通用对话框”tkinter 接口?

Python 2.7(32 位)Windows:我们正在试验 Python 2.7 对主题 Tkinter ( ttk) 的简单 GUI 支持,结果给我们留下了深刻的印象!新主题支持似乎不足的一个领域是如何包装特定于操作系统的常用对话框。

更正:换句话说,MessageBoxColorChooser普通对话框有“难看”的 Win 95 风格块状按钮,而主题(圆形/渐变)按钮通常显示在 XP、Vista 和 Windows 7 下的这些普通对话框上。(我'我在所有 3 个平台上进行测试,结果相同,没有主题)。

注意:filedialog 常用对话框 ( askopenfilename, askopenfilenames, asksaveasfilename, askdirectory) 都是正确的主题。

MessageBox关于使 Tkinter和ColorChooser通用对话框与操作系统主题兼容(至少在 Windows XP 或更高版本下)需要什么的任何想法?

0 投票
1 回答
2674 浏览

python - Python 2.7/Windows:如何控制 Tkinter 常用对话框的位置?

Windows下的Python 2.7:如何控制Tkinter常用对话框的位置?

以下是我们的发现:

  • 某些常见的对话框总是相对于它们的父窗口打开
  • 某些常用对话框总是以用户桌面为中心打开
  • 所有常见的对话框似乎都忽略了可选的 parent= 参数

问题:

  • 我们如何强制对话框相对于其父窗口打开?
  • 我们如何强制以用户桌面为中心打开对话框?

背景:

谢谢你,马尔科姆

0 投票
1 回答
5057 浏览

python - Python 2.7/Windows:ttk 组合框下拉菜单显示在最上面的根窗口下方

我正在试验 Python 2.7 附带的新的 ttk Tile 增强功能。

Windows 7:下面的代码演示了当根窗口配置为最顶层窗口(“始终在顶层”)时,组合框下拉菜单如何显示在我们的根窗口后面。如果您注释掉 """ root.attributes( '-topmost', 1 )""" 行,那么组合框下拉菜单将出现在根窗口中(如预期的那样)。

任何人都对此行为有任何解决方法,以便我们可以将组合框与“最顶层”窗口一起使用?

0 投票
4 回答
9575 浏览

python - Create resizable/multiline Tkinter/ttk Labels with word wrap

Is it possible to create a multi-line label with word wrap that resizes in sync with the width of its parent? In other words the wordwrap behavior of Notepad as you change the width of the NotePad window.

The use case is a dialog that needs to present a block of multi-line text (instructions) in its entirety without having the text clipped or resorting to scrollbars. The parent container will have enough vertical space to accomodate narrow widths.

I've been experimenting with Tkinter Label and Message widgets and the ttk Label widget without success. It seems that I need to hard code a pixel wraplength value vs. have these controls auto wordwrap when their text reaches the right edge of their containers. Certainly Tkinters geometry managers can help me auto-resize my labels and update their wraplength values accordingly?

Should I be looking at the Text widget instead? If so, is it possible to hide the border of a Text widget so I can use it as a multi-line label with wordwrap?

Here's a prototype of how one might do what I described above. It was inspired by Bryan Oakley's tip to use the Text widget and the following post on Stackoverflow: In python's tkinter, how can I make a Label such that you can select the text with the mouse?