0% found this document useful (0 votes)
29 views

Frontpage Design

This Python code defines a Frontpage class that creates a Tkinter GUI with a background image and login form. The Frontpage initializes with a root window, loads a background image by resizing it to fit the screen, and displays a welcome message centered on the canvas. It then creates a login frame centered on the screen with labels and entries for username and password, and a button to create an account. The main function initializes the Frontpage and starts the main loop.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Frontpage Design

This Python code defines a Frontpage class that creates a Tkinter GUI with a background image and login form. The Frontpage initializes with a root window, loads a background image by resizing it to fit the screen, and displays a welcome message centered on the canvas. It then creates a login frame centered on the screen with labels and entries for username and password, and a button to create an account. The main function initializes the Frontpage and starts the main loop.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import tkinter as tk

from tkinter import Canvas, Entry, Button


from PIL import Image, ImageTk

class Frontpage:
def __init__(self, root):
self.root = root
self.root.title("Image Background Example")

self.screen_width = self.root.winfo_screenwidth()
self.screen_height = self.root.winfo_screenheight()

self.load_background_image()
self.create_welcome_message()
self.show_login_box()

def load_background_image(self):
image_path = "C:\\Users\\Taha\\Desktop\\LULU\\1-python project\\
Airportmanagement\\airplane1_png.png"
image = Image.open(image_path)
self.resized_image = image.resize((self.screen_width, self.screen_height))
self.background_image = ImageTk.PhotoImage(self.resized_image)

self.canvas = Canvas(self.root, width=self.screen_width,


height=self.screen_height)
self.canvas.pack()
self.canvas.create_image(0, 0, anchor=tk.NW, image=self.background_image)

def create_welcome_message(self):
welcome_message = "WELCOME"
font_size = 60
font_family = "Helvetica"
text_color = "black"

self.canvas.create_text(
self.screen_width // 2,
self.screen_height // 8,
text=welcome_message,
fill=text_color,
font=(font_family, font_size, "bold")
)

def show_login_box(self):
self.login_frame = tk.Frame(self.root, width=300, height=200, bg="#C5C6D0")
self.login_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER)

self.username_label = tk.Label(self.login_frame, text="LOGIN PAGE:",


font=("Helvetica", 19, "bold"), bg="#C5C6D0")
self.username_label.grid(row=0, column=0, padx=10, pady=10)

self.username_label = tk.Label(self.login_frame, text="Username:",


font=("Helvetica", 14), bg="#594D5B")
self.username_label.grid(row=1, column=0, padx=10, pady=10)

self.username_entry = Entry(self.login_frame, font=("Helvetica", 14))


self.username_entry.grid(row=1, column=1, padx=10, pady=10)

self.password_label = tk.Label(self.login_frame, text="Password:",


font=("Helvetica", 14), bg="white")
self.password_label.grid(row=2, column=0, padx=10, pady=10)
self.password_entry = Entry(self.login_frame, show="*", font=("Helvetica",
14))
self.password_entry.grid(row=2, column=1, padx=10, pady=10)

self.password_label = tk.Label(self.login_frame, text="Password:",


font=("Helvetica", 14), bg="white")
self.password_label.grid(row=3, column=0, padx=10, pady=10)
self.password_entry = Entry(self.login_frame, show="*", font=("Helvetica",
14))
self.password_entry.grid(row=3, column=1, padx=10, pady=10)

self.create_account_button = Button(self.login_frame, text="Create


Account", font=("Helvetica", 14), bg="blue", fg="white")
self.create_account_button.grid(row=23, column=0, columnspan=2, padx=10,
pady=10)

def main():
root = tk.Tk()
app = Frontpage(root)
root.mainloop()

if __name__ == "__main__":
main()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy