I'm pretty new to coding so bear with me if my code looks like crap (which is probably does.) I just want my output to appear in the GUI I made instead of in the shell. How do I modify my code to make this happen?
import random
from tkinter import *
# Attributes
age = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
"21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58",
"59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77",
"78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96",
"97", "98", "99", "100", ]
country = ["United States", "Brazil", "Mexico", "China", "Japan", "Canada", "France", "Germany"]
male_name = ["Joe", "Eden", "Diego", "Anthony", "Jarod", "Kique", "Austin", "Hunter"]
female_name = ["Haley", "Ariana", "Sarah", "Jackie", "Serena"]
gender_male = "Male"
gender_female = "Female"
# Random Generation
def print_start_life(event):
Text(window, text=print(random.choice(age)), font=("Arial Bold", 16))
Text(window, text=print(random.choice(country)), font=("Arial Bold", 16))
Text(window, text=print(random.choice(male_name or female_name)), font=("Arial Bold", 16))
if male_name:
Text(window, text=print(gender_male), font=("Arial Bold", 16))
elif female_name:
Text(window, text=print(gender_female), font=("Arial Bold", 16))
# GUI
window = Tk()
window.title("Random Life")
window.geometry('800x500')
lbl = Label(window, text="Do you want to play Random Life?", font=("Arial Bold", 25))
lbl.grid(column=0, row=0)
btn = Button(window, text="Yes")
btn.bind("<Button-1>", print_start_life)
btn.grid(column=1, row=0)
window.mainloop()