Issue #21477: Idle htest: merge and modify run and runall; add many tests.

Patch by Saimadhav Heblikar
This commit is contained in:
Terry Jan Reedy 2014-05-24 18:48:18 -04:00
parent 10cbb1e463
commit 1b392ffe67
18 changed files with 412 additions and 179 deletions

View file

@ -2,9 +2,10 @@
OptionMenu widget modified to allow dynamic menu reconfiguration
and setting of highlightthickness
"""
from tkinter import OptionMenu
from tkinter import _setit
from tkinter import OptionMenu, _setit, Tk, StringVar, Button
import copy
import re
class DynOptionMenu(OptionMenu):
"""
@ -33,3 +34,24 @@ class DynOptionMenu(OptionMenu):
command=_setit(self.variable,item,self.command))
if value:
self.variable.set(value)
def _dyn_option_menu(parent):
root = Tk()
root.title("Tets dynamic option menu")
var = StringVar(root)
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
root.geometry("+%d+%d"%(x, y + 150))
var.set("Old option set") #Set the default value
dyn = DynOptionMenu(root,var, "old1","old2","old3","old4")
dyn.pack()
def update():
dyn.SetMenu(["new1","new2","new3","new4"],value="new option set")
button = Button(root, text="Change option set", command=update)
button.pack()
root.mainloop()
if __name__ == '__main__':
from idlelib.idle_test.htest import run
run(_dyn_option_menu)