Have you ever wanted to make an App in python?
Well, Tkinter is where to start!
What is Tkinter?
Tkinter is an in-build python library that you can get by adding "import tkinter" to the top of your script.
I made an Example app that you can expand upon or use as reference!
Just copy this code! (Note either way, you will need Python, or Visual Studio Code installed with the Python Extension
import math
import random
import tkinter as tk
import time
#Hello, this is the Engineering Catβ’ sample app code for Tkinter
#You can use this as reference or to expand upon, head to https://www.engineeringcat.com/contact for any questions / feedback
#We will respond within 24 hours, and we deeply appreciate your questions / feedback
#App Required Variables
minNum = 0
maxNum = 0
generatedNum = 0
#Configurable App Variable
windowTitle = "Random Number Generator"
backgroundColor = "lightblue"
spacerSize = 10
normalFontSize = 10
outputFontSize = 15
#Setup
root = tk.Tk()
root.title(str(windowTitle))
root.geometry("800x500")
root.config(bg=str(backgroundColor))
#App Methods
def generateNumber():
global minNum
global maxNum
global generatedNum
minNum = int(minimumInput.get())
maxNum = int(maximumInput.get())
generatedNum = random.randrange(minNum, maxNum)
outputText.config(text=generatedNum)
#Elements
welcomeTitle = tk.Label(text="Hello, welcome to Random Number Generator!\n Just input a minimum value and a maximum value and click generate!", background=backgroundColor, font=("Ariel", normalFontSize))
welcomeTitle.pack()
spacer = tk.Label(text="", background=backgroundColor, font=("Ariel", spacerSize))
spacer.pack()
minText = tk.Label(text="Minimum", background=backgroundColor)
minText.pack()
minimumInput = tk.Entry()
minimumInput.pack()
maxText = tk.Label(text="Maximum", background=backgroundColor)
maxText.pack()
maximumInput = tk.Entry()
maximumInput.pack()
generateButton = tk.Button(text="Generate", command=generateNumber)
generateButton.pack()
spacer1 = tk.Label(text="", background=backgroundColor, font=("Ariel", spacerSize))
spacer1.pack()
outputText = tk.Label(text="", background=backgroundColor, font=("Ariel", outputFontSize))
outputText.pack()
#This is the END of the script (for Tkinter) and any app related info should go above this line!
root.mainloop()