utils.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:porcupine 作者: Akuli 项目源码 文件源码
def copy_bindings(widget1, widget2):
    """Add all bindings of *widget1* to *widget2*.

    You may need to call ``copy_bindings(porcupine.get_main_window(), widget)``
    on widgets that can be focused by clicking them, like ``Text`` and
    ``Entry`` widgets. Porcupine's keyboard bindings return ``'break'``
    and are bound to the main window, and thus work by default, but in
    some cases returning ``'break'`` doesn't do anything when the focus
    is in another widget inside the main window.
    """
    # tkinter's bind() can do quite a few different things depending
    # on how it's invoked
    for sequence in widget1.bind():
        tcl_command = widget1.bind(sequence)

        # add=True doesn't work if the command is a string :(
        widget2.tk.call('bind', widget2, sequence, '+' + tcl_command)


# see docs/utils.rst for explanation and docs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号