Blog Pages

1/5/18

Raspberry pi 3 GUI - Part 2 - Window Size in Tkinter

Setting Window Size In Tkinter
To set a window to an initial size we will be using ".geometry".

(1) 
Insert the BOLD code into your python editor. (See Part-1 for help with IDLE)

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

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

window.mainloop()

My code looks like this:


(2)
Save your work using the same procedure as in Part-1. Only this time name your file tkinter2.py.

(3)
Open your terminal window and change directory to your Desktop.
Enter cd Desktop in your terminal window. Click enter.
Enter chmod 755 tkinter2.py in your terminal editor. Click enter.
Enter ./tkinter2.py in your terminal window. Click enter.
Ignore my scrot commands in my terminal window.



(4)
If everything went OK then your screen should produce a window (below) with a larger size. Note: The window is not currently doing anything except opening.

Throughout these posts I will show you how to build a GUI that will actually do cool audio control stuff.

For now, practice the procedure I just showed you until you can enter all of the code without looking at mine. Also, play around with different window sizes while you are at it.

TKINTER2.PY GUI RESULTS:
Here is the screen capture for my Ras-pi-3 running tkinter2.py.


"Part-1" screen of tkinter1.py: Notice the size difference of the grey window?


NEXT UP? ADDING A SIMPLE BUTTON

Thanks for reading,
Trenton

No comments:

Post a Comment