36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import tkinter as tk
|
|
|
|
|
|
|
|
class LoginView(tk.Frame):
|
|
def __init__(self, master=None):
|
|
super().__init__(master)
|
|
self.create_widgets()
|
|
|
|
def create_widgets(self):
|
|
# Username Label and Entry
|
|
username_label = tk.Label(self, text="Username:")
|
|
username_label.pack(pady=5)
|
|
self.username_entry = tk.Entry(self)
|
|
self.username_entry.pack(pady=5)
|
|
|
|
# Password Label and Entry
|
|
password_label = tk.Label(self, text="Password:")
|
|
password_label.pack(pady=5)
|
|
self.password_entry = tk.Entry(self, show="*") # Use show="*" to hide password characters
|
|
self.password_entry.pack(pady=5)
|
|
|
|
# Login Button
|
|
login_button = tk.Button(self, text="Submit", command=self.on_login)
|
|
login_button.pack(pady=10)
|
|
|
|
def on_login(self):
|
|
# Retrieve username and password values
|
|
username = self.username_entry.get()
|
|
password = self.password_entry.get()
|
|
|
|
# Example: Check credentials (you'll need to implement your own logic)
|
|
if username == "example" and password == "password":
|
|
self.master.show_main_view()
|
|
else:
|
|
print("Invalid credentials") |