Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting a button into a tkinter listbox on python?

...
self.myListbox=tkinter.Listbox() 
self.myListbox.pack()
self.myButton=tkinter.Button(self.myListbox,text="Press")

self.myListbox.insert(1,myButton.pack())
...

I want to insert a button into listbox like inserting a sting. How can I do this?

like image 776
junkmail Avatar asked Nov 14 '25 15:11

junkmail


1 Answers

You can't. From the listbox documentation: "A listbox is a widget that displays a list of strings".

You can, of course, use pack, place or grid to put a button inside the widget but it won't be part of the listbox data -- it won't scroll for example, and might obscure some of the data.

like image 132
Bryan Oakley Avatar answered Nov 17 '25 09:11

Bryan Oakley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!