mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #22236: Tkinter tests now don't reuse default root window. New root
window is created for every test class. Fixed Tkinter images copying operations in NoDefaultRoot mode. Tcl command names generated for "after" callbacks now contains a name of original function.
This commit is contained in:
parent
ee55826072
commit
d00aff2f62
15 changed files with 231 additions and 271 deletions
|
@ -562,6 +562,7 @@ class Misc:
|
|||
self.deletecommand(name)
|
||||
except TclError:
|
||||
pass
|
||||
callit.__name__ = func.__name__
|
||||
name = self._register(callit)
|
||||
return self.tk.call('after', ms, name)
|
||||
def after_idle(self, func, *args):
|
||||
|
@ -3351,7 +3352,7 @@ class Image:
|
|||
master = _default_root
|
||||
if not master:
|
||||
raise RuntimeError('Too early to create image')
|
||||
self.tk = master.tk
|
||||
self.tk = getattr(master, 'tk', master)
|
||||
if not name:
|
||||
Image._last_id += 1
|
||||
name = "pyimage%r" % (Image._last_id,) # tk itself would use image<x>
|
||||
|
@ -3422,20 +3423,20 @@ class PhotoImage(Image):
|
|||
# XXX copy -from, -to, ...?
|
||||
def copy(self):
|
||||
"""Return a new PhotoImage with the same image as this widget."""
|
||||
destImage = PhotoImage()
|
||||
destImage = PhotoImage(master=self.tk)
|
||||
self.tk.call(destImage, 'copy', self.name)
|
||||
return destImage
|
||||
def zoom(self,x,y=''):
|
||||
"""Return a new PhotoImage with the same image as this widget
|
||||
but zoom it with X and Y."""
|
||||
destImage = PhotoImage()
|
||||
destImage = PhotoImage(master=self.tk)
|
||||
if y=='': y=x
|
||||
self.tk.call(destImage, 'copy', self.name, '-zoom',x,y)
|
||||
return destImage
|
||||
def subsample(self,x,y=''):
|
||||
"""Return a new PhotoImage based on the same image as this widget
|
||||
but use only every Xth or Yth pixel."""
|
||||
destImage = PhotoImage()
|
||||
destImage = PhotoImage(master=self.tk)
|
||||
if y=='': y=x
|
||||
self.tk.call(destImage, 'copy', self.name, '-subsample',x,y)
|
||||
return destImage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue