(bindings=None,
                         antialiasing=False,
                         constrain_ratio=False,
                         constrain_navigation=False,
                         activate_help=True,
                         activate_grid=False,
                         show_grid=False,
                         display_fps=False,
                         activate3D=False,
                         animation_interval=None,
                         momentum=False,
                         autosave=None,
                         getfocus=True,
                         figure=None,
                        **companion_classes)
return MyWidget
Helper function to create a custom widget class from various parameters.
    
    Arguments:
      * bindings=None: the bindings class, instance, or a list of those.
      * antialiasing=False: whether to activate antialiasing or not. It can
        hurt performance.
      * constrain_ratio=False: if True, the ratio is 1:1 at all times.
      * constrain_navigation=True: if True, the viewbox cannot be greater
        than [-1,1]^2 by default (but it can be customized in 
        interactionmanager.MAX_VIEWBOX).
      * display_fps=False: whether to display the FPS.
      * animation_interval=None: if not None, a special widget with automatic
        timer update is created. This variable then refers to the time interval
        between two successive updates (in seconds).
      * **companion_classes: keyword arguments with the companion classes.
Helper function to create a custom widget class from various parameters.
    
    Arguments:
      * bindings=None: the bindings class, instance, or a list of those.
      * antialiasing=False: whether to activate antialiasing or not. It can
        hurt performance.
      * constrain_ratio=False: if True, the ratio is 1:1 at all times.
      * constrain_navigation=True: if True, the viewbox cannot be greater
        than [-1,1]^2 by default (but it can be customized in 
        interactionmanager.MAX_VIEWBOX).
      * display_fps=False: whether to display the FPS.
      * animation_interval=None: if not None, a special widget with automatic
        timer update is created. This variable then refers to the time interval
        between two successive updates (in seconds).
      * **companion_classes: keyword arguments with the companion classes.
Helper function to create a custom widget class from various parameters . Arguments : * bindings = None : the bindings class instance or a list of those . * antialiasing = False : whether to activate antialiasing or not . It can hurt performance . * constrain_ratio = False : if True the ratio is 1 : 1 at all times . * constrain_navigation = True : if True the viewbox cannot be greater than [ - 1 1 ] ^2 by default ( but it can be customized in interactionmanager . MAX_VIEWBOX ) . * display_fps = False : whether to display the FPS . * animation_interval = None : if not None a special widget with automatic timer update is created . This variable then refers to the time interval between two successive updates ( in seconds ) . * ** companion_classes : keyword arguments with the companion classes .
def create_custom_widget(bindings=None,
                         antialiasing=False,
                         constrain_ratio=False,
                         constrain_navigation=False,
                         activate_help=True,
                         activate_grid=False,
                         show_grid=False,
                         display_fps=False,
                         activate3D=False,
                         animation_interval=None,
                         momentum=False,
                         autosave=None,
                         getfocus=True,
                         figure=None,
                        **companion_classes):
    """Helper function to create a custom widget class from various parameters.
    
    Arguments:
      * bindings=None: the bindings class, instance, or a list of those.
      * antialiasing=False: whether to activate antialiasing or not. It can
        hurt performance.
      * constrain_ratio=False: if True, the ratio is 1:1 at all times.
      * constrain_navigation=True: if True, the viewbox cannot be greater
        than [-1,1]^2 by default (but it can be customized in 
        interactionmanager.MAX_VIEWBOX).
      * display_fps=False: whether to display the FPS.
      * animation_interval=None: if not None, a special widget with automatic
        timer update is created. This variable then refers to the time interval
        between two successive updates (in seconds).
      * **companion_classes: keyword arguments with the companion classes.
    
    """
    if momentum and animation_interval is None:
        animation_interval = .01
    
    # use the GalryTimerWidget if animation_interval is not None
    if animation_interval is not None:
        baseclass = GalryTimerWidget
    else:
        baseclass = GalryWidget
    
    if bindings is None:
        bindings = []
    if type(bindings) != list and type(bindings) != tuple:
        bindings = [bindings]
    
    # create the custom widget class
    class MyWidget(baseclass):
        """Automatically-created Galry widget."""
        def __init__(self):
            # antialiasing
            if QGLFormat is not None:
                format = QGLFormat()
            else:
                format = None
            if antialiasing:
                if hasattr(format, 'setSampleBuffers'):
                    format.setSampleBuffers(True)
            super(MyWidget, self).__init__(format=format, autosave=autosave,
                getfocus=getfocus)
        
        def initialize(self):
            if figure:
                figure.widget = self
            self.set_bindings(*bindings)
            self.set_companion_classes(**companion_classes)
            self.constrain_ratio = constrain_ratio
            self.constrain_navigation = constrain_navigation
            self.activate_help = activate_help
            self.activate_grid = activate_grid
            self.show_grid = show_grid
            self.activate3D = activate3D
            self.momentum = momentum
            self.display_fps = display_fps
            self.initialize_companion_classes()
            if animation_interval is not None:
                self.initialize_timer(dt=animation_interval)

    return MyWidget
def create_custom_widget ( bindings = None , antialiasing = False , constrain_ratio = False , constrain_navigation = False , activate_help = True , activate_grid = False , show_grid = False , display_fps = False , activate3D = False , animation_interval = None , momentum = False , autosave = None , getfocus = True , figure = None , * * companion_classes ) : if momentum and animation_interval is None : animation_interval = .01 # use the GalryTimerWidget if animation_interval is not None if animation_interval is not None : baseclass = GalryTimerWidget else : baseclass = GalryWidget if bindings is None : bindings = [ ] if type ( bindings ) != list and type ( bindings ) != tuple : bindings = [ bindings ] # create the custom widget class class MyWidget ( baseclass ) : """Automatically-created Galry widget.""" def __init__ ( self ) : # antialiasing if QGLFormat is not None : format = QGLFormat ( ) else : format = None if antialiasing : if hasattr ( format , 'setSampleBuffers' ) : format . setSampleBuffers ( True ) super ( MyWidget , self ) . __init__ ( format = format , autosave = autosave , getfocus = getfocus ) def initialize ( self ) : if figure : figure . widget = self self . set_bindings ( * bindings ) self . set_companion_classes ( * * companion_classes ) self . constrain_ratio = constrain_ratio self . constrain_navigation = constrain_navigation self . activate_help = activate_help self . activate_grid = activate_grid self . show_grid = show_grid self . activate3D = activate3D self . momentum = momentum self . display_fps = display_fps self . initialize_companion_classes ( ) if animation_interval is not None : self . initialize_timer ( dt = animation_interval ) return MyWidget