Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Minimum Width in CreateDialog?

Minimum Width in CreateDialog?

alexandre_bisewski
Enthusiast Enthusiast
776 Views
3 Replies
Message 1 of 4

Minimum Width in CreateDialog?

alexandre_bisewski
Enthusiast
Enthusiast

Hi guys.I am creating a dialog from a rollout using this line:

createDialog _main 800 850  style:#(#style_titlebar, #style_border, #style_sysmenu, #style_minimizebox, #style_maximizebox, #style_resizing)

What is cool is that I can resize my script.

 

But I need a minimum width and I dont know how do it.

For example: If I change the width to 450 no problens...But when I move to 200 I want to stop here. This is the minimum value. I only can increase this value to turn the script more wider...

 

I had try to listener the width like if _main.width < 200 do (_main.width = 200) but not worked because the script start to fliker 

 

Thank you

 

0 Likes
Accepted solutions (1)
777 Views
3 Replies
Replies (3)
Message 2 of 4

Swordslayer
Advisor
Advisor
Accepted solution

There's nothing wrong with that approach (ie limiting the size in the resize handler), I do the same see for example Color Mixer, the Qt one. Why not full Qt and instead just one Qt widget in native mxs dialog? Because sometimes you want native controls for their niceties - spinners with keyable controllers or like here the colorpickers to copy-paste to material editor. 

Message 3 of 4

denisT.MaxDoctor
Advisor
Advisor

@Swordslayer wrote:

There's nothing wrong with that approach (ie limiting the size in the resize handler)...

The problem is the flickering... Depending on your monitor and graphics settings, it can range from just bad to very bad.

 

Message 4 of 4

denisT.MaxDoctor
Advisor
Advisor

 

try (rol.win.close()) catch()

rollout rol "RO:6D9E22C8" width:400
(
	local win 
	
	button bt_0 "d" width:(rol.width/6 - 6) align:#center across:6
	button bt_1 "e" width:(rol.width/6 - 6) align:#center
	button bt_2 "n" width:(rol.width/6 - 6) align:#center
	button bt_3 "i" width:(rol.width/6 - 6) align:#center
	button bt_4 "s" width:(rol.width/6 - 6) align:#center
	button bt_5 "T" width:(rol.width/6 - 6) align:#center
	
	fn create_qt =
	(
		cui.RegisterDialogBar rol

		host_hwnd = UIAccessor.GetParentWindow rol.hwnd
		dbar_hwnd = UIAccessor.GetParentWindow host_hwnd

		sc = GetUIScaleFactor()
		
		core = python.import "PySide2.QtCore"
		wdts = python.import "PySide2.QtWidgets"
		qwdt = wdts.QWidget	
		
		maxd = qwdt.find (windows.getMAXHWND())
		host = qwdt.find host_hwnd
		root = qwdt.find dbar_hwnd
		root.setAttribute core.Qt.WA_DeleteOnClose
			
		win = wdts.QDialog maxd
		win.setWindowTitle rol.title
		win.setAttribute core.Qt.WA_DeleteOnClose
		win.setWindowFlags core.Qt.Window 			

		lt = wdts.QHBoxLayout()
		lt.setContentsMargins 0 0 0 0
		win.setLayout lt
		lt.addWidget host
		
		win.setMinimumHeight (30 * sc)
		win.setMaximumHeight (30 * sc)
		
		win.setMinimumWidth (300 * sc)
		win.setMaximumWidth (1000 * sc)
			
		root.close()
		win
	)
	
	on rol resized size do
	(
		updateRolloutLayout rol forceUpdate:on
	)
	on rol open do
	(
		win = create_qt()
		win.show()
	)
)
createdialog rol style:#(#style_resizing) height:-1

 

 

... at least it flickers less 😜

 

0 Likes