jarvisteach / appJar

Simple Tkinter GUIs in Python
http://appJar.info
Other
615 stars 68 forks source link

Setting the value of Option box again #555

Closed Lithimlin closed 5 years ago

Lithimlin commented 5 years ago

Feature Request


Context


I have a GUI containing an Option box where options can be added or removed while running.

Expected Behaviour


When setting, if the value contains a string, it represents the item to select. If the value is a list, it should change the values.

Actual Behaviour


When setting, the value should contain the item to select.

Sample code, demonstrating the issue


with gui("MyGUI", bg="lightblue") as app:
    app.option("corpora", value=parser.list_corpora(), label="Corpora",
               change=update_corpora, colspan=2)
    app.entry("corpus_name", label="Corpus Name:", colspan=2)
    app.button("add_corpus", update_corpora, label="Add Corpus")
    app.button("remove_corpus", update_corpora, label="Remove Corpus", row=1,
                column=1)

def update_corpora(value):
    if value is "add_corpus":
        name = app.entry("corpus_name")
        parser.save_corpus(name, app.text("corpus"))
        app.option("corpora", value=parser.list_corpora()) #Here, I'd like to update the values
        app.option("corpora", selected=name) #Here, I'd like to select the new entry

    elif value is "remove_corpus":
        parser.remove_corpus(app.option("corpora"))
        app.option("corpora", value=parser.list_corpora(), selected=0) #Here, I'd like to update the values
jarvisteach commented 5 years ago

Hi @Lithimlin - this has been added to the next release.

Now when you're working with options, you can specify a mode