Palette sample with useNewWebBrowser

Palette sample with useNewWebBrowser

JeromeBriot
Mentor Mentor
267 Views
0 Replies
Message 1 of 1

Palette sample with useNewWebBrowser

JeromeBriot
Mentor
Mentor

Hello,

 

Here is the version of the Palette sample in Python with useNewWebBrowser set to True.

 

The first modification is the last argument of Palettes.add sets to True at line 25:

 

palette = _ui.palettes.add('myPalette', 'My Palette', 'palette.html', True, True, True, 300, 200, True)

 

 

The second modification is in the event handler for the palette HTML event at line 108:

 

# Event handler for the palette HTML event.
class MyHTMLEventHandler(adsk.core.HTMLEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            htmlArgs = adsk.core.HTMLEventArgs.cast(args)
            if htmlArgs.action == 'response':
                response = json.loads(htmlArgs.data)
                msg = "An event has been fired from the html to Fusion with the following data:\n"
                msg += '    Command: {}\n'.format(htmlArgs.action)
                msg += '    Response: {}\n'.format(response['data'])
            else:
                data = json.loads(htmlArgs.data)
                msg = "An event has been fired from the html to Fusion with the following data:\n"
                msg += '    Command: {}\n    arg1: {}\n    arg2: {}'.format(htmlArgs.action, data['arg1'], data['arg2'])
            _ui.messageBox(msg)
        except:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Hope this helps.

 

268 Views
0 Replies
Replies (0)