optionmenu

tkinter optionmenu first option vanishes

谁说胖子不能爱 提交于 2021-02-10 14:14:31
问题 A ttk optionmenu widget starts out with all of its values in the dropdown. Upon selecting any value, the first value in the list vanishes, never to reappear... Does anyone know why? Is this a feature of the widget's design? Try it with the following: import tkinter.ttk as ttk import tkinter as tk a = tk.Tk() options = ['1', '2', '3'] value = tk.StringVar() masterframe = ttk.Frame() masterframe.pack() dropdown = ttk.OptionMenu(masterframe, value, *options) dropdown.pack() a.mainloop() Note -

Tkinter Create OptionMenus With Loop

倾然丶 夕夏残阳落幕 提交于 2021-02-05 09:29:16
问题 I have created a code to create tkinter OptionMenus with values in a dictionary using a for loop. The code seems to work successfully, with OptionMenus appearing with keywords on a window as desired... import tkinter as tk from tkinter import * class Example: def __init__(self): #Dictionary with categories and their relative keywords self.categorykeywords={"Category 1":["Keyword 1", "Keyword 2", "Keyword 3"], "Category 2":["Keyword A","Keyword B","Keyword C"], "Category 3":["Another Keyword"]

Update on the fly a ttk.OptionMenu without affecting its previous callback/command

若如初见. 提交于 2021-01-29 07:26:28
问题 I am doing a large GUI with different ttk.OptionMenu widgets that need to be updated often depending on the interaction with the user. Each time the user selects another value from the menu, there is a function callback by the widget via the command input. The command works fine until I need to update the possible values within the OptionMenu widget. After updating using add_command , my previous callback does not work anymore. Is there any way of updating the possible inputs of a ttk

Tkinter OptionMenu cant use .get in a function

烂漫一生 提交于 2020-06-09 06:58:28
问题 I'm writing some code and i need a variable to change when the optionMenu is changed here is some of my code below #!/user # -*- coding: utf-8 -*- import locale import Tkinter as Tk root = Tk.Tk() root.title("My Tax Calculator") root.geometry("700x225") def getStudentLoan(): global StudentLoan StudentLoan = StudentLoanLi.get() LeftFrame = Tk.Frame(root, width=300, height=200, pady=3) Placeholder2 = Tk.Label(LeftFrame, text="") Placeholder2.grid(row=2, column=1) StudentLoanOp = Tk.StringVar()

Android listview item edit operation

我的未来我决定 提交于 2020-01-17 09:12:55
问题 I am new at developing Android App.I have a MainActivity that has a ListView.The data on Listview is hold in a Arraylist.(I dont have any DB).Listview items has 4 field such as coursecode,coursetitle,courselevel,coursedescription.When I clicked an item on Listview,a new activity(ShowDetailActivity) will be launced in order to view detail of course.The editable of the EditViews on ShowDetailActivity are false.On ShowDetailActivity I have an option menu item (Edit).When I clicked the Edit

Android listview item edit operation

℡╲_俬逩灬. 提交于 2020-01-17 09:12:18
问题 I am new at developing Android App.I have a MainActivity that has a ListView.The data on Listview is hold in a Arraylist.(I dont have any DB).Listview items has 4 field such as coursecode,coursetitle,courselevel,coursedescription.When I clicked an item on Listview,a new activity(ShowDetailActivity) will be launced in order to view detail of course.The editable of the EditViews on ShowDetailActivity are false.On ShowDetailActivity I have an option menu item (Edit).When I clicked the Edit

Assigning values to optionmenu in tkinter

柔情痞子 提交于 2020-01-14 05:57:26
问题 I have a list of months which I want to show in an option menu. When I select a month, I want get the number of month it is. Like if Apr is selected, I want an answer that This is the fourth month I have written code as follows: months = {'Jan' : '1', 'Feb' : '2', 'March' : '3' , 'Apr' : '4'} var = StringVar(root) var.set('Jan') OptionMenu1 = OptionMenu(root, var, *months) OptionMenu1.pack(); I want to know, how to trigger a function on selecting a particular entry 回答1: You can use the .trace

Getting the choice of optionmenu right after selection Python

只谈情不闲聊 提交于 2020-01-10 17:07:38
问题 I was wondering if there is any way for me to see what the User has selected among the list displaying, let's say: ["Apple","Orange","Grapes"] right after they select either one of them? Like when user clicks the optionbox, and clicks Apple, Tkinter will return something then if he switches his selection to, let's say, Orange, then that will also return something on the spot. Thanks! How to put parameter correctly? from Tkinter import * def option_changed(a): print "the user chose the value {