Skip to content

Commit

Permalink
Fixed error in SmartOptionMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
slightlynybbled committed Jun 11, 2018
1 parent 192789d commit c54c5ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions examples/smart_optionmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ def callback(value):


if __name__ == '__main__':

root = tk.Tk()

tk.Label(root, text="The variable value: ").grid(row=0, column=0)
tk.Label(root, text="The variable value: ").grid(row=1, column=0, sticky='ew')
value_label = tk.Label(root, text="")
value_label.grid(row=0, column=1)
value_label.grid(row=1, column=1, sticky='ew')

def callback(value):
value_label.config(text=str(value))

tk.Label(root, text="Select a value: ").grid(row=0, column=0, sticky='ew')
drop_down = tk_tools.SmartOptionMenu(root, ['one', 'two', 'three'], callback=callback)
drop_down.grid()
drop_down.grid(row=0, column=1, sticky='ew')

print(root.winfo_children())
print(drop_down.winfo_manager(), drop_down.winfo_parent())
print(drop_down.winfo_children())

root.mainloop()
2 changes: 1 addition & 1 deletion tk_tools/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.9.9'
__version__ = '0.10.0'
4 changes: 2 additions & 2 deletions tk_tools/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def __init__(self, parent, options: list, initial_value: str=None,
self._var = tk.StringVar()
self._var.set(initial_value if initial_value else options[0])

self.option_menu = tk.OptionMenu(self._parent, self._var,
self.option_menu = tk.OptionMenu(self, self._var,
*options)
self.option_menu.grid()
self.option_menu.grid(row=0, column=0)

if callback is not None:
def internal_callback(*args):
Expand Down

0 comments on commit c54c5ce

Please sign in to comment.