#Tkinter Demonstration by Kuba Karys

#IMPORT
from tkinter import * 
master = Tk()

#DEFINITIONS
def mkbutton(): 
    print("Hello, World!")

def infodisplay(): 
    messagebox.showinfo("A little information window", "This is an information dialog. Kuba is the best, yo!") 

def warndisplay(): 
    messagebox.showwarning("Careful there!", "This is a warning. The earth will explode in 1 minute.") 

def errordisplay(): 
    messagebox.showerror("Oh no!", "This is an error. This computer will combust momentarily!") 

def askyesno(): 
    messagebox.askyesno("Options Menu", "Would you like to click yes or no?")

#LIST
rbList = [("Option 1", "1"), ("Option 2", "2"),]

#LABELLING/TEXT
Paragraph1 = Label(master, text="Produced by Kuba Karys") 
Paragraph1.pack() 

#BUTTON
regButton = Button(master, text="PRINT OUTPUT", command=mkbutton) 
regButton.pack() 

#CHECKBOX
checkBox = Checkbutton(master, text="This is a checkbox.") 
checkBox.pack() 

val = StringVar() 
val.set("1") 

#RADIOBUTTON
for text, mode in rbList: 
    radioButton = Radiobutton(master, text=text, variable=val, value=mode) 
    radioButton.pack(anchor=W)

#INFORMATION DIALOGUE
infoButton = Button(master, text="INFO", fg="blue", command=infodisplay) 
infoButton.pack()

#WARNING DIALOGUE
warningButton = Button(master, text="WARNING", fg="orange", command=warndisplay)
warningButton.pack()

#ERROR DIALOGUE
errorButton = Button(master, text="ERROR", fg="red", command=errordisplay) 
errorButton.pack() 

#QUESTION MENU
askQuestionButton = Button(master, text="QUESTION", fg="green", command=askyesno) 
askQuestionButton.pack()

#SCROLLBAR
textScroller = Scrollbar(master) 
listbox = Listbox(master, yscrollcommand=textScroller.set)
for i in range(35):
    listbox.insert(END, str(i)) 
listbox.pack(side=RIGHT, fill=BOTH) 

textScroller.config(command=listbox.yview) 
textScroller.pack(side=RIGHT, fill=Y) 

#If you wanted to, you could make a horizontal scrollbar by using xview and xscrollcommand instead.

#SPINBOX SELECTOR
spinBoxRun = Spinbox(master, from_=0, to=10)
spinBoxRun.pack()

#TEXTBOX
e = Entry(master)
e.pack()

e.delete(0, END)
e.insert(0, "An editable textbox!")

#In the next updates of this file, I plan to make the textbox's value available to save to a variable which can then be printed to the Python console.

#IMAGES
image = PhotoImage(file="happy.gif")
Label(master, image=image).pack()

#MESSAGE LABELLING
mes = Message(master, text="This method of displaying text is mostly obsolete as the label() function does the same.", fg="blue")
mes.pack()

#PACK
mainloop() #Calls mainloop, which allows the Tkinter program to run.

#There are many more features included here that are not shown in this demonstration.













