Table of Contents
Preface
Chapter 1: Start your Engines
Chapter 2: Drawing Fundamental Shapes
Chapter 3: Handling Text
Chapter 4: Animation Principles
Chapter 5: The Magic of Color
Chapter 6: Working with Pictures
Chapter 7: Combining Raster and Vector Pictures
Chapter 8: Data In and Data Out
Chapter 9: Exchanging Inkscape SVG Drawings with Tkinter Shapes
Chapter 10: GUI Construction: Part 1
Chapter 11: GUI Construction: Part 2
Appendix: Quick tips for running Python programs in Microsoft Windows
Index
- Chapter 1: Start your Engines
- Introduction
- Running a shortest Python program
- Ensuring that the Python modules are present
- A basic Tkinter program
- Make a compiled executable under Windows and Linux
- Chapter 2: Drawing Fundamental Shapes
- Introduction
- A straight line and the coordinate system
- Draw a dashed line
- Lines of varying styles with arrows and endcaps
- A two segment line with a sharp bend
- A line with a curved bend
- Drawing intricate shapes – the curly vine
- Draw a rectangle
- Draw overlapping rectangles
- Draw concentric squares
- A circle from an oval
- A circle from an arc
- Three arc ellipses
- Polygons
- A star polygon
- Cloning and resizing stars
- Chapter 3: Handling Text
- Introduction
- Simple text
- Text font type, size, and color
- Alignment of text – left and right justify
- All the fonts available on your computer
- Chapter 4: Animation Principles
- Introduction
- Static shifting of a ball
- Time-controlled shifting of a ball
- Complete animation using draw-move-pause-erase cycles
- More than one moving object
- A ball that bounces
- Bouncing in a gravity field
- Precise collisions using floating point numbers
- Trajectory tracing and ball-to-ball collisions
- Rotating line
- Trajectory tracing on multiple line rotations
- A rose for you
- Chapter 5: The Magic of Color
- Introduction
- A limited palette of named colors
- Nine ways of specifying color
- A red beachball of varying hue
- A red color wedge of graded hue
- Newton's grand wheel of color mixing
- The numerical color mixing matching palette
- The animated graded color wheel
- Tkinter's own color picker-mixer
- Chapter 6: Working with Pictures
- Opening an image file and discovering its attributes
- Open, view, and save an image in a different file format
- Image format conversion for JPEG, PNG, TIFF, GIF, BMP
- Image rotation in the plane of the image
- Image size alteration
- Correct proportion image resizing
- Separating one color band in an image
- Red, green, and blue color alteration in images
- Slider controlled color manipulation
- Combining images by blending
- Blending images by varying percentages
- Make a composite image using a mask image
- Offset (roll) image horizontally and vertically
- Flip horizontally, vertically, and rotate
- Filter effects: blur, sharpen, contrast, and so on
- Chapter 7: Combining Raster and Vector Pictures
- Simple animation of a GIF beach ball
- The vector walking creature
- Bird with shoes walking in the Karroo
- Making GIF images with transparent backgrounds using GIMP
- Diplomat walking at the palace
- Spider in the forest
- Moving band of images
- Continuous band of images
- Endless background
- Chapter 8: Data In and Data Out
- Introduction
- Creation of a new file on a hard drive
- Writing data to a newly-created file
- Writing data to multiple files
- Adding data to existing files
- Saving a Tkinter-drawing shape to disk
- Retrieving Python data from disk storage
- Simple mouse input
- Storing and retrieving a mouse-drawn shape
- A mouse-line editor
- All possible mouse actions
- Chapter 9: Exchanging Inkscape SVG Drawings with Tkinter Shapes
- Introduction
- The structure of an SVG drawing
- Tracing the shape of an image in Inkscape
- Converting an SVG path into a Tkinter Line
- Chapter 10: GUI Construction: Part 1
- Introduction
- Widget configuration – a label
- Button focus
- The simplest push button with validation
- A data entry box
- Colored button causing a message pop-up
- Complex interaction between buttons
- Images on buttons and button packing
- Grid Geometry Manager and button arrays
- Drop-down menus to select from a list
- Listbox variable selection
- Text in a window
- Chapter 11: GUI Construction: Part 2
- Introduction
- The Grid Layout Geometry Manager
- The Pack Geometry Manager
- Radiobuttons to select one from many
- Checkbuttons (Tickboxes) to select some of many
- Key-stroke event handling
- Scrollbar
- Custom DIY controller widgets
- Organizing widgets inside frames
- Appendix: Quick tips for running Python programs in Microsoft Windows
- Running Python programs in Microsoft Windows
- Where will we find the windows installer?
- Do we have to use Python version 2.7?
- Why do we get "python is not recognized…"?