0

Is there a way I can stop the user from dragging around the separator in a gtk.Paned? I don't want to disable it completely... if any child resized or set_position() was called, the separator should still change position.

Thanks!

Eric Chen
  • 3,562
  • 7
  • 39
  • 58
  • 1
    I think you should be looking at using another type of widget as a Paned widget is specifically used to allow the user to adjust the size of the child. A vbox/hbox would do what you need, and just allow the child to request a different size if required. – Andrew Steele Apr 30 '11 at 22:34
  • With the vbox/hbox approach I can programmatically change the size, but the user cannot drag the borders to resize (like a window). Is there yet another widget that would allow me to dynamically enable/disable drag-resizing? – Eric Chen May 01 '11 at 03:23
  • Er, I think I am misunderstanding something: vbox/hbox do not at all prevent a window from being resized. (Are your `pack_start` fill/expand settings correct? Is your widget of a fixed size?) –  May 05 '11 at 10:12
  • @user25148 From my understanding VBox/HBox are deprecated in GTK-3, and the only way to set the width and height in the successor `Box`, is by setting the minimum width/height (setting the requested width/height). Which blocks the container window from making it smaller than its childs width/height. So yes: The window is then blocked from resizing (although only in the smaller direction, increasing the size still works). – Jan Diederich May 27 '23 at 18:37

1 Answers1

1

One possible (dirty :)) way would be to track Paned' events and re-set its size:

def handle_cb (pane, param):
    # detect if paned is locked
    # or its position has changed - ommited
    pane.set_position(10)
    return True

pane = gtk.VPaned()
...
pane.connect("notify", handle_cb)

I'd try to set child widgets unshrinkable first, though.

barti_ddu
  • 10,179
  • 1
  • 45
  • 53