import moverlay moverlay.mayaDemo.demoOverlays()您可以在安装文件夹下的 Python/Lib/site-packages 中找到 moverlay。您还可以查看交互式教程演示或交互式基础知识教程中包含的脚本,以查看更多有关二维叠加代码和用法的示例。
叠加类型 | Hello World 示例 | 结果 |
---|---|---|
进度对话框: 设计为教程控制器的双按钮对话框窗口。 |
import moverlay as mo from PySide2.QtCore import QPoint def pressNext(): print("Next was pressed") def pressReset(): print("Reset was pressed") def pressClosed(dialog): manager.controller.deleteLater() #create manager object and assign its controller manager = mo.maya.overlayManager() manager.controller = mo.progressDialog.ProgressDialog(manager.getMainWindow()) #Assign title and body text manager.controller.setTitle("Example Dialog") manager.controller.setBodyText("Hello World") #Create buttons and attach them to appropriate procedures when clicked manager.controller.setupButton(0, "Reset", pressReset) manager.controller.setupButton(1, "Next", pressNext) manager.controller.setCloseCallback(pressClosed) #Create a progress bar with 10 steps manager.controller.progressBar().resetSteps(1, 10) #Re-size and position the controller manager.controller.theDialog().resize(mo.utils.DPIScale(180), mo.utils.DPIScale(250)) manager.controller.theDialog().moveToScreenPos(QPoint(0, 0)) #Display the controller manager.controller.showAndRaise() |
|
HIG 对话框: 设计为显示提示或图表的无按钮对话框窗口。 |
import moverlay as mo from PySide2.QtCore import QPoint def pressClosed(dialog): dialog.deleteLater() #Create manager and dialog object manager = mo.maya.overlayManager() dialog = mo.higDialog.HIGDialog(manager.getMainWindow()) #Assign body text label = dialog.setAsLabel('<h1>Example Dialog</h1><p>Hello World</p>') #Assign close procedure dialog.setCloseCallback(pressClosed) #Re-size and position the dialog dialog.theDialog().resize(mo.utils.DPIScale(180), mo.utils.DPIScale(250)) dialog.theDialog().moveToScreenPos(QPoint(0, 0)) dialog.theDialog().setFixedWidth(250) dialog.showAndRaise() |
|
气泡: 在指定位置显示的不可交互文字气泡。 注: 若要移除叠加,可以调用 overlayManager 的 deleteAll() 过程。
|
import moverlay as mo from PySide2.QtCore import QPoint from PySide2.QtCore import QSize from PySide2.QtGui import QColor #Create manager and overlay definition manager = mo.maya.overlayManager() od = mo.overlayDef.OverlayDef(QSize(300, 100)) #Position relative to screen center and apply the style and color od.style = mo.enums.OverlayStyle.SpeechBubble od.attachment = mo.enums.RelTo.Center od.bgColor = QColor(217, 217, 217, 255) #Create this overlay overlay = manage.createOverlay(od) #Assign body text label=overlay.setAsLabel("""<h2>Hello World</h2><p style="color: #3C3C3C; font-size: 16pt; font-weight: normal; font-style: normal; font-family: Artifakt Element">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>""") #Add a word bubble tail overlay.addSpeechBubbleTail(mo.enums.Direction.Top, 0.25) #Display the overlay bubble manager.showAll() |