Example #1
0
    def GetDisplayId(self):
        """Function to get X11 Display ID from WX and return it in a format
        that can be used by VTK Python.

        We query the X11 Display with a new call that was added in wxPython
        2.6.0.1.  The call returns a SWIG object which we can query for the
        address and subsequently turn into an old-style SWIG-mangled string
        representation to pass to VTK.
        """
        d = None

        try:
            d = wx.GetXDisplay()

        except NameError:
            # wx.GetXDisplay was added by Robin Dunn in wxPython 2.6.0.1
            # if it's not available, we can't pass it.  In general,
            # things will still work; on some setups, it'll break.
            pass

        else:
            # wx returns None on platforms where wx.GetXDisplay is not relevant
            if d:
                d = hex(d)
                # On wxPython-2.6.3.2 and above there is no leading '0x'.
                if not d.startswith('0x'):
                    d = '0x' + d

                # we now have 0xdeadbeef
                # VTK wants it as: _deadbeef_void_p (pre-SWIG-1.3 style)
                d = '_%s_%s' % (d[2:], 'void_p')

        return d
Example #2
0
 def GetDisplayId(self):
     d = None
     try:
         d = wx.GetXDisplay()
     except NameError:
         pass
     else:
         if d:
             d = hex(d)
             if not d.startswith('0x'):
                 d = '0x' + d
             d = '_%s_%s\0' % (d[2:], 'p_void')
     return d
Example #3
0
    def GetDisplayId(self):
        """Function to get X11 Display ID from WX and return it in a format
        that can be used by VTK Python.

        We query the X11 Display with a new call that was added in wxPython
        2.6.0.1.  The call returns a SWIG object which we can query for the
        address and subsequently turn into an old-style SWIG-mangled string
        representation to pass to VTK.
        """
        d = None

        try:
            d = wx.GetXDisplay()

        except (AttributeError, NameError):
            # wx.GetXDisplay was added by Robin Dunn in wxPython 2.6.0.1
            # if it's not available, we can't pass it.  In general,
            # things will still work; on some setups, it'll break.
            pass

        else:
            # wx returns None on platforms where wx.GetXDisplay is not relevant
            if d:
                d = hex(d)
                # On wxPython-2.6.3.2 and above there is no leading '0x'.
                if not d.startswith('0x'):
                    d = '0x' + d

                # the vtk pointer format changed between 6.1 and 6.2
                ver = list(
                    map(int,
                        vtk.vtkVersion().GetVTKVersion().split('.')))
                ver = ver[0] * 10000 + ver[1] * 100 + ver[2]

                if ver < 60200:
                    d = '_%s_%s\0' % (d[2:], 'void_p')
                else:
                    # VTK wants it as: _xxxxxxxx_p_void (SWIG pointer)
                    d = '_%s_%s\0' % (d[2:], 'p_void')

        return d