Skip to content

Instantly share code, notes, and snippets.

@Swordslayer
Last active May 12, 2021 09:46
Show Gist options
  • Save Swordslayer/1582be3dc34e586993a29682318f0e41 to your computer and use it in GitHub Desktop.
Save Swordslayer/1582be3dc34e586993a29682318f0e41 to your computer and use it in GitHub Desktop.
Using Qt UI with scripted plugins.
plugin simpleManipulator MXSQtSample
name:"MXSQtSample" category:"Manipulators"
classID:#(0x76d22fb1, 0x190d5d2d)
(
parameters main rollout:params
(
radius type:#worldUnits default:10
on radius set val do if not loading and this.params.isDisplayed do
(
this.params.dial.blockSignals on --> prevent recursive calls
this.params.dial.setValue val
this.params.dial.blockSignals off
)
)
fn setRadius val = with undo on this.radius = val
rollout params "Radius" autoLayoutOnResize:on
(
local QtWidgets = if QtWidgets == undefined then python.import "PySide2.QtWidgets" else QtWidgets
local dial = QtWidgets.QDial()
local layout
on params open do
(
dial.setWrapping on
dial.setMaximum 100
dial.setValue this.radius
dial.valueChanged.connect this.setRadius
dial.sliderPressed.connect (fn startHold = theHold.superBegin())
dial.sliderReleased.connect (fn acceptHold = theHold.superAccept "Radius changed")
local rolloutWidget = QtWidgets.QWidget.find (UIAccessor.GetParentWindow params.hwnd)
layout = rolloutWidget.layout()
)
on params rolledUp open do
if open then layout.addWidget dial else layout.removeWidget dial
)
tool create numPoints:1 (on mousePoint click do nodeTM.translation = gridPoint)
on updateGizmos do
(
this.clearGizmos()
this.addGizmoShape (manip.makeCircle [0, 0, 0] radius 16) 0 (blue/255.) (orange/255.)
)
)
MXSQtSample isSelected:on
SetCommandPanelTaskMode #modify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment