Python Forum
Update value selected in option menu when select an item from text box
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Update value selected in option menu when select an item from text box
#1
In my GUI using tkinter, I'm trying to update the value display for option menu based on selected row function.

def get_selected_row(event):
    try:
        global selected_tuple
        index=list1.curselection()[0]
        selected_tuple=list1.get(index)
        e1.delete(0,END)
        e1.insert(END,selected_tuple[1])
        e2.delete(0,END)
        e2.insert(END,selected_tuple[2])
        e3.delete(0,END)
        e3.insert(END,selected_tuple[3])
        e4.delete(0,END)
        e4.insert(END,selected_tuple[4])
        #avial_typeSelect_text.setvar(textvar,selected_tuple[5])
        #avial_typeSelect_text.update()
        avial_typeSelect_text['menu'].delete(0,END)
        #avial_typeSelect_text['menu'].add_command( command=tk._setit(avial_text, selected_tuple[5]))
        avial_typeSelect_text['menu'].update(END,selected_tuple[5])
        print(selected_tuple[5])
    except IndexError:
        pass
However this was not successful.In the attached picture shows that value of the filed "Availability" is "No" in the database. But value shows in the option menu is not updated according to selected row.

Appreciate if someone can give a though on how to do this.

Both backed & front end files attached. Sample database can't be attached. So pls. input some sample data and add data to create a sqlite database.

Attached Files

Thumbnail(s)
   

.py   Creating_frontend_udemy.py (Size: 3.69 KB / Downloads: 381)
.py   backend_udemy.py (Size: 1.78 KB / Downloads: 333)
Reply
#2
try updating e1 widget directly (which I can't see)
Reply
#3
(Jun-06-2019, 04:00 AM)Larz60+ Wrote: try updating e1 widget directly (which I can't see)
Thanks for the reply.

e1, e2,e3,e4 get the values of selected items correctly.

However i'm unable to get the selected items value into option menu (ie avial_typeSelect_text)

[Image: AF1QipNcU_MWbgzegUmum5Wu_Q_-5s4AysmOx9j4HWbO]

Please note i have attached full python code files (front end & back end) but what is noted in my question is only a function used to update the values based on selected item.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  QListWidget, no item was selected flash77 4 923 Aug-02-2023, 09:31 AM
Last Post: Axel_Erfurt
  [PyQt] How to always select the item in the first column when a row is selected DrakeSoft 1 1,570 Feb-17-2023, 07:43 PM
Last Post: DrakeSoft
  [Tkinter] Make my button text update? Skata100 1 2,012 Aug-07-2021, 05:37 AM
Last Post: deanhystad
  [PyQt] How to update selected data in combobox displaying DB data? JokerSob 3 3,377 Aug-02-2021, 04:39 AM
Last Post: JokerSob
  update text variable on label with keypress knoxvilles_joker 3 4,835 Apr-17-2021, 11:21 PM
Last Post: knoxvilles_joker
  [Tkinter] tkinter.Menu – How to make text-variable? Sir 3 5,538 Mar-10-2021, 04:21 PM
Last Post: Sir
  Get selected text inside an Entry Jerdup 0 2,443 Aug-20-2020, 12:42 PM
Last Post: Jerdup
  [Tkinter] how to update label text from list Roshan 8 5,370 Apr-25-2020, 08:04 AM
Last Post: Roshan
  [PyQt] saving text file by FileDialog option atlass218 14 4,493 Feb-19-2020, 09:22 AM
Last Post: atlass218
  How to get the selected item from Listbox and convert it to int? Jionni 8 5,022 Feb-17-2020, 11:07 AM
Last Post: Jionni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020