[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
Example 11-8. PP4E\Gui\MovingPics\movingpics.py """ ############################################################################ ...
Keyboard commands: w=Pick border width c=Pick color u=Pick move unit s=Pick move delay o=Draw ovals r=Draw rectangles l=Draw lin ...
pickPens = ['elastic', 'scribble', 'trails'] class MovingPics: def init(self, parent=None): canvas = Canvas(parent, width=500, h ...
reptX = abs(diffX) // pickUnits[0] # incr per move, number moves reptY = abs(diffY) // pickUnits[0] # from last to event click i ...
'?': MovingPics.help} try: keymapevent.char except KeyError: self.setTextInfo('Press? for help') def changeDraw(self, method, na ...
if file: self.canvas.postscript(file=file) # save canvas to file def help(self): self.setTextInfo(helpstr) showinfo('PyDraw', he ...
from movingpics import * class MovingPicsAfter(MovingPics): def doMoves(self, delay, objectId, incrX, reptX, incrY, reptY): if r ...
reflection of the overhead incurred for switching the interpreter (and CPU) between multiple threads—but again, this can vary. E ...
MovingPicsThreaded(root) mainloop() PyClock: An Analog/Digital Clock Widget One of the first things I always look for when explo ...
number of points to be plotted, and then multiplying by the point number; in case you’ve forgotten too, it’s 360 degrees around ...
if name == 'main': Width = 500 # default width, height if len(sys.argv) == 2: Width = int(sys.argv[1]) # width cmdline arg? orig ...
For more help, this book’s examples distribution also includes text-based versions of this plotting script that print circle poi ...
To understand how these points are mapped to a canvas, you first need to know that the width and height of a circle are always t ...
To minimize screen updates, PyClock redraws only clock hands on second rollovers; points on the clock’s circle are redrawn only ...
and digital displays are both constructed when the script starts, but only one is ever packed at any given time. A right mouse c ...
classes I teach to remind myself and my students when it’s time to move on (the effect is more striking when this pop up is proj ...
More generally, you can run this file directly to start a clock with or without arguments, import and make its objects with conf ...
class ClockConfig: defaults--override in instance or subclass size = 200 # width=height bg, fg = 'beige', 'brown' # face, tick c ...
try: self.image = PhotoImage(file=cfg.picture) # bkground except: self.image = BitmapImage(file=cfg.picture) # save ref imgx = ( ...
self.drawClockface(cfg) # onUpdate called next ############################################################################### # ...
«
35
36
37
38
39
40
41
42
43
44
»
Free download pdf