Inserting a button into a tkinter listbox on python?

≯℡__Kan透↙ 提交于 2019-12-24 02:57:10

问题


...
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?


回答1:


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.



来源:https://stackoverflow.com/questions/5612237/inserting-a-button-into-a-tkinter-listbox-on-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!