Connect Forms in Tkinter

Using python Tkinter we can connect multiple forms . eg. If user enters the correct login details(username & password) then it open the next main menu screen.


Create Login Form (First Page ):

import tkinter as tk
from tkinter import Entry
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
button1 = tk.Button(frame,
text="Login",
fg="blue")
button1.pack(side=tk.LEFT)
button2 = tk.Button(frame,
text="Register",
command=register)
button2.pack(side=tk.LEFT)
root.mainloop()

Create Second Page Registration Page:

Complete code with First page and registration page.
(Registration page opens when we click on register button).

import tkinter as tk
from tkinter import Entry
def register ():
window = tk.Tk()
window.title("GUI")
label = tk.Label(window, text="Enter Username").pack()
#u=StringVar()
global username
global password
username=Entry(window)
#print(u)
username.pack()
label = tk.Label(window, text="Enter password").pack()
password=Entry(window,show='*')
password.pack()
button3=tk.Button(window,
text="OK",
command=ok)
button3.pack(side=tk.LEFT)
button4=tk.Button(window,
text="Cancel",
command=quit)
button4.pack(side=tk.LEFT)
def ok():
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()

button1 = tk.Button(frame,
text="Login",
fg="blue")

button1.pack(side=tk.LEFT)
button2 = tk.Button(frame,
text="Register",
command=register)
button2.pack(side=tk.LEFT)

root.mainloop()
Click Here

Video/ C Introduction

Watch video in full size