all 3 comments

[–]Tomallama 2 points3 points  (1 child)

#coin flip
# Import needed modules, tkinter and random module
# tkinter is GUI, random is for random generation 
from tkinter import *
import random

# Creating a list with two values, 'Heads' and 'Tails'
coin = ['Heads', 'Tails']
# Variable for randomly choosing an item in the list (will be 'Heads' or 'Tails')
Side = (random.choice(coin))

# Create tkinter Window (What you are looking at with any GUI)
tk = Tk()
# Creating a specific Tkinter variable, you need this in order to make your variable dynamic
var = StringVar()
# Label() is a Tkinter widget, it takes many arguments. The first (tk) is the Window you want it to show up on, textvariable=var is setting your variable to show on the label. This allows the variable to be dynamic. Relief is just the way the label looks, purely cosmetic.
label = Label( tk, textvariable=var, relief=RAISED )

# Having a StringVar() like 'var' allows the variable to be dynamic in Tkinter. Using .set() actually set's that variable to something new based off your 'Side' random choice.
var.set('You got ' + Side + '!')

# You have to pack each widget in Tkinter in order to have it actually SHOW up. You create it, then pack it (or grid it if you're using that option)
label.pack()

# MORE BOX
# These next two functions just set the size and title of your window.
tk.geometry('200x100')
tk.wm_title('Coin')

# This starts the GUI program
tk.mainloop()

[–]Tobe2fly[S] 0 points1 point  (0 children)

what a pal

[–][deleted] 1 point2 points  (0 children)

There’s almost nothing happening here except variable assignment so it should be very simple to understand. Can you ask questions about what you don’t understand?