小编Pla*_*ave的帖子

在 tkinter 中添加笔记本选项卡 - 如何使用基于类的结构来完成?(蟒蛇 3)

我写了一个 tkinter 应用程序,它在两个框架上显示了小部件,类似于这个例子,它成功运行。

from tkinter import *
from tkinter import ttk

root = Tk()
root.title("Example")

notebook = ttk.Notebook(root)
frame1 = ttk.Frame(notebook)
frame2 = ttk.Frame(notebook)
notebook.add(frame1, text="Frame One")
notebook.add(frame2, text="Frame Two")
notebook.pack()

#(The labels are examples, but the rest of the code is identical in structure). 

labelA = ttk.Label(frame1, text = "This is on Frame One")
labelA.grid(column=1, row=1)

labelB = ttk.Label(frame2, text = "This is on Frame Two")
labelB.grid(column=1, row=1)

root.mainloop()
Run Code Online (Sandbox Code Playgroud)

我决定我应该尝试重组程序以使用一个类(我承认我不是很熟悉)。但是,我不确定我应该怎么做才能让小部件出现在不同的框架上(其他一切正常)。例如,下面会产生一个“TypeError: init () 需要 1 到 2 个位置参数,但给出了 3 个。” …

python tkinter python-3.x

2
推荐指数
1
解决办法
8144
查看次数

标签 统计

python ×1

python-3.x ×1

tkinter ×1