开发者

gtk: expand widget as if it had some text in it

I have a GTK widget, in this case, a TreeView. It starts off pretty small and compressed, as there's no te开发者_开发百科xt in it besides the columns names. As I add things, it grows horizontally to cover the text and vertically to cover the extra rows. If I then take those away, it retains its expanded size.

It's kind of annoying for your window to always be resizing as you add things. My question is - how can I "pre-"size the widget? Like one way would be to fill it with junk text that I think is the biggest size it can get, and then remove the text, but that won't look very pretty. Is there a better way?


  1. Simplest answer: treeview.set_size_request(width, height) (but then your tree view won't grow when it needs to afterwards.)
  2. Is your tree view in a box? Have you tried packing it with expand=True and fill=True?
  3. window.set_default_size(width, height) on your whole gtk.Window is the best solution, because that "pre-"sizes the window as you say. It can still grow, or be resized smaller by the user.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜