| | |
Printing in one window
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2007
Posts: 6
Reputation:
Solved Threads: 0
I created a function that creates smiley faces. I want to print more than 1 (with different size and location) on 1 window. How do I do it? Here is the code:
Python Syntax (Toggle Plain Text)
from graphics import * def main(): print drawface(Point(40, 40), 20, GraphWin) print drawface(Point(90, 90), 30, GraphWin) print drawface(Point(130, 160), 10, GraphWin) def drawface(center, size, win): win = GraphWin() win.setBackground('white') center = Circle(center, size) center.draw(win) Point1 = center.getCenter() Point2 = size * .20 Point3 = size * .30 Point4 = size * .40 Point5 = size * .25 lefteye = Circle(Point1, Point2) lefteye.move(-Point3, -Point2) lefteye.draw(win) righteye = Circle(Point1, Point2) righteye.move(Point3, -Point2) righteye.draw(win) mouth = Circle(Point1, Point3) mouth.move(0, Point4) mouth.draw(win) mouth2 = Circle(Point1, Point3) mouth2.setFill('white') mouth2.setOutline('white') mouth2.move(0, Point5) mouth2.draw(win) main()
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 150
If you walk through your code carefully, you'll see that the drawface() function does *way* too much. As a result, it clobbers any old faces that might be on the screen. The solution is to move the initialization out of the drawface() function, and then let drawface() do one single thing: draw a face.
Hope that helps; I've left out some of the details so that you can get the benefit of the debugging experience.
Jeff
Hope that helps; I've left out some of the details so that you can get the benefit of the debugging experience.
Jeff
![]() |
Similar Threads
- edges of print missing when printing web pages (Web Browsers)
- Setting up wireless printing - having problems (Networking Hardware Configuration)
- Printing using Web Control Print button. (ASP.NET)
- Printing in Java (Java)
- Burner Drive, Printing, PDFs (Apple Hardware)
- Help needed for a printing routine (Visual Basic 4 / 5 / 6)
- Printing Web Page (Windows 95 / 98 / Me)
Other Threads in the Python Forum
- Previous Thread: Style issue ... def main()
- Next Thread: wxPython DateTime problems
| Thread Tools | Search this Thread |
abrupt ansi anti apache application approximation array backend beginner binary book builtin calculator converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit examples file float format function gui heads homework import inches input java launcher library line lines linux list lists loop mouse movingimageswithpygame mysql mysqlquery number numbers numeric output parsing path phonebook plugin pointer port prime programming progressbar projects py2exe pygame pysimplewizard python random recursion redirect remote reverse scrolledtext session simple smtp software statictext statistics string strings syntax table terminal text textarea thread threading time tlapse trick tricks tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython





