Skip to content

Commit d63ad46

Browse files
committed
Preserve created Tcl commands for bindings
1 parent a69f41f commit d63ad46

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

ttkwidgets/utilities.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# Copyright (c) RedFantom 2017
1+
"""
2+
Author: The ttkwidgets authors
3+
License: GNU GPLv3, as in LICENSE.md
4+
Copyright (c) 2016-2019 The ttkwidgets authors
5+
6+
For author details, see AUTHORS.md
7+
"""
28
import os
39
from PIL import Image, ImageTk
410
import re
@@ -42,16 +48,9 @@ def copy_widget(widget, new_parent, level=0):
4248
"""
4349
rv = widget.__class__(master=new_parent, **get_widget_options(widget))
4450
for b in widget.bind():
51+
widget._tclCommands = None # Preserve bound functions
4552
script = widget.bind(b)
46-
rv.bind(b, script) # Not sure it will work tho
47-
# TODO: bind the script to the new widget (rv)
48-
# set type [ getWidgetType $w ]
49-
# set name [ string trimright $newparent.[lindex [split $w "." ] end ] "." ]
50-
# set retval [ $type $name {*}[ getConfigOptions $w ] ]
51-
# foreach b [ bind $w ] {
52-
# puts "bind $retval $b [subst { [bind $w $b ] } ] "
53-
# bind $retval $b [subst { [bind $w $b ] } ]
54-
# }
53+
rv.bind(b, script)
5554

5655
if level > 0:
5756
if widget.grid_info(): # if geometry manager is grid

0 commit comments

Comments
 (0)