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

Method copy_replace

Lib/tkinter/__init__.py:4470–4530  ·  view source on GitHub ↗

Copy a region from the source image (which must be a PhotoImage) to this image, possibly with pixel zooming and/or subsampling. If no options are specified, this command copies the whole of the source image into this image, starting at coordinates (0, 0). The FROM_C

(self, sourceImage, *, from_coords=None, to=None, shrink=False,
                     zoom=None, subsample=None, compositingrule=None)

Source from the content-addressed store, hash-verified

4468 return self.copy(subsample=(x, y), from_coords=from_coords)
4469
4470 def copy_replace(self, sourceImage, *, from_coords=None, to=None, shrink=False,
4471 zoom=None, subsample=None, compositingrule=None):
4472 """Copy a region from the source image (which must be a PhotoImage) to
4473 this image, possibly with pixel zooming and/or subsampling. If no
4474 options are specified, this command copies the whole of the source
4475 image into this image, starting at coordinates (0, 0).
4476
4477 The FROM_COORDS option specifies a rectangular sub-region of the
4478 source image to be copied. It must be a tuple or a list of 1 to 4
4479 integers (x1, y1, x2, y2). (x1, y1) and (x2, y2) specify diagonally
4480 opposite corners of the rectangle. If x2 and y2 are not specified,
4481 the default value is the bottom-right corner of the source image.
4482 The pixels copied will include the left and top edges of the
4483 specified rectangle but not the bottom or right edges. If the
4484 FROM_COORDS option is not given, the default is the whole source
4485 image.
4486
4487 The TO option specifies a rectangular sub-region of the destination
4488 image to be affected. It must be a tuple or a list of 1 to 4
4489 integers (x1, y1, x2, y2). (x1, y1) and (x2, y2) specify diagonally
4490 opposite corners of the rectangle. If x2 and y2 are not specified,
4491 the default value is (x1,y1) plus the size of the source region
4492 (after subsampling and zooming, if specified). If x2 and y2 are
4493 specified, the source region will be replicated if necessary to fill
4494 the destination region in a tiled fashion.
4495
4496 If SHRINK is true, the size of the destination image should be
4497 reduced, if necessary, so that the region being copied into is at
4498 the bottom-right corner of the image.
4499
4500 If SUBSAMPLE or ZOOM are specified, the image is transformed as in
4501 the subsample() or zoom() methods. The value must be a single
4502 integer or a pair of integers.
4503
4504 The COMPOSITINGRULE option specifies how transparent pixels in the
4505 source image are combined with the destination image. When a
4506 compositing rule of 'overlay' is set, the old contents of the
4507 destination image are visible, as if the source image were printed
4508 on a piece of transparent film and placed over the top of the
4509 destination. When a compositing rule of 'set' is set, the old
4510 contents of the destination image are discarded and the source image
4511 is used as-is. The default compositing rule is 'overlay'.
4512 """
4513 options = []
4514 if from_coords is not None:
4515 options.extend(('-from', *from_coords))
4516 if to is not None:
4517 options.extend(('-to', *to))
4518 if shrink:
4519 options.append('-shrink')
4520 if zoom is not None:
4521 if not isinstance(zoom, (tuple, list)):
4522 zoom = (zoom,)
4523 options.extend(('-zoom', *zoom))
4524 if subsample is not None:
4525 if not isinstance(subsample, (tuple, list)):
4526 subsample = (subsample,)
4527 options.extend(('-subsample', *subsample))

Callers 3

copyMethod · 0.95
test_copy_replaceMethod · 0.95

Calls 3

extendMethod · 0.45
appendMethod · 0.45
callMethod · 0.45

Tested by 2

test_copy_replaceMethod · 0.76