## popup message -A disappearing message def popupMessage(function_name): """ Displays an in-view message indicating that a function has been copied to the clipboard. :param function_name: #The name of the function that has been copied. :return: """ mc.inViewMessage(amg="Copied!!\nFunction name '{0}' has been copied to the clipboard.".format(function_name), pos='midCenter', fade=True) # Test function is provided to test main function popupMessage def test_popupMessage(): popupMessage(function_name='exampleFunction') # Since mc.inViewMessage affects the UI, manual verification is required. print("popupMessage executed successfully.") test_popupMessage()
top of page

โœจ๐ŸŽฏ ๐˜ฟ๐™–๐™ฎ03 -100-๐˜ฟ๐™–๐™ฎ๐™จ ๐˜พ๐™ค๐™™๐™š ๐™Ž๐™ฃ๐™ž๐™ฅ๐™ฅ๐™š๐™ฉ๐™จ ๐˜พ๐™๐™–๐™ก๐™ก๐™š๐™ฃ๐™œ๐™š

Writer's picture: Subbu AddankiSubbu Addanki

โœจ๐ŸŽฏ ๐˜ฟ๐™–๐™ฎ03 - ๐™จ๐™๐™ค๐™ฌ๐™ƒ๐™š๐™–๐™™๐™จ๐™๐™ฅ๐™ˆ๐™š๐™จ๐™จ๐™–๐™œ๐™š ๐ŸŽจ๐Ÿš€



Hello Maya enthusiasts and Python coders! ๐Ÿ‘‹

I'm excited to share another powerful utility to elevate your Maya scripting workflowโ€”showHeadsUpMessage! ๐ŸŒŸ

In the dynamic world of VFX and Animation, effective communication within your pipeline is key. showHeadsUpMessage leverages Maya's headsUpDisplayย command to provide persistent, in-viewport messages that keep you informed without interrupting your creative process. Whether you're monitoring script progress, displaying critical information, or enhancing user interactions, this tool is a game-changer. Letโ€™s dive into its features:

๐ŸŽจ ๐™„๐™ฃ๐™ฉ๐™ง๐™ค๐™™๐™ช๐™˜๐™ž๐™ฃ๐™œ ๐™ƒ๐™š๐™–๐™™๐™จ๐™๐™ฅ๐™Ž๐™ฉ๐™ฎ๐™ก๐™š๐™๐™„

Our new UI, HeadsUpStyleUI, is designed to be sleek, stylish, and seamlessly integrates into your Maya workspace. Here's what it includes:

  • Heads-Up Display (HUD): Shows persistent messages directly in the viewport.

  • Status Indicator: Provides real-time updates on ongoing processes.

  • Clear Button: Allows users to remove the HUD message when needed.

  • Agave Font: Ensures all UI elements have a consistent and modern typography.

All UI elements are crafted using the elegant Agave font, ensuring a cohesive and professional look.

๐Ÿ› ๏ธ ๐™จ๐™๐™ค๐™ฌ๐™ƒ๐™š๐™–๐™™๐™จ๐™๐™ฅ๐™ˆ๐™š๐™จ๐™จ๐™–๐™œ๐™š ๐˜พ๐™ค๐™™๐™š ๐™Ž๐™ฃ๐™ž๐™ฅ๐™ฅ๐™š๐™ฉ:

##1
import maya.cmds as cmds

def show_confirm_dialog(title="Confirmation", message="Operation completed successfully!"):
    """
    Displays a simple confirmation dialog with an OK button.

    Parameters:
        title (str): The title of the dialog window.
        message (str): The message displayed in the dialog.

    Example:
        show_confirm_dialog("Save Status", "Your file has been saved successfully.")
    """
    cmds.confirmDialog(
        title=title,
        message=message,
        button=['OK'],
        defaultButton='OK',
        dismissString='OK'
    )

# Example Usage:
if __name__ == "__main__":
    show_confirm_dialog("Process Complete", "Your animation render has finished successfully!")




##2
cmds.confirmDialog(
    title='Delete Confirmation',
    message='Are you sure you want to delete this asset?',
    button=['Yes', 'No'],
    defaultButton='Yes',
    cancelButton='No',
    dismissString='No'
)




##3
result = cmds.confirmDialog(
    title='Save Changes',
    message='Do you want to save changes before exiting?',
    button=['Save', 'Don\'t Save', 'Cancel'],
    defaultButton='Save',
    cancelButton='Cancel',
    dismissString='Cancel'
)

if result == 'Save':
    # Call save function
    save_project()
elif result == 'Don\'t Save':
    # Proceed without saving
    exit_project()
else:
    # Cancel the exit process
    pass


๐™จ๐™๐™ค๐™ฌ๐™ƒ๐™š๐™–๐™™๐™จ๐™๐™ฅ๐™ˆ๐™š๐™จ๐™จ๐™–๐™œ๐™š ๐™‹๐™ฎ๐™Ž๐™ž๐™™๐™š2 ๐™‘๐™š๐™ง๐™จ๐™ž๐™ค๐™ฃ

[Todayโ€™s Challenge is to take this simple code to next level.. I am sharing images of these advanced codes... Due to space constraints, I couldnโ€™t share those codes here.. But checking for the other possibilities] ##4

from PySide2 import QtWidgets, QtCore, QtGui

def number_of_block():

"""

Determines the next available block number for the HUD.

:return: <int> The next block number.

"""

try:

existing_blocks = mc.headsUpDisplay(query=True, blockArray=True)

if existing_blocks:

return max(existing_blocks) + 1

except:

pass

return 1

def showHeadsUpMessage(message, section='center', block=None):

"""

Displays a heads-up message in the Maya viewport.

:param message: <str> The message to display.

:param section: <str> The section of the HUD to display the message in.

:param block: <int> The block number within the section. If None, it determines the next available block.

:return: <None>

"""

if block is None:

block = number_of_block()

hud_name = 'HeadsUpStyleHUD'

# Remove existing HUD with the same name to prevent duplication

if mc.headsUpDisplay(hud_name, exists=True):

mc.headsUpDisplay(hud_name, remove=True)

# Add new HUD message with advanced configuration

try:

mc.headsUpDisplay(

hud_name,

section=section,

block=block,

label=message,

event='idle',

command='return "{}"'.format(message),

font='fixedWidthFont', # 'fixedWidthFont' for better clarity in heads-up messages

commandAlignment='left',

dataFontSize='large' # Ensures the message is clear and prominent

)

except Exception as e:

mc.warning("Failed to create HeadsUpDisplay: {}".format(e))

# Heads-Up UI for managing messages

class HeadsUpStyleUI(QtWidgets.QWidget):

def __init__(self):

super(HeadsUpStyleUI, self).__init__()

self.setWindowTitle("HeadsUpStyleUI")

self.setObjectName('HeadsUpStyleUI')

self.setStyleSheet("""

QWidget#HeadsUpStyleUI {

background-color: #333333;

border: 2px solid #555555;

border-radius: 10px;

}

QLabel {

font-family: 'Agave';

color: #F5F5F5; /* Light text */

}

QPushButton {

font-family: 'Agave';

background-color: #4A4A4A;

color: #FFFFFF;

border: 2px solid #FF914D;

border-radius: 8px;

padding: 8px 15px;

transition: all 0.3s ease;

}

QPushButton:hover {

background-color: #FF914D;

color: #2C2C2C;

border: 2px solid #F5F5F5;

}

QPushButton:pressed {

background-color: #FF7043;

border: 2px solid #FF914D;

}

""")

layout = QtWidgets.QVBoxLayout()

# Status message label

self.messageLabel = QtWidgets.QLabel("Heads-Up: Rendering in Progress...")

self.messageLabel.setAlignment(QtCore.Qt.AlignCenter)

layout.addWidget(self.messageLabel)

# Clear button for removing HUD

self.clearButton = QtWidgets.QPushButton("Clear Heads-Up")

layout.addWidget(self.clearButton)

self.setLayout(layout)

self.setFixedSize(350, 150)

self.clearButton.clicked.connect(self.clearMessage)

def clearMessage(self):

"""

Clears the HeadsUpDisplay message.

"""

try:

mc.headsUpDisplay('HeadsUpStyleHUD', remove=True)

self.close()

print("HeadsUpDisplay message cleared.")

except Exception as e:

mc.warning("Failed to remove HeadsUpDisplay: {}".format(e))

# Test function to demonstrate showHeadsUpMessage

def test_showHeadsUpMessage():

"""

Function to test the Heads-Up Message functionality.

"""

showHeadsUpMessage(message="Rendering in Progress...", section='center')

print("HeadsUpMessage executed successfully.")

# Running the UI standalone (for testing purposes)

if __name__ == "__main__":

# Test the heads-up display message functionality

test_showHeadsUpMessage()

# Show the custom UI for managing heads-up display messages

window = HeadsUpStyleUI()

window.show()


๐Ÿ” ๐™’๐™๐™–๐™ฉ ๐™จ๐™๐™ค๐™ฌ๐™ƒ๐™š๐™–๐™™๐™จ๐™๐™ฅ๐™ˆ๐™š๐™จ๐™จ๐™–๐™œ๐™š ๐™Š๐™›๐™›๐™š๐™ง๐™จ:

  • Persistent In-Viewport Messaging:ย Keeps you informed with continuous updates without intrusive dialogs.

  • Real-Time Status Updates:ย Monitor the progress of scripts or processes directly within the viewport.

  • User Control:ย Easily clear messages with a single click, maintaining a clutter-free workspace.

  • Stylish Integration:ย Modern UI design that complements Mayaโ€™s interface, enhancing overall user experience.

๐Ÿ”ง ๐™†๐™š๐™ฎ ๐˜ฝ๐™š๐™ฃ๐™š๐™›๐™ž๐™ฉ๐™จ:

โ€ข ๐Ÿš€ Enhance Workflow Efficiency:ย Stay informed about script operations in real-time, reducing the need to switch contexts.

โ€ข ๐Ÿ” Improve User Feedback:ย Provide clear and immediate feedback, making your tools more intuitive and user-friendly.

โ€ข ๐Ÿ“ˆ Boost Productivity:ย Eliminate the need for external logs or manual checks, allowing you to focus more on creative tasks.

โ€ข ๐Ÿ’ก Flexible Usage:ย Ideal for a variety of tasks, from rendering notifications to process tracking, adaptable to your specific pipeline needs.

I'm sharing showHeadsUpMessageย to help Maya developers and technical artists create more interactive and efficient scripts. Say goodbye to intrusive dialogs and hello to seamless, in-context updates that keep you in the flow!

โœจ Ready to Enhance Your Maya Workflow?ย โœจReach out or comment below to see showHeadsUpMessage in action. Letโ€™s elevate our Maya scripting together! ๐Ÿ’ช๐ŸŽ‰

15 views0 comments

Comments


bottom of page