mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
new after options; text.search; new image methods
This commit is contained in:
parent
275fbe21c9
commit
96ebbd3082
2 changed files with 74 additions and 4 deletions
|
@ -177,6 +177,7 @@ class Misc:
|
||||||
return self._nametowidget(name)
|
return self._nametowidget(name)
|
||||||
def after(self, ms, func=None, *args):
|
def after(self, ms, func=None, *args):
|
||||||
if not func:
|
if not func:
|
||||||
|
# I'd rather use time.sleep(ms*0.001)
|
||||||
self.tk.call('after', ms)
|
self.tk.call('after', ms)
|
||||||
else:
|
else:
|
||||||
# XXX Disgusting hack to clean up after calling func
|
# XXX Disgusting hack to clean up after calling func
|
||||||
|
@ -188,7 +189,11 @@ class Misc:
|
||||||
tk.deletecommand(tmp[0])
|
tk.deletecommand(tmp[0])
|
||||||
name = self._register(callit)
|
name = self._register(callit)
|
||||||
tmp.append(name)
|
tmp.append(name)
|
||||||
self.tk.call('after', ms, name)
|
return self.tk.call('after', ms, name)
|
||||||
|
def after_idle(self, func, *args):
|
||||||
|
return apply(self.after, ('idle', func) + args)
|
||||||
|
def after_cancel(self, id):
|
||||||
|
self.tk.call('after', 'cancel', id)
|
||||||
def bell(self, displayof=None):
|
def bell(self, displayof=None):
|
||||||
if displayof:
|
if displayof:
|
||||||
self.tk.call('bell', '-displayof', displayof)
|
self.tk.call('bell', '-displayof', displayof)
|
||||||
|
@ -212,7 +217,7 @@ class Misc:
|
||||||
def lower(self, belowThis=None):
|
def lower(self, belowThis=None):
|
||||||
self.tk.call('lower', self._w, belowThis)
|
self.tk.call('lower', self._w, belowThis)
|
||||||
def option_add(self, pattern, value, priority = None):
|
def option_add(self, pattern, value, priority = None):
|
||||||
self.tk.call('option', 'add', pattern, priority)
|
self.tk.call('option', 'add', pattern, value, priority)
|
||||||
def option_clear(self):
|
def option_clear(self):
|
||||||
self.tk.call('option', 'clear')
|
self.tk.call('option', 'clear')
|
||||||
def option_get(self, name, className):
|
def option_get(self, name, className):
|
||||||
|
@ -1190,6 +1195,21 @@ class Text(Widget):
|
||||||
self.tk.call(self._w, 'scan', 'mark', y)
|
self.tk.call(self._w, 'scan', 'mark', y)
|
||||||
def scan_dragto(self, y):
|
def scan_dragto(self, y):
|
||||||
self.tk.call(self._w, 'scan', 'dragto', y)
|
self.tk.call(self._w, 'scan', 'dragto', y)
|
||||||
|
def search(self, pattern, index, stopindex=None,
|
||||||
|
forwards=None, backwards=None, exact=None,
|
||||||
|
regexp=None, nocase=None, count=None):
|
||||||
|
args = [self._w, 'search']
|
||||||
|
if forwards: args.append('-forwards')
|
||||||
|
if backwards: args.append('-backwards')
|
||||||
|
if exact: args.append('-exact')
|
||||||
|
if regexp: args.append('-regexp')
|
||||||
|
if nocase: args.append('-nocase')
|
||||||
|
if count: args.append('-count'); args.append(count)
|
||||||
|
if pattern[0] == '-': args.append('--')
|
||||||
|
args.append(pattern)
|
||||||
|
args.append(index)
|
||||||
|
if stopindex: args.append(stopindex)
|
||||||
|
return apply(self.tk.call, tuple(args))
|
||||||
def tag_add(self, tagName, index1, index2=None):
|
def tag_add(self, tagName, index1, index2=None):
|
||||||
self.tk.call(
|
self.tk.call(
|
||||||
self._w, 'tag', 'add', tagName, index1, index2)
|
self._w, 'tag', 'add', tagName, index1, index2)
|
||||||
|
@ -1287,6 +1307,21 @@ class Image:
|
||||||
class PhotoImage(Image):
|
class PhotoImage(Image):
|
||||||
def __init__(self, name=None, cnf={}, **kw):
|
def __init__(self, name=None, cnf={}, **kw):
|
||||||
apply(Image.__init__, (self, 'photo', name, cnf), kw)
|
apply(Image.__init__, (self, 'photo', name, cnf), kw)
|
||||||
|
def blank(self):
|
||||||
|
self.tk.call(self.name, 'blank')
|
||||||
|
def cget(self):
|
||||||
|
return self.tk.call(self.name, 'cget')
|
||||||
|
# XXX config
|
||||||
|
# XXX copy
|
||||||
|
def get(self, x, y):
|
||||||
|
return self.tk.call(self.name, 'get', x, y)
|
||||||
|
def put(self, data, to=None):
|
||||||
|
args = (self.name, 'put', data)
|
||||||
|
if to:
|
||||||
|
args = args + to
|
||||||
|
apply(self.tk.call, args)
|
||||||
|
# XXX read
|
||||||
|
# XXX write
|
||||||
|
|
||||||
class BitmapImage(Image):
|
class BitmapImage(Image):
|
||||||
def __init__(self, name=None, cnf={}, **kw):
|
def __init__(self, name=None, cnf={}, **kw):
|
||||||
|
|
|
@ -177,6 +177,7 @@ class Misc:
|
||||||
return self._nametowidget(name)
|
return self._nametowidget(name)
|
||||||
def after(self, ms, func=None, *args):
|
def after(self, ms, func=None, *args):
|
||||||
if not func:
|
if not func:
|
||||||
|
# I'd rather use time.sleep(ms*0.001)
|
||||||
self.tk.call('after', ms)
|
self.tk.call('after', ms)
|
||||||
else:
|
else:
|
||||||
# XXX Disgusting hack to clean up after calling func
|
# XXX Disgusting hack to clean up after calling func
|
||||||
|
@ -188,7 +189,11 @@ class Misc:
|
||||||
tk.deletecommand(tmp[0])
|
tk.deletecommand(tmp[0])
|
||||||
name = self._register(callit)
|
name = self._register(callit)
|
||||||
tmp.append(name)
|
tmp.append(name)
|
||||||
self.tk.call('after', ms, name)
|
return self.tk.call('after', ms, name)
|
||||||
|
def after_idle(self, func, *args):
|
||||||
|
return apply(self.after, ('idle', func) + args)
|
||||||
|
def after_cancel(self, id):
|
||||||
|
self.tk.call('after', 'cancel', id)
|
||||||
def bell(self, displayof=None):
|
def bell(self, displayof=None):
|
||||||
if displayof:
|
if displayof:
|
||||||
self.tk.call('bell', '-displayof', displayof)
|
self.tk.call('bell', '-displayof', displayof)
|
||||||
|
@ -212,7 +217,7 @@ class Misc:
|
||||||
def lower(self, belowThis=None):
|
def lower(self, belowThis=None):
|
||||||
self.tk.call('lower', self._w, belowThis)
|
self.tk.call('lower', self._w, belowThis)
|
||||||
def option_add(self, pattern, value, priority = None):
|
def option_add(self, pattern, value, priority = None):
|
||||||
self.tk.call('option', 'add', pattern, priority)
|
self.tk.call('option', 'add', pattern, value, priority)
|
||||||
def option_clear(self):
|
def option_clear(self):
|
||||||
self.tk.call('option', 'clear')
|
self.tk.call('option', 'clear')
|
||||||
def option_get(self, name, className):
|
def option_get(self, name, className):
|
||||||
|
@ -1190,6 +1195,21 @@ class Text(Widget):
|
||||||
self.tk.call(self._w, 'scan', 'mark', y)
|
self.tk.call(self._w, 'scan', 'mark', y)
|
||||||
def scan_dragto(self, y):
|
def scan_dragto(self, y):
|
||||||
self.tk.call(self._w, 'scan', 'dragto', y)
|
self.tk.call(self._w, 'scan', 'dragto', y)
|
||||||
|
def search(self, pattern, index, stopindex=None,
|
||||||
|
forwards=None, backwards=None, exact=None,
|
||||||
|
regexp=None, nocase=None, count=None):
|
||||||
|
args = [self._w, 'search']
|
||||||
|
if forwards: args.append('-forwards')
|
||||||
|
if backwards: args.append('-backwards')
|
||||||
|
if exact: args.append('-exact')
|
||||||
|
if regexp: args.append('-regexp')
|
||||||
|
if nocase: args.append('-nocase')
|
||||||
|
if count: args.append('-count'); args.append(count)
|
||||||
|
if pattern[0] == '-': args.append('--')
|
||||||
|
args.append(pattern)
|
||||||
|
args.append(index)
|
||||||
|
if stopindex: args.append(stopindex)
|
||||||
|
return apply(self.tk.call, tuple(args))
|
||||||
def tag_add(self, tagName, index1, index2=None):
|
def tag_add(self, tagName, index1, index2=None):
|
||||||
self.tk.call(
|
self.tk.call(
|
||||||
self._w, 'tag', 'add', tagName, index1, index2)
|
self._w, 'tag', 'add', tagName, index1, index2)
|
||||||
|
@ -1287,6 +1307,21 @@ class Image:
|
||||||
class PhotoImage(Image):
|
class PhotoImage(Image):
|
||||||
def __init__(self, name=None, cnf={}, **kw):
|
def __init__(self, name=None, cnf={}, **kw):
|
||||||
apply(Image.__init__, (self, 'photo', name, cnf), kw)
|
apply(Image.__init__, (self, 'photo', name, cnf), kw)
|
||||||
|
def blank(self):
|
||||||
|
self.tk.call(self.name, 'blank')
|
||||||
|
def cget(self):
|
||||||
|
return self.tk.call(self.name, 'cget')
|
||||||
|
# XXX config
|
||||||
|
# XXX copy
|
||||||
|
def get(self, x, y):
|
||||||
|
return self.tk.call(self.name, 'get', x, y)
|
||||||
|
def put(self, data, to=None):
|
||||||
|
args = (self.name, 'put', data)
|
||||||
|
if to:
|
||||||
|
args = args + to
|
||||||
|
apply(self.tk.call, args)
|
||||||
|
# XXX read
|
||||||
|
# XXX write
|
||||||
|
|
||||||
class BitmapImage(Image):
|
class BitmapImage(Image):
|
||||||
def __init__(self, name=None, cnf={}, **kw):
|
def __init__(self, name=None, cnf={}, **kw):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue