sg_tick_tkinter_add_tb.py

sg_tick_tkinter_add_tb.py   introduces two new tkinter "widgets" - Frame and Text.  Prints ‘tick’ to the tkinter window as well as the terminal. The Frame widget is called at line 17  with app = Frame(root)   ‘root’ is the name I gave the window, ‘app’ the name I gave this particular frame (you can have multiple frames).  Line 19, app.grid() assigns a layout method called ‘grid’.  There are other layout methods but grid is the newest and probably the best to use.  I gave a link to a page on layout management options on line 23.

“Text” is the name of a widget that creates a text box you can print to.  I called this one ‘t_box’ and created it at line 44, with the .grid placement on line 48.  This is the normal way we’ll work on widgets, creating them with a function call assigned to a variable name, then placing them in the grid of the frame.  So two lines per button/box/label etc is the norm. Finally, in the ‘tick’ function I added a line to insert ‘tick’ with a new line (\n) in the text box each time the function runs.  So this is fairly simple but it’s worth taking a moment to make sure you understand each step.

If you want to learn more about these widgets here are sample links.  We’ll see them again soon if you want to wait though.  They may seem pretty simple in this example but Frame has 18 configuration options and Text has 38, plus another 50+ ways of handling text:

http://effbot.org/tkinterbook/frame.htm

http://www.tutorialspoint.com/python/tk_frame.htm

http://effbot.org/tkinterbook/text.htm

http://www.tutorialspoint.com/python/tk_text.htm