我的功能在遇到条件后无法正确执行/完全执行

发布于 2025-02-04 03:32:11 字数 4071 浏览 1 评论 0原文

我正在编写一个注册计划来注册大量学生并将其信息保存在数据库中,但是我的功能没有运行。

这是示例代码;我没有收到任何错误,所以我不确定怎么了。

# imported modules
if __name__ == "__main__":
    # creating instance of window stuff
    def erase(f):
        email.delete(0,"end")

    def erase1(e):
        name.delete(0,"end")

    # Password generator (To be sent on user's email)
    mxchars = string.ascii_letters+string.digits

    for pwd in range(1):
        pw = ''
    for c in range(10):
        pw += random.choice(mxchars)

    def aft():
        rot = tk.Tk()
        rot.title("zZ |Ξηr:book:llado")
        rot.iconbitmap(r"C:\PYTHON\Python310\share\Enrolladoico.ico")

        # Simply set the theme
        rot.tk.call("source", r"C:\PYTHON\Python310\Sun-Valley-ttk-theme-master\sun-valley.tcl")
        rot.tk.call("set_theme", "dark")

        # Set a minsize for the window, and place it in the middle
        rot.update()
        rot.minsize(rot.winfo_width(), rot.winfo_height())
        x_cordinate = int((rot.winfo_screenwidth() / 2) - (rot.winfo_width() / 2))
        y_cordinate = int((rot.winfo_screenheight() / 2) - (rot.winfo_height() / 2))
        rot.geometry("+{}+{}".format(x_cordinate, y_cordinate))

        # Panedwindow
        paned = ttk.PanedWindow()
        paned.grid(row=0, column=0, pady=(0, 0), sticky="news", rowspan=100)

        # Pane #1
        pane_1 = ttk.Frame(paned, padding=0)
        paned.add(pane_1, weight=0)


        # Notebook, pane #2
        pane_2 = ttk.Frame(paned, padding=5)
        paned.add(pane_2, weight=0)

        # Notebook, pane #2
        notebook = ttk.Notebook(pane_2)
        notebook.pack(fill="both", expand=True)

        # Tab #1
        tab_1 = ttk.Frame(notebook)
        for index in [0, 1]:
            tab_1.columnconfigure(index=index, weight=0)
            tab_1.rowconfigure(index=index, weight=0)
            notebook.add(tab_1, text="The Development of Enrollado")

        # Label
        label = ttk.Label(tab_1,text="‎‎‎‎‎‎‎‎",justify="center",font=("-size", 104, "-weight", "bold"),)
        label.grid(row=0, column=0, pady=10, columnspan=2)

        # BG image
        introu = Image.open(r"C:\PYTHON\Python310\share\form.jpg")
        intr = ImageTk.PhotoImage(introu)
        intro = ttk.Label(tab_1,image=intr)
        intro.place(x=0, y=0)

        # Intro label
        fr = ttk.Label(tab_1,text="The goal of this system is to assist admissions staff in enrolling more students.\nThis system was devised in order to make the enrollment process for the\nupcoming school year 2022–2023 more efficient and effective in the most convenient\nway possible. There were several problems faced throughout the development of this system, but\nI was capable of completing it in a short timespan, which improved my programming expertise. ",justify="center",font=("-size", 23, "-weight", "normal"),)
        fr.grid(row=1, column=0, pady=170, columnspan=1)

        # LOGO image
        ing = Image.open("C:\PYTHON\Python310\share\Enrolladopng.png")
        imng = ImageTk.PhotoImage(ing)
        label5 = ttk.Label(tab_1,image=imng)
        label5.grid(row=0, column=0)


        # Tab #2
        tab_2 = ttk.Frame(notebook)
        notebook.add(tab_2, text="Enrollment form")

        # BG image
        intou = Image.open(r"C:\PYTHON\Python310\share\intro.jpg")
        inr = ImageTk.PhotoImage(intou)
        inro = ttk.Label(tab_2,image=inr)
        inro.place(x=0, y=0)

        ##############

该部分与上面的代码有关。它执行似乎并未完全执行的函数

    def entries_check():

        mail = email.get()
        fname = name.get()
        
        # import re module
        import re
        
        # Make a regular expression for validating an Email
        
        regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
        # define a function for validating an email
        
        if(re.fullmatch(regex, email.get()))and 'makatiscience.edu.ph' in email.get():
                # some email stuff
            else:
                aft()
        else:
            email.state(["invalid"])

I'm writing an enrollment program to enroll a large number of students and save their information in a database, however my function isn't running.

THIS is the sample code; I received no errors, so I'm not sure what's wrong.

# imported modules
if __name__ == "__main__":
    # creating instance of window stuff
    def erase(f):
        email.delete(0,"end")

    def erase1(e):
        name.delete(0,"end")

    # Password generator (To be sent on user's email)
    mxchars = string.ascii_letters+string.digits

    for pwd in range(1):
        pw = ''
    for c in range(10):
        pw += random.choice(mxchars)

    def aft():
        rot = tk.Tk()
        rot.title("zZ |Ξηr:book:llado")
        rot.iconbitmap(r"C:\PYTHON\Python310\share\Enrolladoico.ico")

        # Simply set the theme
        rot.tk.call("source", r"C:\PYTHON\Python310\Sun-Valley-ttk-theme-master\sun-valley.tcl")
        rot.tk.call("set_theme", "dark")

        # Set a minsize for the window, and place it in the middle
        rot.update()
        rot.minsize(rot.winfo_width(), rot.winfo_height())
        x_cordinate = int((rot.winfo_screenwidth() / 2) - (rot.winfo_width() / 2))
        y_cordinate = int((rot.winfo_screenheight() / 2) - (rot.winfo_height() / 2))
        rot.geometry("+{}+{}".format(x_cordinate, y_cordinate))

        # Panedwindow
        paned = ttk.PanedWindow()
        paned.grid(row=0, column=0, pady=(0, 0), sticky="news", rowspan=100)

        # Pane #1
        pane_1 = ttk.Frame(paned, padding=0)
        paned.add(pane_1, weight=0)


        # Notebook, pane #2
        pane_2 = ttk.Frame(paned, padding=5)
        paned.add(pane_2, weight=0)

        # Notebook, pane #2
        notebook = ttk.Notebook(pane_2)
        notebook.pack(fill="both", expand=True)

        # Tab #1
        tab_1 = ttk.Frame(notebook)
        for index in [0, 1]:
            tab_1.columnconfigure(index=index, weight=0)
            tab_1.rowconfigure(index=index, weight=0)
            notebook.add(tab_1, text="The Development of Enrollado")

        # Label
        label = ttk.Label(tab_1,text="‎‎‎‎‎‎‎‎",justify="center",font=("-size", 104, "-weight", "bold"),)
        label.grid(row=0, column=0, pady=10, columnspan=2)

        # BG image
        introu = Image.open(r"C:\PYTHON\Python310\share\form.jpg")
        intr = ImageTk.PhotoImage(introu)
        intro = ttk.Label(tab_1,image=intr)
        intro.place(x=0, y=0)

        # Intro label
        fr = ttk.Label(tab_1,text="The goal of this system is to assist admissions staff in enrolling more students.\nThis system was devised in order to make the enrollment process for the\nupcoming school year 2022–2023 more efficient and effective in the most convenient\nway possible. There were several problems faced throughout the development of this system, but\nI was capable of completing it in a short timespan, which improved my programming expertise. ",justify="center",font=("-size", 23, "-weight", "normal"),)
        fr.grid(row=1, column=0, pady=170, columnspan=1)

        # LOGO image
        ing = Image.open("C:\PYTHON\Python310\share\Enrolladopng.png")
        imng = ImageTk.PhotoImage(ing)
        label5 = ttk.Label(tab_1,image=imng)
        label5.grid(row=0, column=0)


        # Tab #2
        tab_2 = ttk.Frame(notebook)
        notebook.add(tab_2, text="Enrollment form")

        # BG image
        intou = Image.open(r"C:\PYTHON\Python310\share\intro.jpg")
        inr = ImageTk.PhotoImage(intou)
        inro = ttk.Label(tab_2,image=inr)
        inro.place(x=0, y=0)

        ##############

THIS PART IS RELATED TO THE CODE ABOVE. IT EXECUTES THE FUNCTION WHICH DOESN'T SEEM TO EXECUTE COMPLETELY

    def entries_check():

        mail = email.get()
        fname = name.get()
        
        # import re module
        import re
        
        # Make a regular expression for validating an Email
        
        regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
        # define a function for validating an email
        
        if(re.fullmatch(regex, email.get()))and 'makatiscience.edu.ph' in email.get():
                # some email stuff
            else:
                aft()
        else:
            email.state(["invalid"])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文