GTK3 No resize limits

时间:2018-09-18 20:01:28

标签: c++ c linux gtk

Currently if I make a window in GTK3

For example 300x300

And I put a button at the bottom, right hand corner, I can not shrink my window

Size because this button is preventing me is there a function in gtk3 that can allow me to ignore all widgets, and resize to anything even 0x0

And this is the user doing this with the window resize, drag and click

And is there a way where I can set this resize limit myself, and not have this dependent on whats in my window

1 个答案:

答案 0 :(得分:0)

If you initially use set_size_request() to set the window to 300x300, then it won't shrink below that. To allow users to shrink below an initial value, use set_default_size(). I seem to have read that the minimum size of a widget is 1x1, which seems logical, as, at 0x0 you wouldn't be able to resize it anymore. If you want less than 1x1, you can use hide() and just hide the contents.

But if you have any widgets inside the window, then the minimum size is determined by the widgets! (Called the 'natural size')

To allow a window smaller that than the one determined by the widgets, you can maybe use a Gtk.ScrolledWindow.

Also, recall that the outer border is drawn by the window manager, NOT by Gtk. However, you can disable the outer border by using set_decorated(). Not that this may not work - depending if the window manager respects this (not Gtk's fault).