Python Tkinter components

smo1234
07:27:19
Dropdown list box is a common requirement , so it is available in all languages. You can learn about basic HTML drop down list box here.

There are common requirements like , click event , reading the value and index , multiple selection etc of a list box.

Multiple selection works when we press Ctrl Key and select more then one option.
smo1234
07-27-2019
In place of using a button to read and display the selected value. We can directly use the click event of the list box .

https://stackoverflow.com/questions/6554805/getting-a-callback-when-a-tkinter-listbox-selection-is-changed

In html we call it OnSelect event
smo1234
07-27-2019
Surprisingly I am unable to set my one value ( key ) for the listbox . Tkinter adds its own index starting from 0 and increases.

https://stackoverflow.com/questions/47580444/python-tkinter-listbox-getting-index
smo1234
07-28-2019
import tkinter as tk
from tkinter import messagebox as msg
my_w = tk.Tk()
my_w.geometry("500x500") # Size of the window

msg.showerror("Title Here ","Your Message here ")

my_w.mainloop()
smo1234
07-28-2019
the 2nd line "from tkinter import messagebox as msg" is not working!
smo1234
07-28-2019
It works even without that!
smo1234
07-28-2019
import tkinter as tk
#from tkinter import messagebox as msg
my_w = tk.Tk()
my_w.geometry("500x500") # Size of the window

m1=msg.showerror("Title Here ","Your Message here ")

my_w.mainloop()
smo1234
07-28-2019
import tkinter as tk
my_w = tk.Tk()
my_w.geometry("500x500") # Size of the window

msg.showerror("Title Here ","Your Message here ")

my_w.mainloop()
smo1234
07-28-2019
https://stackoverflow.com/questions/34063335/nameerror-global-name-messagebox-is-not-defined-console-mode
smo1234
08-02-2019
To retain the highlight even after it lost focus we can use exportselection=0 .

https://stackoverflow.com/questions/10048609/how-to-keep-selections-highlighted-in-a-tkinter-listbox
smo1234
08-02-2019
Documentation
http://tcl.tk/man/tcl8.5/TkCmd/listbox.htm
Please Login to post your reply or start a new topic