本文整理汇总了Python中idlelib.WidgetRedirector.WidgetRedirector类的典型用法代码示例。如果您正苦于以下问题:Python WidgetRedirector类的具体用法?Python WidgetRedirector怎么用?Python WidgetRedirector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WidgetRedirector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReadOnlyText
class ReadOnlyText(Text):
def __init__(self, *args, **kwargs):
Text.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = \
self.redirector.register("insert", lambda *args, **kw: "break")
self.delete = \
self.redirector.register("delete", lambda *args, **kw: "break")
示例2: ReadOnlyEntry
class ReadOnlyEntry(Entry):
def __init__(self, *args, **kwargs):
Entry.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = self.redirector.register(
"insert", lambda *args, **kw: "break")
self.delete = self.redirector.register(
"delete", lambda *args, **kw: "break")
示例3: ReadOnlyText
class ReadOnlyText(tkinter.Text):
def __init__(self, *args, **kwargs):
from idlelib.WidgetRedirector import WidgetRedirector
tkinter.Text.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = \
self.redirector.register("insert", lambda *args, **kw: "break")
self.delete = \
self.redirector.register("delete", lambda *args, **kw: "break")
示例4: ReadOnlyText
class ReadOnlyText(Tkinter.Text):
"""Sets up a read-only chat box that can be added to with the
Text.insert method, but cannot be modified by the user because
all the input is rerouted"""
def __init__(self, *args, **kwargs):
Tkinter.Text.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = self.redirector.register(
"insert", lambda *args, **kw: "break")
self.delete = self.redirector.register(
"delete", lambda *args, **kw: "break")
示例5: ReadOnlyText
class ReadOnlyText(tk.Text):
def __init__(self, *args, **kwargs):
kwargs['relief'] = tk.FLAT
kwargs['insertwidth'] = 0
kwargs['highlightthickness'] = 0
tk.Text.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = \
self.redirector.register("insert", lambda *args, **kw: "break")
self.delete = \
self.redirector.register("delete", lambda *args, **kw: "break")
示例6: __init__
class Percolator:
def __init__(self, text):
self.text = text
self.redir = WidgetRedirector(text)
self.top = self.bottom = Delegator(text)
self.bottom.insert = self.redir.register('insert', self.insert)
self.bottom.delete = self.redir.register('delete', self.delete)
self.filters = []
def close(self):
while self.top is not self.bottom:
self.removefilter(self.top)
self.top = None
self.bottom.setdelegate(None)
self.bottom = None
self.redir.close()
self.redir = None
self.text = None
return
def insert(self, index, chars, tags = None):
self.top.insert(index, chars, tags)
def delete(self, index1, index2 = None):
self.top.delete(index1, index2)
def insertfilter(self, filter):
raise isinstance(filter, Delegator) or AssertionError
raise filter.delegate is None or AssertionError
filter.setdelegate(self.top)
self.top = filter
return
def removefilter(self, filter):
if not isinstance(filter, Delegator):
raise AssertionError
raise filter.delegate is not None or AssertionError
f = self.top
self.top = f is filter and filter.delegate
filter.setdelegate(None)
else:
while not (f.delegate is not filter and f is not self.bottom):
raise AssertionError
f.resetcache()
f = f.delegate
f.setdelegate(filter.delegate)
filter.setdelegate(None)
return
示例7: __init__
class Percolator:
def __init__(self, text):
# XXX would be nice to inherit from Delegator
self.text = text
self.redir = WidgetRedirector(text)
self.top = self.bottom = Delegator(text)
self.bottom.insert = self.redir.register("insert", self.insert)
self.bottom.delete = self.redir.register("delete", self.delete)
self.filters = []
def close(self):
while self.top is not self.bottom:
self.removefilter(self.top)
self.top = None
self.bottom.setdelegate(None)
self.bottom = None
self.redir.close()
self.redir = None
self.text = None
def insert(self, index, chars, tags=None):
# Could go away if inheriting from Delegator
self.top.insert(index, chars, tags)
def delete(self, index1, index2=None):
# Could go away if inheriting from Delegator
self.top.delete(index1, index2)
def insertfilter(self, filter):
# Perhaps rename to pushfilter()?
assert isinstance(filter, Delegator)
assert filter.delegate is None
filter.setdelegate(self.top)
self.top = filter
def removefilter(self, filter):
# XXX Perhaps should only support popfilter()?
assert isinstance(filter, Delegator)
assert filter.delegate is not None
f = self.top
if f is filter:
self.top = filter.delegate
filter.setdelegate(None)
else:
while f.delegate is not filter:
assert f is not self.bottom
f.resetcache()
f = f.delegate
f.setdelegate(filter.delegate)
filter.setdelegate(None)
示例8: ReadOnlyText
class ReadOnlyText(ScrolledText):
def __init__(self, *args, **kwargs):
ScrolledText.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = self.redirector.register("insert", lambda *args, **kw: "break")
self.delete = self.redirector.register("delete", lambda *args, **kw: "break")
self.config(wrap=tk.WORD)
示例9: ReadOnlyText
class ReadOnlyText(Text):
def __init__(self, master=None, cnf={}, **kw):
super().__init__(master, cnf, **kw)
self.redirector = WidgetRedirector(self)
self.insert = self.redirector.register("insert", lambda *args, **kw: "break")
self.delete = self.redirector.register("delete", lambda *args, **kw: "break")
示例10: __init__
def __init__(self, *args, **kwargs):
Tkinter.Text.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = self.redirector.register(
"insert", lambda *args, **kw: "break")
self.delete = self.redirector.register(
"delete", lambda *args, **kw: "break")
示例11: __init__
def __init__(self, *args, **kwargs):
kwargs["relief"] = tk.FLAT
kwargs["insertwidth"] = 0
kwargs["highlightthickness"] = 0
tk.Text.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = self.redirector.register("insert", lambda *args, **kw: "break")
self.delete = self.redirector.register("delete", lambda *args, **kw: "break")
示例12: __init__
def __init__(self, text):
# XXX would be nice to inherit from Delegator
self.text = text
self.redir = WidgetRedirector(text)
self.top = self.bottom = Delegator(text)
self.bottom.insert = self.redir.register("insert", self.insert)
self.bottom.delete = self.redir.register("delete", self.delete)
self.filters = []
示例13: __init__
def __init__(self, *args, **kwargs):
tk.Text.__init__(self, *args, **kwargs)
self.tag_config("ok", foreground="forest green")
self.tag_config("error", foreground="red")
self.redir = WidgetRedirector(self)
self.insert = self.redir.register("insert", lambda *args, **kw: "break")
self.delete = self.redir.register("delete", lambda *args, **kw: "break")
self.queue = queue.Queue()
self.update()
示例14: ReadOnlyText
class ReadOnlyText(Text):
"""
Prevent keys from being shown in the text area.
We want to control what is actualxpyl presented to the user.
"""
def __init__(self, *args, **kwargs):
"""
Trashes every attempt to modify the text area coming from
user input.
"""
Text.__init__(self, *args, **kwargs)
self.redirector = WidgetRedirector(self)
self.insert = \
self.redirector.register("insert",
lambda *args, **kw: "break")
self.delete = \
self.redirector.register("delete",
lambda *args, **kw: "break")
示例15: __init__
def __init__(self, *args, **kwargs):
ScrolledText.__init__(self, *args, **kwargs)
_rc_menu_install(self)
# overwrite default class binding so we don't need to return "break"
self.bind_class("Text", "<Control-a>", self.event_select_all)
self.bind("<Button-3><ButtonRelease-3>", self.show_menu)
# Make the widget ready only
self.redirector = WidgetRedirector(self)
self.insert = self.redirector.register("insert", lambda *args, **kw: "break")
self.delete = self.redirector.register("delete", lambda *args, **kw: "break")