Page 80 - Programming the Raspberry Pi Getting Started with Python
P. 80

Figure 7-12    The Canvas widget
             The Canvas is just like any other widget you can add to a window. The following example shows
          how to draw rectangles, ovals, and lines:


























             You can draw arcs, images, polygons, and text in a similar way. Refer to an online Tkinter reference
          such as http://infohost.nmt.edu/tcc/help/pubs/tkinter/ for more information.
          NOTE   The origin of the coordinates is the top-left corner of the window, and the coordinates are in
               pixels.

          Summary
          In a book this size, it is sometimes only possible to introduce a topic and get you started on the right
          path. Once you’ve followed the examples in this chapter, run them, altered them, and analyzed what’s
          going on, you will soon find yourself hungry for more information. You will get past the need for
          hand-holding and have specific ideas of what you want to write. No book is going to tell you exactly
          how to build the project you have in your head. This is where the Internet really comes into its own.
             Good online references to take what you’ve learned further can be found here:
             •  www.pythonware.com/library/tkinter/introduction/
             •  http://infohost.nmt.edu/tcc/help/pubs/tkinter/
   75   76   77   78   79   80   81   82   83   84   85