Posts

Making GUI Calculator in Tkinter Python

from tkinter import * abdur = Tk () abdur . geometry ( "480x600" ) abdur . minsize ( 480 , 600 ) abdur . maxsize ( 480 , 600 ) abdur . wm_iconbitmap ( "calc.ico" ) abdur . title ( "Calculator - Made by AbdurCodes" ) def calc ( event ):     global entry_val     btext = event .widget.cget( "text" )         try :         if btext == "=" :             if entry_val . get (). isdigit ():                 value = int ( entry_val . get ())             else :                 value = eval ( screen . get ())                             entry_val . set ( value )             screen . update ()                             ...

CHECKBUTTON and ENTRY widget in TKINTER

  from tkinter import * root = Tk () def getvalue ():     print ( "Submitting your form" )     print ( f " { nvalue . get (), fvalue . get (), ovalue . get (), avalue . get () } " )     with open ( "records.txt" , "a" ) as f :         f . write ( f " \n { nvalue . get (), fvalue . get (), ovalue . get (), avalue . get () } " ) root . geometry ( "600x300" ) Label ( text = "Welcome to Abdur GUI" , font = "verdana 16 bold" ). grid ( column = 1 ) name = Label ( root , text = "Name:" ) fname = Label ( root , text = "Father Name:" ) ocupation = Label ( root , text = "Occupation:" ) age = Label ( root , text = "Age:" ) name . grid ( row = 1 ) fname . grid ( row = 2 ) ocupation . grid ( row = 3 ) age . grid ( row = 4 ) nvalue = StringVar () fvalue = StringVar () ovalue = StringVar () avalue = StringVar () bookingval = IntVar () n_entry = Entry ( root , text...

Creating RADIOBUTTONS in TKINTER

  from tkinter import * import tkinter . messagebox as tmsg root = Tk () def info ():     tmsg . showinfo ( "Your Response" , f "Your response is { rad_var . get () } . Thanks!" )     root . geometry ( "700x400" ) root . title ( "Radiobutton Tutor" ) Label ( root , text = "What is your Blood Group?" , font = "verdana 17 bold" ). pack () rad_var = StringVar () rad_var . set ( "+" ) Radiobutton ( root , text = "B+" , value = "B+" , variable = rad_var ). pack ( anchor = CENTER ) Radiobutton ( root , text = "A+" , value = "A+" , variable = rad_var ). pack ( anchor = CENTER ) Radiobutton ( root , text = "AB+" , value = "AB+" , variable = rad_var ). pack ( anchor = CENTER ) Radiobutton ( root , text = "AB-" , value = "AB-" , variable = rad_var ). pack ( anchor = CENTER ) Radiobutton ( root , text = "O+" , value = "O+...

Creating MENU widget in Tkinter

  from tkinter import * root = Tk () def fruits ():     print ( "This is a fruit!" )     def people ():     print ( "This is a person!" )         root . geometry ( "600x200" ) root . title ( "Menus Submenus in Tkinter" ) mymenu = Menu ( root ) m1 = Menu ( mymenu , tearoff = 0 ) m1 . add_command ( label = "Apple" , command = fruits ) m1 . add_command ( label = "banana" , command = fruits ) m1 . add_separator () m1 . add_command ( label = "lemon" , command = fruits ) m1 . add_command ( label = "guava" , command = fruits ) mymenu . add_cascade ( label = "Fruits" , menu = m1 ) m2 = Menu ( mymenu , tearoff = 0 ) m2 . add_command ( label = "adam" , command = people ) m2 . add_command ( label = "john" , command = people ) m2 . add_separator () m2 . add_command ( label = "abdur" , command = people ) m2 . add_command ( label = "wahab" , command = people ) my...

Creating a Status Bar in Tkinter GUI

  from tkinter import * def updating ():     statusvar . set ( "Updating..." )     status_bar . update ()     import time     time . sleep ( 2 )     statusvar . set ( "Updated" )         root = Tk () root . geometry ( "1000x600" ) root . title ( "STATUS BAR Creating" ) Button ( root , text = "Update" , command = updating ). pack ( side = TOP ) statusvar = StringVar () statusvar . set ( "Ready" ) status_bar = Label ( root , textvariable = statusvar , relief = SUNKEN , anchor = W ) status_bar . pack ( side = BOTTOM , fill = X ) root . mainloop ()

Creating a LISTBOX Widget and applying a SCROLLBAR to it (TKINTER, PYTHON)

  from tkinter import * root = Tk () root . geometry ( "1000x600" ) root . title ( "Listbox Creating" ) scrollbar = Scrollbar ( root ) scrollbar . pack ( side = RIGHT , fill = Y ) a = Listbox ( root , yscrollcommand = scrollbar . set , height = 1000 ) for i in range ( 100 ):     a . insert ( END , f "item { i } " ) a . pack ( fill = BOTH ) scrollbar . config ( command = a . yview ) root . mainloop ()

Creating a SLIDER and Dialog Box in Python Tkinter GUI

  from tkinter import * import tkinter . messagebox as tmsg from PIL import Image , ImageTk root = Tk () def rating ():     tmsg . showinfo ( "Your Rating Us" , f "Thanks for your time. You rated us as { scale_val . get () } " )         root . geometry ( "700x400" ) root . title ( "Sliders Tutor" ) foto = Image . open ( "New folder\photo (4).jpg" ) imageFD = ImageTk . PhotoImage ( foto ) imageFD_label = Label ( image = imageFD ) imageFD_label . pack () Label ( root , text = """You ordered food from our Service. How satisfied you are with our service.       (O for Not Satisfied at all while 10 for Absolutely satisfied)""" ). pack () scale_val = Scale ( root , from_ = 0 , to = 10 , orient = "horizontal" ) scale_val . set ( 10 ) scale_val . pack () Button ( root , text = "Rate" , command = rating ). pack () root . mainloop ()