Interactive/BrowserCustom.py

##
## (C) Copyright 2012 Autodesk, Inc. All Rights Reserved.
##
## By using this code, you are agreeing to the terms and conditions of
## the License Agreement included in the documentation for this code.
##
## AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE
## CORRECTNESS OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE
## IT. AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY
## DISCLAIMS ANY LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL
## DAMAGES FOR ERRORS, OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
##
## Use, duplication, or disclosure by the U.S. Government is subject
## to restrictions set forth in FAR 52.227-19 (Commercial Computer
## Software Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
## (Rights in Technical Data and Computer Software), as applicable.
##

# Append links to web pages to one of the menu items.

__all__ = ['BrowserCustom', 'instantiate', 'description']

from UserCustomization   import UserCustomBase, CustomInfo
from Browser             import BrowserFrame

class BrowserCustom (UserCustomBase):
    def __init__(self):
        self.__myMenu = None

    def appendMenuItems(self,id,menu):
        if self.__myMenu is None:
            self.__myMenu = menu

        if "View" == id:
            menu.appendItem('Autodesk in View menu', self.__onAutodesk)
        if "Edit" == id:
            menu.appendItem('3ds Max in Edit menu', self.__on3dsMax )
        if "Help" == id:
            menu.appendItem('Revit in Help menu', self.__onRevit )

    # ------------------------------------------------
    def __onAutodesk( self, event ):
        frame = BrowserFrame( self.__myMenu.getParentWindow(),
                              _('Autodesk'),
                              "http://www.autodesk.com",
                              (800,800),
                              None,
                              None )
        frame.Show( True )

    def __on3dsMax( self, event ):
        frame = BrowserFrame( self.__myMenu.getParentWindow(),
                              _('3ds Max'),
                              "http://www.autodesk.com/3dsmax",
                              (800,800),
                              None,
                              None )
        frame.Show( True )

    def __onRevit( self, event ):
        frame = BrowserFrame( self.__myMenu.getParentWindow(),
                              _('Revit'),
                              "http://www.revit.com",
                              (800,800),
                              None,
                              None )
        frame.Show( True )



def instantiate():
    return BrowserCustom()

def info():
    customInfo = CustomInfo()
    customInfo.vendor = 'Autodesk'
    customInfo.version = '1.0'
    customInfo.api = '2013'
    customInfo.shortInfo = "Open a web browser to custom links."
    customInfo.longInfo = \
"""Menu items are created that open the internal web browser, pointing to a few example pages.
"""
    return customInfo