Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve htest.
  • Loading branch information
terryjreedy committed Feb 28, 2023
commit 1f8c34671ade1b7c7d599fc524e427c4badd4272
11 changes: 7 additions & 4 deletions Lib/idlelib/dynoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from tkinter import OptionMenu, _setit, StringVar, Button

class DynOptionMenu(OptionMenu):
"""
unlike OptionMenu, our kwargs can include highlightthickness
"""Add SetMenu and highlightthickness to OptionMenu.

Highlightthickness adds space around menu button.
"""
def __init__(self, master, variable, value, *values, **kwargs):
highlightthickness = kwargs.pop('highlightthickness', None)
Expand All @@ -32,14 +33,15 @@ def _dyn_option_menu(parent): # htest #
from tkinter import Toplevel # + StringVar, Button

top = Toplevel(parent)
top.title("Tets dynamic option menu")
top.title("Test dynamic option menu")
x, y = map(int, parent.geometry().split('+')[1:])
top.geometry("200x100+%d+%d" % (x + 250, y + 175))
top.focus_set()

var = StringVar(top)
var.set("Old option set") #Set the default value
dyn = DynOptionMenu(top,var, "old1","old2","old3","old4")
dyn = DynOptionMenu(top, var, "old1","old2","old3","old4",
highlightthickness=5)
dyn.pack()

def update():
Expand All @@ -48,5 +50,6 @@ def update():
button.pack()

if __name__ == '__main__':
# Only module without unittests because of intention to replace.
from idlelib.idle_test.htest import run
run(_dyn_option_menu)