mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Couple more has_keys() going...
This commit is contained in:
parent
6e23e3796d
commit
e014a13f03
5 changed files with 26 additions and 26 deletions
|
@ -107,7 +107,7 @@ class FileDialog:
|
||||||
self.top.bind('<Alt-W>', self.cancel_command)
|
self.top.bind('<Alt-W>', self.cancel_command)
|
||||||
|
|
||||||
def go(self, dir_or_file=os.curdir, pattern="*", default="", key=None):
|
def go(self, dir_or_file=os.curdir, pattern="*", default="", key=None):
|
||||||
if key and dialogstates.has_key(key):
|
if key and key in dialogstates:
|
||||||
self.directory, pattern = dialogstates[key]
|
self.directory, pattern = dialogstates[key]
|
||||||
else:
|
else:
|
||||||
dir_or_file = os.path.expanduser(dir_or_file)
|
dir_or_file = os.path.expanduser(dir_or_file)
|
||||||
|
|
|
@ -13,7 +13,7 @@ import sys, os
|
||||||
prefix = os.path.join(sys.prefix,"tcl")
|
prefix = os.path.join(sys.prefix,"tcl")
|
||||||
# if this does not exist, no further search is needed
|
# if this does not exist, no further search is needed
|
||||||
if os.path.exists(prefix):
|
if os.path.exists(prefix):
|
||||||
if not os.environ.has_key("TCL_LIBRARY"):
|
if "TCL_LIBRARY" not in os.environ:
|
||||||
for name in os.listdir(prefix):
|
for name in os.listdir(prefix):
|
||||||
if name.startswith("tcl"):
|
if name.startswith("tcl"):
|
||||||
tcldir = os.path.join(prefix,name)
|
tcldir = os.path.join(prefix,name)
|
||||||
|
@ -23,13 +23,13 @@ if os.path.exists(prefix):
|
||||||
# as Tcl
|
# as Tcl
|
||||||
import _tkinter
|
import _tkinter
|
||||||
ver = str(_tkinter.TCL_VERSION)
|
ver = str(_tkinter.TCL_VERSION)
|
||||||
if not os.environ.has_key("TK_LIBRARY"):
|
if "TK_LIBRARY" not in os.environ:
|
||||||
v = os.path.join(prefix, 'tk'+ver)
|
v = os.path.join(prefix, 'tk'+ver)
|
||||||
if os.path.exists(os.path.join(v, "tclIndex")):
|
if os.path.exists(os.path.join(v, "tclIndex")):
|
||||||
os.environ['TK_LIBRARY'] = v
|
os.environ['TK_LIBRARY'] = v
|
||||||
# We don't know the Tix version, so we must search the entire
|
# We don't know the Tix version, so we must search the entire
|
||||||
# directory
|
# directory
|
||||||
if not os.environ.has_key("TIX_LIBRARY"):
|
if "TIX_LIBRARY" not in os.environ:
|
||||||
for name in os.listdir(prefix):
|
for name in os.listdir(prefix):
|
||||||
if name.startswith("tix"):
|
if name.startswith("tix"):
|
||||||
tixdir = os.path.join(prefix,name)
|
tixdir = os.path.join(prefix,name)
|
||||||
|
|
|
@ -321,7 +321,7 @@ class TixWidget(Tkinter.Widget):
|
||||||
# We can even do w.ok.invoke() because w.ok is subclassed from the
|
# We can even do w.ok.invoke() because w.ok is subclassed from the
|
||||||
# Button class if you go through the proper constructors
|
# Button class if you go through the proper constructors
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if self.subwidget_list.has_key(name):
|
if name in self.subwidget_list:
|
||||||
return self.subwidget_list[name]
|
return self.subwidget_list[name]
|
||||||
raise AttributeError, name
|
raise AttributeError, name
|
||||||
|
|
||||||
|
@ -446,9 +446,9 @@ class TixSubWidget(TixWidget):
|
||||||
# also destroys the parent NoteBook thus leading to an exception
|
# also destroys the parent NoteBook thus leading to an exception
|
||||||
# in Tkinter when it finally calls Tcl to destroy the NoteBook
|
# in Tkinter when it finally calls Tcl to destroy the NoteBook
|
||||||
for c in self.children.values(): c.destroy()
|
for c in self.children.values(): c.destroy()
|
||||||
if self.master.children.has_key(self._name):
|
if self._name in self.master.children:
|
||||||
del self.master.children[self._name]
|
del self.master.children[self._name]
|
||||||
if self.master.subwidget_list.has_key(self._name):
|
if self._name in self.master.subwidget_list:
|
||||||
del self.master.subwidget_list[self._name]
|
del self.master.subwidget_list[self._name]
|
||||||
if self.destroy_physically:
|
if self.destroy_physically:
|
||||||
# This is bypassed only for a few widgets
|
# This is bypassed only for a few widgets
|
||||||
|
@ -470,8 +470,8 @@ class DisplayStyle:
|
||||||
|
|
||||||
def __init__(self, itemtype, cnf={}, **kw):
|
def __init__(self, itemtype, cnf={}, **kw):
|
||||||
master = _default_root # global from Tkinter
|
master = _default_root # global from Tkinter
|
||||||
if not master and cnf.has_key('refwindow'): master=cnf['refwindow']
|
if not master and 'refwindow' in cnf: master=cnf['refwindow']
|
||||||
elif not master and kw.has_key('refwindow'): master= kw['refwindow']
|
elif not master and 'refwindow' in kw: master= kw['refwindow']
|
||||||
elif not master: raise RuntimeError, "Too early to create display style: no root window"
|
elif not master: raise RuntimeError, "Too early to create display style: no root window"
|
||||||
self.tk = master.tk
|
self.tk = master.tk
|
||||||
self.stylename = self.tk.call('tixDisplayStyle', itemtype,
|
self.stylename = self.tk.call('tixDisplayStyle', itemtype,
|
||||||
|
@ -553,7 +553,7 @@ class ButtonBox(TixWidget):
|
||||||
return btn
|
return btn
|
||||||
|
|
||||||
def invoke(self, name):
|
def invoke(self, name):
|
||||||
if self.subwidget_list.has_key(name):
|
if name in self.subwidget_list:
|
||||||
self.tk.call(self._w, 'invoke', name)
|
self.tk.call(self._w, 'invoke', name)
|
||||||
|
|
||||||
class ComboBox(TixWidget):
|
class ComboBox(TixWidget):
|
||||||
|
@ -1413,7 +1413,7 @@ class StdButtonBox(TixWidget):
|
||||||
self.subwidget_list['help'] = _dummyButton(self, 'help')
|
self.subwidget_list['help'] = _dummyButton(self, 'help')
|
||||||
|
|
||||||
def invoke(self, name):
|
def invoke(self, name):
|
||||||
if self.subwidget_list.has_key(name):
|
if name in self.subwidget_list:
|
||||||
self.tk.call(self._w, 'invoke', name)
|
self.tk.call(self._w, 'invoke', name)
|
||||||
|
|
||||||
class TList(TixWidget):
|
class TList(TixWidget):
|
||||||
|
|
|
@ -550,7 +550,7 @@ class Misc:
|
||||||
|
|
||||||
A widget specified for the optional displayof keyword
|
A widget specified for the optional displayof keyword
|
||||||
argument specifies the target display."""
|
argument specifies the target display."""
|
||||||
if not kw.has_key('displayof'): kw['displayof'] = self._w
|
if 'displayof' not in kw: kw['displayof'] = self._w
|
||||||
self.tk.call(('clipboard', 'clear') + self._options(kw))
|
self.tk.call(('clipboard', 'clear') + self._options(kw))
|
||||||
def clipboard_append(self, string, **kw):
|
def clipboard_append(self, string, **kw):
|
||||||
"""Append STRING to the Tk clipboard.
|
"""Append STRING to the Tk clipboard.
|
||||||
|
@ -558,7 +558,7 @@ class Misc:
|
||||||
A widget specified at the optional displayof keyword
|
A widget specified at the optional displayof keyword
|
||||||
argument specifies the target display. The clipboard
|
argument specifies the target display. The clipboard
|
||||||
can be retrieved with selection_get."""
|
can be retrieved with selection_get."""
|
||||||
if not kw.has_key('displayof'): kw['displayof'] = self._w
|
if 'displayof' not in kw: kw['displayof'] = self._w
|
||||||
self.tk.call(('clipboard', 'append') + self._options(kw)
|
self.tk.call(('clipboard', 'append') + self._options(kw)
|
||||||
+ ('--', string))
|
+ ('--', string))
|
||||||
# XXX grab current w/o window argument
|
# XXX grab current w/o window argument
|
||||||
|
@ -619,7 +619,7 @@ class Misc:
|
||||||
self.tk.call('option', 'readfile', fileName, priority)
|
self.tk.call('option', 'readfile', fileName, priority)
|
||||||
def selection_clear(self, **kw):
|
def selection_clear(self, **kw):
|
||||||
"""Clear the current X selection."""
|
"""Clear the current X selection."""
|
||||||
if not kw.has_key('displayof'): kw['displayof'] = self._w
|
if 'displayof' not in kw: kw['displayof'] = self._w
|
||||||
self.tk.call(('selection', 'clear') + self._options(kw))
|
self.tk.call(('selection', 'clear') + self._options(kw))
|
||||||
def selection_get(self, **kw):
|
def selection_get(self, **kw):
|
||||||
"""Return the contents of the current X selection.
|
"""Return the contents of the current X selection.
|
||||||
|
@ -628,7 +628,7 @@ class Misc:
|
||||||
the selection and defaults to PRIMARY. A keyword
|
the selection and defaults to PRIMARY. A keyword
|
||||||
parameter displayof specifies a widget on the display
|
parameter displayof specifies a widget on the display
|
||||||
to use."""
|
to use."""
|
||||||
if not kw.has_key('displayof'): kw['displayof'] = self._w
|
if 'displayof' not in kw: kw['displayof'] = self._w
|
||||||
return self.tk.call(('selection', 'get') + self._options(kw))
|
return self.tk.call(('selection', 'get') + self._options(kw))
|
||||||
def selection_handle(self, command, **kw):
|
def selection_handle(self, command, **kw):
|
||||||
"""Specify a function COMMAND to call if the X
|
"""Specify a function COMMAND to call if the X
|
||||||
|
@ -659,7 +659,7 @@ class Misc:
|
||||||
be provided:
|
be provided:
|
||||||
selection - name of the selection (default PRIMARY),
|
selection - name of the selection (default PRIMARY),
|
||||||
type - type of the selection (e.g. STRING, FILE_NAME)."""
|
type - type of the selection (e.g. STRING, FILE_NAME)."""
|
||||||
if not kw.has_key('displayof'): kw['displayof'] = self._w
|
if 'displayof' not in kw: kw['displayof'] = self._w
|
||||||
name = self.tk.call(('selection', 'own') + self._options(kw))
|
name = self.tk.call(('selection', 'own') + self._options(kw))
|
||||||
if not name: return None
|
if not name: return None
|
||||||
return self._nametowidget(name)
|
return self._nametowidget(name)
|
||||||
|
@ -1692,7 +1692,7 @@ class Tk(Misc, Wm):
|
||||||
the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if
|
the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if
|
||||||
such a file exists in the home directory."""
|
such a file exists in the home directory."""
|
||||||
import os
|
import os
|
||||||
if os.environ.has_key('HOME'): home = os.environ['HOME']
|
if 'HOME' in os.environ: home = os.environ['HOME']
|
||||||
else: home = os.curdir
|
else: home = os.curdir
|
||||||
class_tcl = os.path.join(home, '.%s.tcl' % className)
|
class_tcl = os.path.join(home, '.%s.tcl' % className)
|
||||||
class_py = os.path.join(home, '.%s.py' % className)
|
class_py = os.path.join(home, '.%s.py' % className)
|
||||||
|
@ -1808,7 +1808,7 @@ class Place:
|
||||||
into account
|
into account
|
||||||
"""
|
"""
|
||||||
for k in ['in_']:
|
for k in ['in_']:
|
||||||
if kw.has_key(k):
|
if k in kw:
|
||||||
kw[k[:-1]] = kw[k]
|
kw[k[:-1]] = kw[k]
|
||||||
del kw[k]
|
del kw[k]
|
||||||
self.tk.call(
|
self.tk.call(
|
||||||
|
@ -1900,7 +1900,7 @@ class BaseWidget(Misc):
|
||||||
self.master = master
|
self.master = master
|
||||||
self.tk = master.tk
|
self.tk = master.tk
|
||||||
name = None
|
name = None
|
||||||
if cnf.has_key('name'):
|
if 'name' in cnf:
|
||||||
name = cnf['name']
|
name = cnf['name']
|
||||||
del cnf['name']
|
del cnf['name']
|
||||||
if not name:
|
if not name:
|
||||||
|
@ -1911,7 +1911,7 @@ class BaseWidget(Misc):
|
||||||
else:
|
else:
|
||||||
self._w = master._w + '.' + name
|
self._w = master._w + '.' + name
|
||||||
self.children = {}
|
self.children = {}
|
||||||
if self.master.children.has_key(self._name):
|
if self._name in self.master.children:
|
||||||
self.master.children[self._name].destroy()
|
self.master.children[self._name].destroy()
|
||||||
self.master.children[self._name] = self
|
self.master.children[self._name] = self
|
||||||
def __init__(self, master, widgetName, cnf={}, kw={}, extra=()):
|
def __init__(self, master, widgetName, cnf={}, kw={}, extra=()):
|
||||||
|
@ -1934,7 +1934,7 @@ class BaseWidget(Misc):
|
||||||
"""Destroy this and all descendants widgets."""
|
"""Destroy this and all descendants widgets."""
|
||||||
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)
|
||||||
if self.master.children.has_key(self._name):
|
if self._name in self.master.children:
|
||||||
del self.master.children[self._name]
|
del self.master.children[self._name]
|
||||||
Misc.destroy(self)
|
Misc.destroy(self)
|
||||||
def _do(self, name, args=()):
|
def _do(self, name, args=()):
|
||||||
|
@ -1962,7 +1962,7 @@ class Toplevel(BaseWidget, Wm):
|
||||||
extra = ()
|
extra = ()
|
||||||
for wmkey in ['screen', 'class_', 'class', 'visual',
|
for wmkey in ['screen', 'class_', 'class', 'visual',
|
||||||
'colormap']:
|
'colormap']:
|
||||||
if cnf.has_key(wmkey):
|
if wmkey in cnf:
|
||||||
val = cnf[wmkey]
|
val = cnf[wmkey]
|
||||||
# TBD: a hack needed because some keys
|
# TBD: a hack needed because some keys
|
||||||
# are not valid as keyword arguments
|
# are not valid as keyword arguments
|
||||||
|
@ -2433,10 +2433,10 @@ class Frame(Widget):
|
||||||
highlightcolor, highlightthickness, relief, takefocus, visual, width."""
|
highlightcolor, highlightthickness, relief, takefocus, visual, width."""
|
||||||
cnf = _cnfmerge((cnf, kw))
|
cnf = _cnfmerge((cnf, kw))
|
||||||
extra = ()
|
extra = ()
|
||||||
if cnf.has_key('class_'):
|
if 'class_' in cnf:
|
||||||
extra = ('-class', cnf['class_'])
|
extra = ('-class', cnf['class_'])
|
||||||
del cnf['class_']
|
del cnf['class_']
|
||||||
elif cnf.has_key('class'):
|
elif 'class' in cnf:
|
||||||
extra = ('-class', cnf['class'])
|
extra = ('-class', cnf['class'])
|
||||||
del cnf['class']
|
del cnf['class']
|
||||||
Widget.__init__(self, master, 'frame', cnf, {}, extra)
|
Widget.__init__(self, master, 'frame', cnf, {}, extra)
|
||||||
|
@ -3179,7 +3179,7 @@ class OptionMenu(Menubutton):
|
||||||
self.menuname = menu._w
|
self.menuname = menu._w
|
||||||
# 'command' is the only supported keyword
|
# 'command' is the only supported keyword
|
||||||
callback = kwargs.get('command')
|
callback = kwargs.get('command')
|
||||||
if kwargs.has_key('command'):
|
if 'command' in kwargs:
|
||||||
del kwargs['command']
|
del kwargs['command']
|
||||||
if kwargs:
|
if kwargs:
|
||||||
raise TclError, 'unknown option -'+kwargs.keys()[0]
|
raise TclError, 'unknown option -'+kwargs.keys()[0]
|
||||||
|
|
|
@ -274,7 +274,7 @@ def askfloat(title, prompt, **kw):
|
||||||
|
|
||||||
class _QueryString(_QueryDialog):
|
class _QueryString(_QueryDialog):
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
if kw.has_key("show"):
|
if "show" in kw:
|
||||||
self.__show = kw["show"]
|
self.__show = kw["show"]
|
||||||
del kw["show"]
|
del kw["show"]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue