Tkinter Tutorial 4

Now that we can place both labels and buttons we can combine the two, so that the buttons have labels,  this is not really needed but this also shows how we can display two objects of a different type within a window.

#define functions for button(s)
def btn1():
	print ("button pressed")
 
#create button object	
btn_tog2 = Button( window, text ='button1', command=btn1)
btn_exit = Button( window, text ='exit',command=exit)	
 
#place button object
btn_tog2.grid(row = 1, column = 2, padx = 5, pady = 5)
btn_exit.grid(row = 2, column = 2, padx = 5, pady = 5)
 
#define labeles
button1 = Label(window, text="press button")
button2 = Label(window, text="exit program")
 
#place labels
button1.grid(row = 1, column = 1, padx = 5, pady = 5)
button2.grid(row = 2, column = 1, padx = 5, pady = 5)

There is no real need to explain the code,  as the previous 2 tutorials have done that,  you should end up with something like this

button2