mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
Give in to the tab police.
This commit is contained in:
parent
6f73c1a2ac
commit
c457048744
6 changed files with 286 additions and 276 deletions
|
@ -51,8 +51,14 @@ def _cnfmerge(cnfs):
|
||||||
class Event:
|
class Event:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
_support_default_root = 1
|
||||||
_default_root = None
|
_default_root = None
|
||||||
|
|
||||||
|
def NoDefaultRoot():
|
||||||
|
global _support_default_root
|
||||||
|
_support_default_root = 0
|
||||||
|
del _default_root
|
||||||
|
|
||||||
def _tkerror(err):
|
def _tkerror(err):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -702,6 +708,7 @@ class Misc:
|
||||||
|
|
||||||
# Support for the "event" command, new in Tk 4.2.
|
# Support for the "event" command, new in Tk 4.2.
|
||||||
# By Case Roole.
|
# By Case Roole.
|
||||||
|
# XXX Why is this using the default root?
|
||||||
|
|
||||||
def event_add(self,virtual, *sequences):
|
def event_add(self,virtual, *sequences):
|
||||||
args = ('event', 'add', virtual) + sequences
|
args = ('event', 'add', virtual) + sequences
|
||||||
|
@ -857,14 +864,14 @@ class Tk(Misc, Wm):
|
||||||
self.tk.createcommand('tkerror', _tkerror)
|
self.tk.createcommand('tkerror', _tkerror)
|
||||||
self.tk.createcommand('exit', _exit)
|
self.tk.createcommand('exit', _exit)
|
||||||
self.readprofile(baseName, className)
|
self.readprofile(baseName, className)
|
||||||
if not _default_root:
|
if _support_default_root and not _default_root:
|
||||||
_default_root = self
|
_default_root = self
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
for c in self.children.values(): c.destroy()
|
for c in self.children.values(): c.destroy()
|
||||||
self.tk.call('destroy', self._w)
|
self.tk.call('destroy', self._w)
|
||||||
Misc.destroy(self)
|
Misc.destroy(self)
|
||||||
global _default_root
|
global _default_root
|
||||||
if _default_root is self:
|
if _support_default_root and _default_root is self:
|
||||||
_default_root = None
|
_default_root = None
|
||||||
def readprofile(self, baseName, className):
|
def readprofile(self, baseName, className):
|
||||||
import os
|
import os
|
||||||
|
@ -994,6 +1001,7 @@ class Grid:
|
||||||
|
|
||||||
class BaseWidget(Misc):
|
class BaseWidget(Misc):
|
||||||
def _setup(self, master, cnf):
|
def _setup(self, master, cnf):
|
||||||
|
if _support_default_root:
|
||||||
global _default_root
|
global _default_root
|
||||||
if not master:
|
if not master:
|
||||||
if not _default_root:
|
if not _default_root:
|
||||||
|
@ -1693,10 +1701,12 @@ class OptionMenu(Menubutton):
|
||||||
self.__menu = None
|
self.__menu = None
|
||||||
|
|
||||||
class Image:
|
class Image:
|
||||||
def __init__(self, imgtype, name=None, cnf={}, **kw):
|
def __init__(self, imgtype, name=None, cnf={}, master=None, **kw):
|
||||||
self.name = None
|
self.name = None
|
||||||
|
if not master:
|
||||||
master = _default_root
|
master = _default_root
|
||||||
if not master: raise RuntimeError, 'Too early to create image'
|
if not master:
|
||||||
|
raise RuntimeError, 'Too early to create image'
|
||||||
self.tk = master.tk
|
self.tk = master.tk
|
||||||
if not name:
|
if not name:
|
||||||
name = `id(self)`
|
name = `id(self)`
|
||||||
|
@ -1741,8 +1751,8 @@ class Image:
|
||||||
self.tk.call('image', 'width', self.name))
|
self.tk.call('image', 'width', self.name))
|
||||||
|
|
||||||
class PhotoImage(Image):
|
class PhotoImage(Image):
|
||||||
def __init__(self, name=None, cnf={}, **kw):
|
def __init__(self, name=None, cnf={}, master=None, **kw):
|
||||||
apply(Image.__init__, (self, 'photo', name, cnf), kw)
|
apply(Image.__init__, (self, 'photo', name, cnf, master), kw)
|
||||||
def blank(self):
|
def blank(self):
|
||||||
self.tk.call(self.name, 'blank')
|
self.tk.call(self.name, 'blank')
|
||||||
def cget(self, option):
|
def cget(self, option):
|
||||||
|
@ -1784,8 +1794,8 @@ class PhotoImage(Image):
|
||||||
apply(self.tk.call, args)
|
apply(self.tk.call, args)
|
||||||
|
|
||||||
class BitmapImage(Image):
|
class BitmapImage(Image):
|
||||||
def __init__(self, name=None, cnf={}, **kw):
|
def __init__(self, name=None, cnf={}, master=None, **kw):
|
||||||
apply(Image.__init__, (self, 'bitmap', name, cnf), kw)
|
apply(Image.__init__, (self, 'bitmap', name, cnf, master), kw)
|
||||||
|
|
||||||
def image_names(): return _default_root.tk.call('image', 'names')
|
def image_names(): return _default_root.tk.call('image', 'names')
|
||||||
def image_types(): return _default_root.tk.call('image', 'types')
|
def image_types(): return _default_root.tk.call('image', 'types')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue