【发布时间】:2020-01-18 22:31:40
【问题描述】:
正在玩 python3 和 tkinter。
我试图在框架中有一个带有两个标签的框架。我想在框架和每个标签周围画一个边框。
因为它是下面的代码显示框架仅在标签 1 周围。标签 2 在 notebook_Frame 下方。 如何确保小部件位于特定框架内?
import tkinter as tk
def main():
mainWinTk = tk.Tk()
mainWinTk.title("Setup Server")
mainWinTk.columnconfigure(0, weight=1)
mainWinTk.rowconfigure(0, weight=1)
mainWinTk.rowconfigure(1, weight=1)
notebook_Frame = tk.Frame(mainWinTk, highlightbackground="green", highlightthickness=3, borderwidth=2, relief='ridge').grid(column=0, row=0, sticky=tk.W+tk.E+tk.S+tk.N)
tk.Label(notebook_Frame, text="Label 1", highlightbackground="red", highlightthickness=3).grid(column=0, row=0)
tk.Label(notebook_Frame, text="Label 2", highlightbackground="red", highlightthickness=3).grid(column=0, row=1)
mainWinTk.mainloop()
if __name__ == "__main__":
main()
【问题讨论】:
-
因为
notebook_Frame是None。
标签: python-3.x tkinter