首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的小工具不显示在我的Tkinter Notebook选项卡中?

为什么我的小工具不显示在我的Tkinter Notebook选项卡中?
EN

Stack Overflow用户
提问于 2021-03-17 05:05:39
回答 1查看 135关注 0票数 0

正在尝试使用Tkinter笔记本标签制作GUI。如果我不使用Notebook标签,我可以正常地使用.grid(),但是当我添加它们时,所有东西都会消失。

代码语言:javascript
复制
from tkinter import *
from tkinter import ttk

root= Tk()
root.title("Mountain Care Pharmacy CMS")
root.geometry('600x800')
root.resizable(width=False, height=False)

note = ttk.Notebook(root)

tab1 = ttk.Frame(note)
tab2 = ttk.Frame(note)
tab3 = ttk.Frame(note)

note.add(tab1, text = "CMS", compound=TOP)
note.add(tab2, text = "Other")
note.grid()

ttk.Button(tab1, text='Import PBM file', command=getPBM).grid(column = 0 , row = 1, sticky = W)
ttk.Button(tab1, text='Import Direct file', command=getDirect).grid(column = 0 , row = 2, sticky = W)
ttk.Button(tab1, text='Create CMS', command=createReport).grid(column=3, row = 4, sticky = W)
tab1.grid()

reportType = StringVar()
ttk.Combobox(tab2, textvariable=reportType)
pbm_file_path = StringVar()
direct_file_path = StringVar()
pbm_entry = ttk.Entry(tab2, textvariable=pbm_file_path)
direct_entry = ttk.Entry(tab2, textvariable=direct_file_path)
pbm_entry.grid(column=1, columnspan = 2, row=1, sticky = EW)
direct_entry.grid(column=1, columnspan = 2, row=2, sticky = EW)

for child in tab1.winfo_children(): 
    child.grid_configure(padx=5, pady=5)
root.bind("<Return>", createReport)

root.mainloop()

是不是因为我调用grid()的方式?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-17 05:10:40

这是因为您正在调用tab1.grid()。您不应该调用packplacegrid,因为您已将其添加到笔记本中。notebook负责管理框架的可见性。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66663422

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档