Pyside expandable Toolbar widget example?

Hey all,

I’m trying to create a expandable toolbar in Pyside, and wondered if anyone could point me in the right direction / show examples of how they approached this?

Thanks!

It would definitely help us if you defined the behavior a little more

What do you mean by “expandable toolbar”? Are we completely hiding the tools when it’s not expanded? Where do you want the toolbar to live? Is this something to be docked and undocked? Is this something you want in a DCC like Maya?

Thanks for the fast reply. And sorry for not providing more detail.

I’m just looking to explore this idea at a base level. Getting this to work at a simple level so I can understand it fully before adding more features. No docking etc. Just the ability to add buttons which can expand to show more buttons / widget etc. I’ve attached a quick image also to help

expand

thanks again!

The simplest version of this that I know is a checkable button that hides and unhides widgets.

Make a button, and do btn.setCheckable(True). Then make a widget, and put all your tool buttons inside that. Then just connect the btn.toggled signal to the wid.setVisible slot.

And, of course, you can definitely do more with it after that to make it more readable/prettier, like adding the triangles that change with the check state

[edit]
And IMO you should do your prototyping in Qt Designer. And also, use Qt.py so it’ll work in both PySide, and PySide2.

1 Like

Thanks, that’s a great start. I appreciate it. I notice the layout does not re-size back to the smaller size after the widget is hidden. But I think this might be a pyside bug, and I have to force it to somehow?

Probably not a bug, and you do probably have to recompute the layout after hiding/showing.
Most GUI kits avoid doing layouts unless they absolutely have to.

1 Like

Thanks. Recomputing using self.resize, coupled with a _timer.singleShot seems to do the trick.