How to resize a script toolbar

How to resize a script toolbar

e_juma
Enthusiast Enthusiast
1,155 Views
4 Replies
Message 1 of 5

How to resize a script toolbar

e_juma
Enthusiast
Enthusiast

I created my toolbar using script and use cui to register it.  CUI.REGISTERDIALOGBAR

I set the height as 36 before registering it with cui. But cui changes its size and makes it as 74. I tried to manually change it. But cui refused it. It says:

-- Runtime error: Cannot set property while registered as dialogBar: height

How can I set my toolbar with expected height?

0 Likes
1,156 Views
4 Replies
Replies (4)
Message 2 of 5

Swordslayer
Advisor
Advisor
rollout testRollout "" width:50 height:25
(
	button btnEmpty "Empty" align:#center

	on testRollout open do
	(
		cui.RegisterDialogBar testRollout style:#(#cui_dock_top, #cui_max_sized, #cui_floatable, #cui_handles) maxSize:[50,25] minSize:[50,25]
		cui.DockDialogBar testRollout #cui_dock_top

		local pySide2 = python.import "PySide2"
		local toolbarWidget = pySide2.QtWidgets.QWidget.find (UIAccessor.GetParentWindow (UIAccessor.GetParentWindow testRollout.hwnd))
		toolbarWidget.setFixedHeight 25
	)
)
createDialog testRollout
Message 3 of 5

denisT.MaxDoctor
Advisor
Advisor

@Swordslayer wrote:

local pySide2 = python.import "PySide2"

 

I'm so happy to see that! Is there any documentation? ... but anyway, I'm glad to just know that it exists, everything else is at least "SAPIENTI SAT".

0 Likes
Message 4 of 5

Swordslayer
Advisor
Advisor

Looks like on 2021 accessing QtWidgets this way won't work so python.import "PySide2.QtWidgets" has to be used instead.

 


@denisT.MaxDoctor wrote:

@Swordslayer wrote:

local pySide2 = python.import "PySide2"

 

I'm so happy to see that! Is there any documentation? ... but anyway, I'm glad to just know that it exists, everything else is at least "SAPIENTI SAT".


Which part? The python.import to get python modules exposed to mxs directly was already documented five years ago when pymxs was introduced, so you can do fun stuff like this for quite a while:

 

 

builtin = python.import "builtins" #"__builtin__" for python 2.6
itertools = python.import "itertools"

builtin.list(itertools.repeat 10 5) as array
builtin.all #{1..5,7}

 

 

I usually only use the Qt portions (for new parts of UI) and ctypes (since I'm too lazy to write verbose C# only to get some user32 methods and they're pretty conveniently exposed via ctypes.windll.user32).

 

ctypes = python.import "ctypes"
ctypes.windll.user32.SendMessageW ...

 

As for PySide2 usage from MAXScript, querying/modifying existing parts of the UI is pretty straightforward but I don't think you could for example use it to create a Qt dialog from mxs that would do something - but I would certainly like to be proven wrong 🙂

0 Likes
Message 5 of 5

denist.dts
Explorer
Explorer

At least I can already load UI files using QtUiLoader 🙂

0 Likes