fre*_*aks 1 tkinter python-3.x ubuntu-16.04
我有一个 Tkinter 按钮,由于某种原因,它接受 width=xx,但不接受 height=xx
我在 ubuntu 16.04 上使用 Python 3.5,默认支持 Tkinter
这是代码示例:
# works: button_enter = ttk.Button(self.frm, text='ok', width = 100)
# works: button_enter.config(width=25)
# fails: button_enter = ttk.Button(self.frm, text='ok', height=15, width = 25)
# fails: button_enter.config(width=25, height=15)
button_enter = ttk.Button(self.frm, text='ok')
button_enter.config(width=25)
button_enter['command'] = self.some_method
button_enter.grid(column=2, row = 0, sticky=W)
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误:
Traceback (most recent call last):
File "pygo.py", line 44, in <module>
app = App()
File "pygo.py", line 34, in __init__
button_enter.config(height=15, width=25)
File "/usr/lib/python3.5/tkinter/__init__.py", line 1333, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python3.5/tkinter/__init__.py", line 1324, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-height"
Run Code Online (Sandbox Code Playgroud)
可以让它发挥作用吗?或者如果它是一个错误,我应该在哪里报告它?
这不是一个错误,这就是 ttk 按钮的工作原理。如果您需要高度可配置的按钮,请使用 tkinter 按钮。ttk 按钮故意较少可配置。ttk 小部件的目标是为您提供一组与特定主题一致的按钮。
由于您使用的是 Linux 系统,因此您可以使用 或pack适当的选项来影响高度,尽管它不如 选项方便。placegridheight
| 归档时间: |
|
| 查看次数: |
12480 次 |
| 最近记录: |