MCPcopy Index your code
hub / github.com/python/cpython / Canvas

Class Canvas

Lib/tkinter/__init__.py:2962–3265  ·  view source on GitHub ↗

Canvas widget to display graphical elements like lines or text.

Source from the content-addressed store, hash-verified

2960
2961
2962class Canvas(Widget, XView, YView):
2963 """Canvas widget to display graphical elements like lines or text."""
2964
2965 def __init__(self, master=None, cnf={}, **kw):
2966 """Construct a canvas widget with the parent MASTER.
2967
2968 Valid option names: background, bd, bg, borderwidth, closeenough,
2969 confine, cursor, height, highlightbackground, highlightcolor,
2970 highlightthickness, insertbackground, insertborderwidth,
2971 insertofftime, insertontime, insertwidth, offset, relief,
2972 scrollregion, selectbackground, selectborderwidth, selectforeground,
2973 state, takefocus, width, xscrollcommand, xscrollincrement,
2974 yscrollcommand, yscrollincrement."""
2975 Widget.__init__(self, master, 'canvas', cnf, kw)
2976
2977 def addtag(self, *args):
2978 """Internal function."""
2979 self.tk.call((self._w, 'addtag') + args)
2980
2981 def addtag_above(self, newtag, tagOrId):
2982 """Add tag NEWTAG to all items above TAGORID."""
2983 self.addtag(newtag, 'above', tagOrId)
2984
2985 def addtag_all(self, newtag):
2986 """Add tag NEWTAG to all items."""
2987 self.addtag(newtag, 'all')
2988
2989 def addtag_below(self, newtag, tagOrId):
2990 """Add tag NEWTAG to all items below TAGORID."""
2991 self.addtag(newtag, 'below', tagOrId)
2992
2993 def addtag_closest(self, newtag, x, y, halo=None, start=None):
2994 """Add tag NEWTAG to item which is closest to pixel at X, Y.
2995 If several match take the top-most.
2996 All items closer than HALO are considered overlapping (all are
2997 closest). If START is specified the next below this tag is taken."""
2998 self.addtag(newtag, 'closest', x, y, halo, start)
2999
3000 def addtag_enclosed(self, newtag, x1, y1, x2, y2):
3001 """Add tag NEWTAG to all items in the rectangle defined
3002 by X1,Y1,X2,Y2."""
3003 self.addtag(newtag, 'enclosed', x1, y1, x2, y2)
3004
3005 def addtag_overlapping(self, newtag, x1, y1, x2, y2):
3006 """Add tag NEWTAG to all items which overlap the rectangle
3007 defined by X1,Y1,X2,Y2."""
3008 self.addtag(newtag, 'overlapping', x1, y1, x2, y2)
3009
3010 def addtag_withtag(self, newtag, tagOrId):
3011 """Add tag NEWTAG to all items with TAGORID."""
3012 self.addtag(newtag, 'withtag', tagOrId)
3013
3014 def bbox(self, *args):
3015 """Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle
3016 which encloses all items with tags specified as arguments."""
3017 return self._getints(
3018 self.tk.call((self._w, 'bbox') + args)) or None
3019

Callers 3

__init__Method · 0.90
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…