Feb-02-2021, 07:07 PM
Hey, I'm a returning python coder, but it's been a while since the last time I've done anything with functions. I was trying to make a GUI application for generating pseudo-random numbers, but I got a bit puzzled with trying to tell TKinter to get the user input value and use it to generate between 0 and the fetched input.
Constructive criticism and advice is appreciated.
Constructive criticism and advice is appreciated.
import tkinter as tk
import random as rand
window = tk.Tk()
label = tk.Label(
text='Enter a number to inclusively generate up to:',
background='antique white',
)
value = tk.Entry(
bg='antique white',
width=6,
)
button = tk.Button(
text='Generate!',
width=12,
height=3,
)
label.pack()
value.pack()
button.pack()
# The code above should open a window, a label up top,
# an entry field in the middle, and a button on the bottom.
valin = str(value.get())
RNG = rand.randrange(valin())
output = entry.insert(RNG())
# What I want to accomplish is have the program take "valin",
# and use the given integer as an input for "RNG", which is supposed to generate a number
# from 0 to the given input (inclusive), then return the generated value below the button.
window.mainloop()
