pygtk:resizing
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
Entrambe le parti precedenti la revisioneRevisione precedenteProssima revisione | Revisione precedente | ||
pygtk:resizing [2009/01/14 01:04] – scrolledwindow pietro | pygtk:resizing [2009/01/14 09:20] (versione attuale) – set_size_request pietro | ||
---|---|---|---|
Linea 1: | Linea 1: | ||
====== resize tweaks ====== | ====== resize tweaks ====== | ||
- | First: the method gtk.Window.resize() doesnt' | + | First: the method gtk.Window.resize() doesnt' |
Now: if a gtk.Window **w** has size (100,100) and we run the following code: | Now: if a gtk.Window **w** has size (100,100) and we run the following code: | ||
Linea 32: | Linea 32: | ||
window.set_data(' | window.set_data(' | ||
| | ||
- | def set_width(window, width): | + | def get_width(window): |
- | | + | |
+ | if not width: | ||
+ | width = window.get_size()[0] | ||
+ | return width | ||
| | ||
- | window.set_data('real width', | + | def get_height(window): |
height = window.get_data(' | height = window.get_data(' | ||
if not height: | if not height: | ||
height = window.get_size()[1] | height = window.get_size()[1] | ||
- | | + | return height |
+ | |||
+ | def set_width(window, | ||
+ | ensure_configure_handler(window) | ||
+ | |||
+ | window.set_data(' | ||
+ | height = get_height(window) | ||
window.resize(width, | window.resize(width, | ||
| | ||
Linea 46: | Linea 55: | ||
| | ||
window.set_data(' | window.set_data(' | ||
- | width = window.get_data('real width' | + | width = get_width(window) |
- | if not width: | + | |
- | width = window.get_size()[0] | + | |
- | + | ||
window.resize(width, | window.resize(width, | ||
+ | |||
+ | ==== set_size_request ==== | ||
+ | Notice that set_size_request has a similar problem: if a gtk.Widget **widget**' | ||
+ | widget.set_size_request(100, | ||
+ | widget.set_size_request(-1, | ||
+ | |||
+ | , it won't expand at all, nothing will happen. This is an issue if you wanted to use this as a hack to resize the widget but let to the user the possibility to shrink it again; an hackish way to solve this is instead the following code: | ||
+ | widget.set_size_request(100, | ||
+ | gobject.idle_add(widget.set_size_request, | ||
====== gtk.ScrolledWindow ====== | ====== gtk.ScrolledWindow ====== |
pygtk/resizing.1231891443.txt.gz · Ultima modifica: 2009/01/14 01:04 da pietro