Python Forum
GUI for simple python project
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GUI for simple python project
#3
Hello Qwertz, here is your required gui code. I am also beginner to tkinter and gui creation but with the help of google this is what I made. Hope it works fine for you.

# importing the required libraries
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
# creating an instance of tkinter window
win = Tk()
# set geometry of your frame
win.geometry('550x300')
# your function to get values from user in tkinter widget
def enterNumber():
    try:
        hours = int(float(entry.get()))
        minutes = int(((float(entry.get()) * 60) % 60))
    except:
        messagebox.showerror('Error', 'Not a number.')
    Label(win, text = ('%s hours and %s minutes.')%(hours, minutes), font=('Century 16')).pack(pady = 20)
# create an Entry widget
entry = ttk.Entry(win, font = ('Century 12'), width = 40)
entry.pack(pady = 30)
# create a button to display the output
button = ttk.Button(win, text = 'Enter', command = enterNumber)
button.pack()
win.mainloop()
 # enjou with peace
   
Reply


Messages In This Thread
GUI for simple python project - by Qwertz - Jan-24-2022, 10:24 PM
RE: GUI for simple python project - by deanhystad - Jan-24-2022, 11:27 PM
RE: GUI for simple python project - by Hilal - Jan-25-2022, 04:49 PM
RE: GUI for simple python project - by Axel_Erfurt - Jan-25-2022, 05:49 PM
RE: GUI for simple python project - by menator01 - Jan-26-2022, 10:29 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020