Icon which can display itself on a canvas and respond to user interaction.
These icons are generally vector drawn, but a subclass could substitute
raster images.
Methods
|
|
|
|
__init__
|
__init__ (
self,
canvas,
name=None,
ulx=0,
uly=0,
foreground='AntiqueWhite',
lightshadow='tan3',
darkshadow='tan1',
outline='black',
command=None,
allowMotion=0,
width=25,
height=20,
defaultSequence='<ButtonPress-1>',
balloonHelp=None,
balloonFcn=None,
)
Create an AnimatedIcon.
Arguments
-
canvas Canvas widget on which to draw.
-
name Icon name.
-
ulx Upper left X coordinate.
-
uly Upper left Y coordinate.
-
foreground Foreground color, default is AntiqueWhite .
-
lightshadow Light shadow color (for top bevels), default is tan3 .
-
darkshadow Dark shadow color (for bottom bevels), default is tan1 .
-
outline Outline color, default is black
-
command Callable object to invoke as callback.
-
allowMotion Boolean which controls whether the icon can
be dragged. When enabled, the user can click and drag the
icon around the canvas. Defaults to 0 .
-
width Width of icon.
-
height Height of icon.
-
defaultSequence Key sequence which invokes command .
-
balloonHelp Balloon help string to be passed to balloonFcn .
-
balloonFcn Callback to be called on <Enter> and
<Leave> events. The value of balloonHelp is passed as
the only argument.
|
|
__str__
|
__str__ ( self )
|
|
addtag
|
addtag ( self, tag )
Just like other Canvas object addtag methods.
|
|
bbox
|
bbox ( self )
Return the bounding box of the icon.
|
|
bind
|
bind (
self,
event_sequence,
command,
)
Bind a callback to an event sequence.
|
|
clickCB
|
clickCB ( self, event )
A mouse button is clicked.
|
|
delete
|
delete ( self )
Remove the icon from the Canvas.
|
|
dnd_end
|
dnd_end (
self,
target,
event,
)
Abandon drag and drop
|
|
dnd_motion
|
dnd_motion ( self, event )
While dragging.
|
|
dnd_start
|
dnd_start (
self,
widget,
event,
)
Start dragging
|
|
dnd_stop
|
dnd_stop ( self )
Stop dragging
|
|
dupe
|
dupe (
self,
canvas=None,
command=None,
x=None,
y=None,
)
Make another icon just like this one.
|
|
enterCB
|
enterCB ( self, event=None )
Called when mouse pointer enters the icon.
|
|
leaveCB
|
leaveCB ( self, event=None )
Called when mouse pointer leaves the icon.
|
|
motionCB
|
motionCB ( self, event )
Called when there is pointer motion over the icon.
|
|
move
|
move (
self,
x,
y,
)
Move the icon following the standard Tk move() definition.
|
|
moveCanvasObjectToEvent
|
moveCanvasObjectToEvent (
self,
item,
event,
)
DND related method.
|
|
moveItemToEvent
|
moveItemToEvent ( self, event )
DND related method.
The dnd event coordinates are relative to the root window,
not just the canvas. We have to convert them by translating
into the canvas drawing area. Then we can figure out the
change since the last movement, and move the item again.
|
|
pointercoordstowidget
|
pointercoordstowidget (
self,
x,
y,
widget,
)
Correct pointer coordinates
The correction is calculated based on the offset
over a specific widget and return the new (x,y).
|
|
redraw
|
redraw ( self )
|
|
releaseCB
|
releaseCB ( self, event )
A mouse button was released.
|
|
set_geometry
|
set_geometry (
self,
width=None,
height=None,
)
Set the width and or height and redraw.
|
|