示例#1
0
 def __init__(self, figure, parent, *args):
     # Create opengl format
     glFormat = QtOpenGL.QGLFormat()
     #glFormat.setSampleBuffers(True)
     #glFormat.setSamples(4)
     #
     QtOpenGL.QGLWidget.__init__(self, glFormat, parent, *args)
     self.setAttribute(QtCore.Qt.WA_DeleteOnClose) # keep cleaned up
     self.figure = figure
     # Note that the default QGLFormat has double buffering enabled.
     
     # Set icon
     try:
         iconFile = os.path.join(getResourceDir(), 'visvis_icon_%s.png' % qtlib)
         icon = QtGui.QIcon()
         icon.addFile(iconFile, QtCore.QSize(16,16))
         self.setWindowIcon(icon)
     except Exception:
         pass
     
     # enable mouse tracking so mousemove events are always fired.        
     self.setMouseTracking(True)
     
     # enable getting keyboard focus
     self.setFocusPolicy(QtCore.Qt.StrongFocus)
     self.setFocus() # make the widget have focus...
    def __init__(self):
        # load font data
        path = getResourceDir()
        self.s = ssdf.load(os.path.join(path, 'fonts.ssdf'))

        # list of fonts
        self.fonts = {}
示例#3
0
def newFigure():
    """Create a figure and put it in a window."""

    figure = Figure()
    window = gtk.Window()

    # Set icon
    try:
        iconfile = os.path.join(getResourceDir(), 'visvis_icon_gtk.png')
        window.set_icon_from_file(iconfile)
    except Exception:
        pass

    # From GTKGL example
    if sys.platform != 'win32':
        window.set_resize_mode(gtk.RESIZE_IMMEDIATE)
    window.set_reallocate_redraws(True)

    window.add(figure._widget)
    size = visvis.settings.figureSize
    figure._widget.set_size_request(size[0], size[1])
    window.set_geometry_hints(min_width=100, min_height=100)
    window.show_all()

    window.connect('delete-event', figure._widget._on_delete_event)

    # Initialize OpenGl
    figure.DrawNow()
    return figure
示例#4
0
 def __init__(self):
     # load font data
     path = getResourceDir()
     self.s = ssdf.load(os.path.join(path, 'fonts.ssdf'))
     
     # list of fonts
     self.fonts = {}
示例#5
0
def newFigure():
    """Create a figure and put it in a window."""
    
    figure = Figure()
    window = gtk.Window()
    
    # Set icon
    try:
        iconfile = os.path.join(getResourceDir(), 'visvis_icon_gtk.png')
        window.set_icon_from_file(iconfile)
    except Exception:
        pass
    
    # From GTKGL example
    if sys.platform != 'win32':
        window.set_resize_mode(gtk.RESIZE_IMMEDIATE)
    window.set_reallocate_redraws(True)
    
    window.add(figure._widget)
    size = visvis.settings.figureSize 
    figure._widget.set_size_request(size[0], size[1])
    window.set_geometry_hints(min_width=100, min_height=100)
    window.show_all()
    
    window.connect('delete-event', figure._widget._on_delete_event)
    
    # Initialize OpenGl
    figure.DrawNow()
    return figure
示例#6
0
    def __init__(self, figure, parent, *args):
        # Create opengl format
        glFormat = QtOpenGL.QGLFormat()
        #glFormat.setSampleBuffers(True)
        #glFormat.setSamples(4)
        #
        QtOpenGL.QGLWidget.__init__(self, glFormat, parent, *args)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)  # keep cleaned up
        self.figure = figure
        # Note that the default QGLFormat has double buffering enabled.

        # Set icon
        try:
            iconFile = os.path.join(getResourceDir(),
                                    'visvis_icon_%s.png' % qtlib)
            icon = QtGui.QIcon()
            icon.addFile(iconFile, QtCore.QSize(16, 16))
            self.setWindowIcon(icon)
        except Exception:
            pass

        # enable mouse tracking so mousemove events are always fired.
        self.setMouseTracking(True)

        # enable getting keyboard focus
        self.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setFocus()  # make the widget have focus...
示例#7
0
def newFigure():
    """ Create a window with a figure widget.
    """

    # Make sure there is a native app. Need here too, because we need to
    # create the figure frame first
    app.Create()

    # Create frame
    refSize = tuple(visvis.settings.figureSize)
    frame = FigureFrame(None, -1, "Figure", size=refSize)

    # Correct size. The given size includes the window manager's frame
    size = frame.GetClientSizeTuple()
    w = refSize[0] + (refSize[0] - size[0])
    h = refSize[1] + (refSize[1] - size[1])
    frame.SetSize((w, h))

    # Inser figure
    figure = Figure(frame)

    # Set icon
    try:
        iconFile = os.path.join(getResourceDir(), 'visvis_icon_wx.png')
        frame.SetIcon(wx.Icon(iconFile, wx.BITMAP_TYPE_PNG))
    except Exception:
        pass

    # Show AFTER canvas is added
    frame.Show()

    # Apply a draw, so that OpenGl can initialize before we will really
    # do some drawing. Otherwis textures end up showing in black.
    figure.DrawNow()
    return figure
示例#8
0
def newFigure():
    """ Create a window with a figure widget.
    """
    
    # Make sure there is a native app. Need here too, because we need to
    # create the figure frame first
    app.Create()
    
    # Create frame
    refSize = tuple( visvis.settings.figureSize )
    frame = FigureFrame(None, -1, "Figure", size=refSize)
    
    # Correct size. The given size includes the window manager's frame
    size = frame.GetClientSizeTuple()
    w = refSize[0] + (refSize[0] - size[0])
    h = refSize[1] + (refSize[1] - size[1])
    frame.SetSize((w,h))
    
    # Inser figure
    figure = Figure(frame)
    
    # Set icon
    try:
        iconFile = os.path.join(getResourceDir(), 'visvis_icon_wx.png')
        frame.SetIcon(wx.Icon(iconFile, wx.BITMAP_TYPE_PNG))
    except Exception:        
        pass
    
    # Show AFTER canvas is added
    frame.Show() 
    
    # Apply a draw, so that OpenGl can initialize before we will really
    # do some drawing. Otherwis textures end up showing in black.
    figure.DrawNow()
    return figure
示例#9
0
文件: __init__.py 项目: chiluf/visvis
    def find_library(self):

        # Get Python dirs to search (shared is for Pyzo)
        import os
        py_sub_dirs = ['shared', 'lib', 'DLLs']
        py_lib_dirs = [os.path.join(sys.prefix, d) for d in py_sub_dirs]
        if hasattr(sys, 'base_prefix'):
            py_lib_dirs += [
                os.path.join(sys.base_prefix, d) for d in py_sub_dirs
            ]
        py_lib_dirs = [d for d in py_lib_dirs if os.path.isdir(d)]
        for py_lib_dir in py_lib_dirs:
            for fname in os.listdir(py_lib_dir):
                if 'freetype' in fname.lower() and _looks_lib(fname):
                    return os.path.join(py_lib_dir, fname)

        # Search in resources (only when frozen)
        if getattr(sys, 'frozen', None):
            from visvis.core.misc import getResourceDir
            import os
            for fname in os.listdir(getResourceDir()):
                if 'freetype' in fname.lower() and _looks_lib(fname):
                    return os.path.join(getResourceDir(), fname)

        # Try if ctypes knows where to find the freetype library
        fname = ctypes.util.find_library('freetype')

        # Try harder
        if not fname:
            if sys.platform.startswith('win'):
                NBITS = 8 * struct.calcsize("P")
                fname = ctypes.util.find_library('freetype6_' + str(NBITS))
            else:
                fname = 'libfreetype.so.6'

        # So far so good?
        if fname:
            return fname
        else:
            raise RuntimeError('Freetype library could not be found.')
示例#10
0
 def find_library(self):
     
     # Get Python dirs to search (shared is for Pyzo)
     import os
     py_sub_dirs = ['shared', 'lib', 'DLLs']
     py_lib_dirs = [os.path.join(sys.prefix, d) for d in py_sub_dirs]
     if hasattr(sys, 'base_prefix'):
         py_lib_dirs += [os.path.join(sys.base_prefix, d) for d in py_sub_dirs]
     py_lib_dirs = [d for d in py_lib_dirs if os.path.isdir(d)]
     for py_lib_dir in py_lib_dirs:
         for fname in os.listdir(py_lib_dir):
             if 'freetype' in fname.lower() and _looks_lib(fname):
                 return os.path.join(py_lib_dir, fname)
     
     # Search in resources (only when frozen)
     if getattr(sys, 'frozen', None):
         from visvis.core.misc import getResourceDir
         import os
         for fname in os.listdir(getResourceDir()):
             if 'freetype' in fname.lower() and _looks_lib(fname):
                 return os.path.join(getResourceDir(), fname)
     
     # Try if ctypes knows where to find the freetype library
     fname = ctypes.util.find_library('freetype')
     
     # Try harder 
     if not fname:
         if sys.platform.startswith('win'):
             NBITS = 8 * struct.calcsize("P")
             fname = ctypes.util.find_library('freetype6_'+str(NBITS))
         else:
             fname = 'libfreetype.so.6'
     
     # So far so good?
     if fname:
         return fname
     else:
         raise RuntimeError('Freetype library could not be found.')
示例#11
0
 def get_font_file_in_resources(self, fontname, bold, italic):
     
     # Normalize name and attributes
     fontname = fontname[0].upper() + fontname[1:].lower()
     bold = 'Bold' if bold else ''
     italic = 'Oblique' if italic else ''
     
     # Build filename
     fname = 'Free' + fontname + bold + italic + '.otf'
     fname = os.path.join( getResourceDir(), fname )
     
     # Check if exist
     if os.path.exists(fname):
         return fname
     else:
         return ''
    def get_font_file_in_resources(self, fontname, bold, italic):

        # Normalize name and attributes
        fontname = fontname[0].upper() + fontname[1:].lower()
        bold = 'Bold' if bold else ''
        italic = 'Oblique' if italic else ''

        # Be a bit smart
        if fontname in ['Xkcd', 'Humor']:
            fname = 'HumorSans.otf'  # xkcd-style font
        else:
            fname = 'Free' + fontname + bold + italic + '.otf'  # Freetype font

        # Check if exist
        fname = os.path.join(getResourceDir(), fname)
        if os.path.exists(fname):
            return fname
        else:
            return ''
示例#13
0
 def get_font_file_in_resources(self, fontname, bold, italic):
     
     # Normalize name and attributes
     fontname = fontname[0].upper() + fontname[1:].lower()
     bold = 'Bold' if bold else ''
     italic = 'Oblique' if italic else ''
     
     # Be a bit smart
     if fontname in ['Xkcd', 'Humor']:
         fname = 'HumorSans.otf'  # xkcd-style font
     else:
         fname = 'Free' + fontname + bold + italic + '.otf'  # Freetype font
     
     # Check if exist
     fname = os.path.join( getResourceDir(), fname )
     if os.path.exists(fname):
         return fname
     else:
         return ''