© 2017 by Revel Carlberg West. All rights reserved.
Tkinter is way for kids to use GUIs. That creates a basic window like this:
with just the code:
import tkinter
window = tkinter.Tk()
and than you can add stuff to it like this:
but of course the button doesn't do anything because we didn't tell it to do something
import tkinter
window = tkinter.Tk()
#defines a button. "window" means
#put the button the window, and
#"text=" means what the button
#should say
button = tkinter.Button(window, text='Press Me')
button.pack()#tells the button to go on the window
so I modified it so it would do something when you click it, and that something was print "hello world"
and this is the code i used to make the button print hello world
import tkinter
def do_something():
print('hello world')
window = tkinter.Tk()
button = tkinter.Button(window, text='Press Me', command=do_something)
button.pack()