Blog Pages

1/5/18

Raspberry Pi 3 GUI - Part 3 - Window Button using Tkinter

Window Button with TKINTER

This button will close the window when pressed.

(1)
Add code in BOLD to your python editor. Need help? See Part-1.

#! /usr/bin/env python
from Tkinter import*

window = Tk()
window.title( 'tkinter3.py')
window.geometry('500x300')

exit_button = \
Button(window, text='EXIT', command=exit)
exit_button.pack(padx=100, pady=100)
window.mainloop()

(2)
My code looks like this:


(3)
Save to your Desktop. Name your file tkinter3.py.
Change directory with cd Desktop in your terminal editor.

Enter chmod 755 tkinter3.py into your terminal editor.
Enter ./tkinter3.py into your terminal editor.

(4)
Desktop screen capture showing window with "EXIT" button. When you click the button the window will close.


(5)
Button Clicked - Window Closed


NEXT UP? CREATING TEXT IN YOUR WINDOW

Thanks for reading,
Trenton

No comments:

Post a Comment