Book Image

Tkinter GUI Application Development HOTSHOT

By : Bhaskar Chaudhary
Book Image

Tkinter GUI Application Development HOTSHOT

By: Bhaskar Chaudhary

Overview of this book

<p>Tkinter is the built-in GUI package that comes with standard python distributions. This means it is easy to get started right away, without any extra installation or configuration. Tkinter’s strength lies in its simplicity of use and its intuitive nature which makes it suited for programmers and non-programmers alike. Once you get started, you will be surprised to see how a few lines of code can produce powerful GUI applications.</p> <p>Tkinter GUI Application Development Hotshot helps you learn the art of GUI programming—building real-world, productive and fun applications like text editor, drum machine, game of chess, media player, drawing application and many more. Each subsequent project builds on the skills acquired in the previous project. Also, learn to write multi-threaded and multi layered applications using Tkinter. Get to know modern best practices involved in writing GUI programs. Tkinter GUI Application Development Hotshot comes with a rich source of sample codes that you can use in your own projects in any discipline of your choice.</p> <p>Starting with a high level overview of Tkinter that covers the most important concepts involved in writing a GUI application, the book then takes you through a series of real world projects of increasing complexity, developing one project per chapter. After you have developed five full projects, the book provides you with some bare-bone skeleton codes for a few functional but incomplete projects, challenging you to put your skills to test by completing them.</p> <p>Finally, you are provided with tips for writing reusable, scalable, and quality GUI code for larger projects. The appendices provide a quick reference sheet for Tkinter.</p>
Table of Contents (16 chapters)
Tkinter GUI Application Development HOTSHOT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Drawing items on the canvas


Let's now draw some items on the canvas. The Canvas widget natively supports drawing the following items:

Item

Code for adding the item

Arc

w.create_arc( bbox, **options)

Bitmap

w.create_bitmap( bbox, **options)

Image

w.create_image( bbox, **options)

Line

w.create_line( bbox, **options)

Oval

w.create_oval( bbox, **options)

Polygon

w.create_ploygon( bbox, **options)

Rectangle

w.create_rectangle( bbox, **options)

Text

w.create_text( bbox, **options)

Window

w.create_window( bbox, **options)

Let us add the ability to draw lines, rectangles, and ovals to our drawing program. We will also add a brush stroke feature to our program, as shown in the following screenshot:

Engage Thrusters

Step 1 – creating a tuple of methods

We first create a tuple of methods that we intend to define here as follows:

all_toolbar_functions = ('draw_line', 'draw_rectangle', 'draw_oval', 'draw_brush')

Doing so ensures that we do not have to call each...