appJar - ListBox/OptionBox widget call a function on select

Kube Kubow

I recently started playing with appJar python module and I got stuck using its widgets, namely ListBox http://appjar.info/pythonWidgets/#listbox and OptionBox http://appjar.info/pythonWidgets/#optionbox.

I am not able to find out, how to call function when item in ListBox or OptionBox is selected. I found this syntax, but I cannot find where to define the function I want to call:

.selectListItem(title, item, callFunction=True)
.changeOptionBox(title, newOptions, index, callFunction=False)

This is the code, which I have so far. As you can see, I am able to print out selected values, but by calling method on button click.

from appJar import gui

def press(btn):
    if btn == "Cancel":
        app.stop()
    elif btn == "Show":
        list_select()
    else:
        print('not defined yet')

def list_select():
    app.infoBox("Info", "You selected " + app.getOptionBox("optionbox") + "\nBrowsing " + app.getListBox("list")[0])

app = gui("Database Editor", "500x500")
app.addOptionBox("optionbox", ["a", "b", "c", "d"])
app.addListBox("list", ["one", "two", "three", "four"])

app.addButtons(["Show", "Cancel"], press)
app.go()

Is any of you aware, how can I print out these values directly on the select?

Kube Kubow

I've figured it out! Indeed the ChangeFunction can be triggered through the Event function http://appjar.info/pythonEvents/#types-of-event (as I posted in comments) .

I used these two events to do this thing:

app.setOptionBoxChangeFunction("optionbox", opt_changed)
app.setListBoxChangeFunction("list", lst_changed)

The whole working code here:

from appJar import gui

def opt_changed(opt):
    print(app.getOptionBox("optionbox"))

def lst_changed(lst):
    print(app.getListBox("list")[0])

def press(btn):
    if btn == "Cancel":
        app.stop()
    elif btn == "Show":
        list_select()
    else:
        print('not defined yet')

def list_select():
    app.infoBox("Info", "You selected " + app.getOptionBox("optionbox") + "\nBrowsing " + app.getListBox("list")[0])

app = gui("Database Editor", "500x500")
app.addOptionBox("optionbox", ["a", "b", "c", "d"])
app.addListBox("list", ["one", "two", "three", "four"])

app.setOptionBoxChangeFunction("optionbox", opt_changed)
app.setListBoxChangeFunction("list", lst_changed)

app.addButtons(["Show", "Cancel"], press)
app.go()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Call a function inside Flutter Widget

Using `SELECT` to call a function

Python / tkinter: Events: call a function by mouse on widget

Call widget's own function outside it

Flutter: Call a function on a child widget's state

Call a function using bind in tk text widget

How to call function when widget created

Call c++ function in Widget blueprint

how to call child widget function from parent widget

How to call parent widget function from child widget in Flutter

call the function named as select value

Python3 - AppJar (tkinter wrapper) change function of a button

How to call a function from stateless Widget that points to state class function?

passing a function to a widget and call function when button press in flutter

Can we call the button using select(A single selection widget) in bokeh?

How to call function on Change of select option with select option as a parameters of that function

How to call function in Widget from class of another file in Dart / Flutter?

How to call a function in mainwindow from secondwindow(widget) with a button

How to capture the result returned by a callback function call on a Bokeh TextInput widget?

How to call function from another class in the widget array?

How to call a function and pass variable in tkinter scale widget?

Call function from Stateful Widget from another StatefulWidget

Call a function every time a semicolon is typed in Tkinter Entry Widget

QT/C++ Call function of a widget using a slot

How to call function in a widget from a Floating Action Button Flutter?

how can I call function with callback value from custom widget

Call a function for each row in select - Postgres

Call a javascript function from select element in HTML

Dynamically select a function to call without intermediate variables