article

Showing posts with label Python-Tkinter. Show all posts
Showing posts with label Python-Tkinter. Show all posts

Wednesday, April 5, 2023

Python Tkinter Loading Screen - Splash Screen

Python Tkinter Loading Screen - Splash Screen

loadingscreen/loading.py
 
#loadingscreen/loading.py
from tkinter import *
from tkinter.ttk import Progressbar
import sys
import home
import os

root = Tk()
# root.resizable(0, 0)
image = PhotoImage(file='images\\loading.png')

height = 653
width = 736
x = (root.winfo_screenwidth()//2)-(width//2)
y = (root.winfo_screenheight()//2)-(height//2)
root.geometry('{}x{}+{}+{}'.format(width, height, x, y))
root.overrideredirect(1)

root.wm_attributes('-topmost', True)
root.lift()
root.wm_attributes("-topmost", True)
root.wm_attributes("-disabled", True)
root.wm_attributes("-transparentcolor", "white")

bg_label = Label(root, image=image, bg='white')
bg_label.place(x=0, y=0)

progress_label = Label(root, text="Please Wait...", font=('Comic Sans MS', 13, 'bold'), fg='#14183e', bg='#71b3ef')
progress_label.place(x=190, y=430)
progress = Progressbar(root, orient=HORIZONTAL, length=360, mode='determinate')
progress.place(x=190, y=480)

def top():
    root.withdraw()
    os.system("python home.py")
    root.destroy()


i = 0


def load():
    global i
    if i <= 10:
        txt = 'Please Wait...  ' + (str(10*i)+'%')
        progress_label.config(text=txt)
        progress_label.after(1000, load)
        progress['value'] = 10*i
        i += 1
    else:
        top()

load()

root.mainloop()
loadingscreen/home.py
 
#loadingscreen/home.py
from tkinter import *
from PIL import ImageTk, Image, ImageDraw
import sqlite3


class HomePage:
    def __init__(self, System_window):
        self.System_window = System_window

        # Window Size and Placement
        System_window.rowconfigure(0, weight=1)
        System_window.columnconfigure(0, weight=1)
        height = 650
        width = 700
        x = (System_window.winfo_screenwidth()//2)-(width//2)
        y = (System_window.winfo_screenheight()//4)-(height//4)
        System_window.geometry('{}x{}+{}+{}'.format(width, height, x, y))
        System_window.resizable(0, 0)

        # window Icon
        icon = PhotoImage(file='images\\logo.png')
        System_window.iconphoto(True, icon)

        System_window.title('Inventory System')

        Label(System_window, text = "Username").place(x = 40,y = 60) 
           
        Label(System_window, text = "Password").place(x = 40, y = 100) 
           
        Button(System_window, text = "Submit").place(x = 40, y = 130)
           
        Entry(System_window, width = 30).place(x = 110, y = 60) 
           
        Entry(System_window, width = 30).place(x = 110, y = 100) 
        
def page():
    window = Tk()
    HomePage(window)
    window.mainloop()


if __name__ == '__main__':
    page()
download splash screen png file https://drive.google.com/file/d/1O9csuWnQfe60pqL5z12V_18ELDwqErOp/view?usp=share_link

Run PS C:\python_dev\tkinter\loadingscreen> python loading.py

Saturday, August 27, 2022

Python Tkinter Simple Login form

Python Tkinter Simple Login form

#login.py
from tkinter import *
from tkinter import messagebox
 
def login():
    uname = e1.get()
    password = e2.get()
 
    if(uname == "" and password == "") :
        messagebox.showinfo("", "Blank Not allowed")
 
 
    elif(uname == "cairocoders" and password == "123456"):
 
        messagebox.showinfo("","Login Success")
        root.destroy()
 
    else :
        messagebox.showinfo("","Incorrent Username and Password")

root = Tk()
root.title("Login")
root.geometry("400x200")
global e1
global e2

Label(root, text="Login form using Python Tkinter").place(x=5, y=10)

Label(root, text="UserName").place(x=10, y=40)
Label(root, text="Password").place(x=10, y=60)

e1 = Entry(root)
e1.place(x=140, y=40)
 
e2 = Entry(root)
e2.place(x=140, y=60)
e2.config(show="*")
 
Button(root, text="Login", command=login ,height = 2, width = 13).place(x=10, y=100)

root.mainloop()

Thursday, March 26, 2020

Registration Form With sqlite3 database using tkinter python



Registration Form With sqlite3 database using tkinter python

 
from tkinter import *
import sqlite3

root = Tk()
root.geometry('600x500')
root.title("Registration Form")


Fullname=StringVar()
Email=StringVar()
var = IntVar()
c=StringVar()
var1= IntVar()



def database():
   name1=Fullname.get()
   email=Email.get()
   gender=var.get()
   country=c.get()
   prog=var1.get()
   conn = sqlite3.connect('Form.db')
   with conn:
      cursor=conn.cursor()
   cursor.execute('CREATE TABLE IF NOT EXISTS Student (Fullname TEXT,Email TEXT,Gender TEXT,country TEXT,Programming TEXT)')
   cursor.execute('INSERT INTO Student (FullName,Email,Gender,country,Programming) VALUES(?,?,?,?,?)',(name1,email,gender,country,prog,))
   conn.commit()
   
   
             
label_0 = Label(root, text="Registration form",width=20,font=("bold", 20))
label_0.place(x=90,y=53)


label_1 = Label(root, text="FullName",width=20,font=("bold", 10))
label_1.place(x=80,y=130)

entry_1 = Entry(root,textvar=Fullname)
entry_1.place(x=240,y=130)

label_2 = Label(root, text="Email",width=20,font=("bold", 10))
label_2.place(x=68,y=180)

entry_2 = Entry(root,textvar=Email)
entry_2.place(x=240,y=180)

label_3 = Label(root, text="Gender",width=20,font=("bold", 10))
label_3.place(x=70,y=230)

Radiobutton(root, text="Male",padx = 5, variable=var, value=1).place(x=235,y=230)
Radiobutton(root, text="Female",padx = 20, variable=var, value=2).place(x=290,y=230)

label_4 = Label(root, text="country",width=20,font=("bold", 10))
label_4.place(x=70,y=280)

list1 = ['Philippines','Japan','Korea','China','Singapore','Hong kong'];

droplist=OptionMenu(root,c, *list1)
droplist.config(width=15)
c.set('select your country') 
droplist.place(x=240,y=280)

label_4 = Label(root, text="Programming",width=20,font=("bold", 10))
label_4.place(x=85,y=330)
var2= IntVar()
Checkbutton(root, text="java", variable=var1).place(x=235,y=330)

Checkbutton(root, text="python", variable=var2).place(x=290,y=330)

Button(root, text='Submit',width=20,bg='brown',fg='white',command=database).place(x=180,y=380)

root.mainloop()

Wednesday, July 3, 2019

Python GUI Tkinter Checkbutton Tutorial

Python GUI Tkinter Checkbutton Tutorial
 
from Tkinter import *
master = Tk()
master.geometry('250x200')

def var_states():
    print("Male : %d, \nFemale : %d" % (var1.get(), var2.get()))
def callbackFunc():
    if (chkValue.get()):
       tlabel = Label(master, text="Oh. I'm click value is {}".format(chkValue.get()))
       tlabel.pack()
    else:
       tlabel = Label(master, text="Oh. I'm Not clicked")
       tlabel.pack()
Label(master, text="Your sex:").grid(row=0, sticky=W)
var1 = IntVar()
Checkbutton(master, text="Male", variable=var1).grid(row=1, sticky=W)
var2 = IntVar()
Checkbutton(master, text="Female", variable=var2).grid(row=2, sticky=W)
Button(master, text="Quit", command=master.quit).grid(row=3, sticky=W, pady=4)
Button(master, text='Show', command=var_states).grid(row=4, sticky=W, pady=4)

chkValue = BooleanVar()
chkExample = Checkbutton(master, text="Check box", var=chkValue,command=callbackFunc)
chkExample.grid(column=10,row=10)
mainloop()

Tuesday, July 2, 2019

Python GUI Tkinter Button Tutorial

Python GUI Tkinter Button Tutorial
 
import Tkinter as tk

counter = 0
def counter_label(lable):
    counter = 0
    def count():
    global counter
    counter +=1
    label.config(text=str(counter))
    label.after(1000,count)
    count()
  
root = tk.Tk()
root.title("Counting Seconds")
label = tk.Label(root, fg="dark green")
label.pack()
counter_label(label)
button = tk.Button(root, text="Stop", width=25, command=root.destroy)
button.pack()
root.mainloop()
 
import Tkinter
import tkMessageBox

top = Tkinter.Tk()

def helloCallBack():
    tkMessageBox.showinfo("hello Python","Hello word")
B = Tkinter.Button(top,text="Hello button",command=helloCallBack)
B.pack()
top.mainloop();
 
from tkinter import *
from tkinter import messagebox 
top = Tk()  
top.geometry("300x200") 
top.title('Hello Python')

def red():  
    messagebox.showerror("Hello", "Red Button clicked") 
def blue():  
    messagebox.showinfo("Hello", "Blue Button clicked") 
def green():  
    messagebox.showinfo("Hello", "Green Button clicked") 
def clicked():
    res = "Welcome to " + txt.get()
    lbl.configure(text= res)
b1 = Button(top,text = "Red",command = red,activeforeground = "red",activebackground = "pink",bg="green",font="14",pady=10) 
b2 = Button(top, text = "Blue",command = blue,activeforeground = "blue",activebackground = "pink",pady=10)  
b3 = Button(top, text = "Green",command = green,activeforeground = "green",activebackground = "pink",pady = 10)  
b4 = Button(top, text = "Yellow",command = clicked,activeforeground = "yellow",activebackground = "pink",pady = 10) 
lbl = Label(top,text = "Hello",font="14") 
txt = Entry(top,width=50)
b1.pack(side = LEFT) 
b2.pack(side = RIGHT)  
b3.pack(side = TOP)  
b4.pack(side = BOTTOM)  
lbl.pack()  
txt.pack(side = TOP)
top.mainloop() 

Related Post