简体   繁体   中英

pyGTK : pack and unpack

Can I use pack once the main loop has been showed, or should I use something else to add /remove widgets to /from a vbox afterwards ?

I have this gtk.Window() that contains a vbox , where a menu , a treeview and a button are pack ed. At the push of this button, I want to display an image in a new container inside this window / vbox, and ideally, close said container at will.

(think image viewer with a file list, you click on an image file and a pane opens displaying it, if you click on another image file the new image is displayed in place of the old, and you can close the image pane)

My question is : How do you do that ? My trials so far led me to believe that once the vbox has been show() 'd, you cant pack anything else into it..? Has the "image" container have to exist prior to being displayed...?

What is the proper process to do this, in witch direction of the GTK manual should I look?

In GTK+ all widgets are hidden by default (which I think was a stupid design decision, but oh well). You usually call show_all() on a window, so indirectly show all widgets contained in it by the time of the call . If you add (pack, whatever) a widget later, don't forget to show() it manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM