Spyder Python Message Box With Icon

Spyder Python Message Box With Icon

isocam
Collaborator Collaborator
844 Views
1 Reply
Message 1 of 2

Spyder Python Message Box With Icon

isocam
Collaborator
Collaborator

Can anybody help?

 

Can anybody please tell me is Spyder Python messagebox can be displayed with an icon as well, similar to the VB.net

MsgBox(“Hello WORLD”, MsgBoxStyle.Information, “this is a msgbox”)

 

Many thanks in advance

 

Darren

0 Likes
845 Views
1 Reply
Reply (1)
Message 2 of 2

JeromeBriot
Mentor
Mentor

Hello Darren,

use the messageBox method of the UserInterface object with its second calling form:

returnValue = userInterface_var.messageBox(text, title, buttons, icon)


Then see these enumerations :


Now your example translated in Python:

import adsk.core, traceback

def run(context):

    ui = None

    try:

        app = adsk.core.Application.get()
        ui  = app.userInterface

        ui.messageBox('Hello WORLD', 'this is a msgbox', adsk.core.MessageBoxButtonTypes.OKButtonType, adsk.core.MessageBoxIconTypes.InformationIconType)

        # Or shorter:
        #  ui.messageBox('Hello WORLD', 'this is a msgbox', 0, 2)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))



Hope it helps

0 Likes