Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么我的Toplevel()窗口显示为空白_Python_Tkinter_Toplevel - Fatal编程技术网

Python 为什么我的Toplevel()窗口显示为空白

Python 为什么我的Toplevel()窗口显示为空白,python,tkinter,toplevel,Python,Tkinter,Toplevel,我在这上面已经有一段时间了,尝试了很多我可以在网上找到的方法,但似乎没有办法解决我的问题。My Toplevel()窗口不显示任何内容。这应该是我计划的一部分。我们不得不把代码复制出来,并以这种方式进行总结,但它不起作用。我想我错过了什么 from tkinter import * # from tkinter import ttk # import sqlite3 # conn = sqlite3.connect('shengen.db') # c = conn.cursor() #

我在这上面已经有一段时间了,尝试了很多我可以在网上找到的方法,但似乎没有办法解决我的问题。My Toplevel()窗口不显示任何内容。这应该是我计划的一部分。我们不得不把代码复制出来,并以这种方式进行总结,但它不起作用。我想我错过了什么

from tkinter import *
# from tkinter import ttk

# import sqlite3


# conn = sqlite3.connect('shengen.db')

# c = conn.cursor()

# q = c.execute(
#     "SELECT email FROM users WHERE email=('ichibuokem@gmail.com');")
# conn.commit()

# for i in q:
#     print(list(i))

def portal_start():
    portal = Toplevel(root)
    portal.title("Visa Application Form")
    portal.geometry("600x600")
    portal.iconbitmap("...\Visa-Application-Management-System\icon.ico")

    Label(portal, text="", bg="grey", height="2",
          width="900", font=("Calibri", 14)).pack(pady=10)

    spc = Label(portal, text="")
    spc.pack()

    portal_notebook = ttk.Notebook(portal)
    portal_notebook.pack()

    page1 = Frame(portal_notebook, width=600, height=600)
    page2 = Frame(portal_notebook, width=600, height=600)
    page3 = Frame(portal_notebook, width=600, height=600)
    page4 = Frame(portal_notebook, width=600, height=600)
    summary = Frame(portal_notebook, width=600, height=600)

    page1.pack(fill="both", expand=1)
    page2.pack(fill="both", expand=1)
    page3.pack(fill="both", expand=1)
    page4.pack(fill="both", expand=1)
    summary.pack(fill="both", expand=1)

    portal_notebook.add(page1, text="Basic Details")
    portal_notebook.add(page2, text="Sponsorship")
    portal_notebook.add(page3, text="Medicals")
    portal_notebook.add(page4, text="References")
    portal_notebook.add(summary, text="Summary")


# ============================================Portal End===================================================


# =============================================Instantiation window=======================================


def window():
    global root
    root = Tk()
    root.geometry("900x700")
    root.title("Welcome Page")
    root.iconbitmap("..\Visa-Application-Management-System\icon.ico")

    Label(root, text="Welcome To Python Visa Application Portal! \n\nTo check your visa application status, file a new application or update your application, \nLogin or Create an account.",
          fg="white", bg="grey", height="6", width="900", font=("Calibri", 14)).pack()
    Label(root, text="").pack()
    Label(root, text="").pack()
    Label(root, text="").pack()
    Label(root, text="").pack()
    Label(root, text="").pack()
    Button(root, text="Login", width=20, font=(
        "bold", 14)).pack()
    Label(root, text="").pack()
    Button(root, text="Create Account", width=20,
           font=("bold", 14)).pack()
    Label(root, text="").pack()
    Label(root, text="").pack()
    Label(root, text="Copyright 2020. All Rights Reserved \nWith Luv From Group 3",
          font=("Calibri", 8)).pack()

    Button(root, text="Test Window", width=20,
           font=("bold", 14), command=portal_start).pack()
    Label(root, text="").pack()

    root.mainloop()


window()

将此添加到代码顶部

from tkinter import ttk


它应该可以很好地工作,然后使用tkinter import ttk中的

,然后它会显示一个
ttk.notebook
。它会正确弹出一个顶级窗口,但不会显示任何选项卡。当我添加缺少的导入语句时,您的代码对我有效。