Ejemplo n.º 1
0
def _test_ImagePanel():

    icon = op.join(datadir, 'true.png')
    icon = wx.Bitmap(icon, wx.BITMAP_TYPE_PNG)
    icon = icon.ConvertToImage()

    frame = wx.GetApp().GetTopWindow()
    panel1 = ip.ImagePanel(frame)
    realYield()
    panel1.SetImage(icon)
    realYield()
    panel2 = ip.ImagePanel(frame, preserveAspect=True)
    realYield()
    panel2.SetImage(icon)
    realYield()
Ejemplo n.º 2
0
    def __init__(self, parent):
        """Create a ``FSLeyesSplash`` frame.

        :arg parent: The :mod:`wx` parent object.
        """

        wx.Frame.__init__(self, parent, style=wx.FULL_REPAINT_ON_RESIZE)

        splashbmp  = wx.Bitmap(getSplashFile(), wx.BITMAP_TYPE_PNG)
        splashimg  = splashbmp.ConvertToImage()

        self.__splashPanel = imagepanel.ImagePanel(self, splashimg)
        self.__statusBar   = wx.StaticText(self, style=wx.ST_ELLIPSIZE_MIDDLE)

        self.__statusBar.SetLabel(strings.messages[self, 'default'])

        self.__statusBar.SetBackgroundColour('#000000')
        self.__statusBar.SetForegroundColour('#ffffff')
        self            .SetBackgroundColour('#000000')

        self.__sizer = wx.BoxSizer(wx.VERTICAL)

        self.__sizer.Add(self.__splashPanel, flag=wx.EXPAND, proportion=1)
        self.__sizer.Add(self.__statusBar,   flag=wx.EXPAND)

        self.SetSizer(self.__sizer)

        self.Layout()
        self.Fit()
Ejemplo n.º 3
0
def _test_ImagePanel():

    icon = op.join(datadir, 'true.png')
    icon = wx.Bitmap(icon, wx.BITMAP_TYPE_PNG)
    icon = icon.ConvertToImage()

    frame = wx.GetApp().GetTopWindow()
    panel = ip.ImagePanel(frame)
    wx.Yield()
    panel.SetImage(icon)
    wx.Yield()
Ejemplo n.º 4
0
def _ColourMapOpts_ColourMapWidget(target, parent, panel, overlayList,
                                   displayCtx, threedee):
    """Builds a panel which contains widgets for controlling the
    :attr:`.ColourMapOpts.cmap`, :attr:`.ColourMapOpts.negativeCmap`, and
    :attr:`.ColourMapOpts.useNegativeCmap`.

    :returns: A ``wx.Sizer`` containing all of the widgets, and a list
              containing the extra widgets that were added.
    """

    # Button to load a new
    # colour map from file
    loadAction = loadcmap.LoadColourMapAction(overlayList, displayCtx)

    loadButton = wx.Button(parent)
    loadButton.SetLabel(strings.labels[panel, 'loadCmap'])

    loadAction.bindToWidget(panel, wx.EVT_BUTTON, loadButton)

    cmap = getWidgetSpecs(target, threedee)['cmap']
    negCmap = getWidgetSpecs(target, threedee)['negativeCmap']
    useNegCmap = getWidgetSpecs(target, threedee)['useNegativeCmap']

    cbpanel = imagepanel.ImagePanel(parent)
    cbpanel.SetMinSize((-1, 30))
    colourbar = cbar.ColourBar(overlayList, displayCtx)

    colourbar.bgColour = (0, 0, 0, 0)
    colourbar.showLabel = False
    colourbar.showTicks = False

    def cbarUpdate(*a):
        w, h = cbpanel.GetSize().Get()

        if w < 20 or h < 20:
            return

        bmp = colourbar.colourBar(w, h)

        if bmp is None:
            return

        if fwidgets.wxversion() == fwidgets.WX_PHOENIX:
            bmp = wx.Bitmap.FromBufferRGBA(w, h, bmp.transpose(1, 0, 2))
        else:
            bmp = wx.BitmapFromBufferRGBA(w, h, bmp.transpose(1, 0, 2))

        cbpanel.SetImage(bmp.ConvertToImage())

    lname = 'ColourBarWidget_{}'.format(colourbar)

    def onDestroy(ev):
        colourbar.deregister(lname)
        colourbar.destroy()

    colourbar.register(lname, cbarUpdate)
    cbpanel.Bind(wx.EVT_SIZE, cbarUpdate)
    cbpanel.Bind(wx.EVT_WINDOW_DESTROY, onDestroy)

    cbarUpdate()

    cmap = props.buildGUI(parent, target, cmap)
    negCmap = props.buildGUI(parent, target, negCmap)
    useNegCmap = props.buildGUI(parent, target, useNegCmap)

    useNegCmap.SetLabel(strings.properties[target, 'useNegativeCmap'])

    sizer = wx.GridBagSizer()
    sizer.AddGrowableCol(0)

    sizer.Add(cbpanel, (0, 0), (1, 2), flag=wx.EXPAND)
    sizer.Add(cmap, (1, 0), (1, 1), flag=wx.EXPAND)
    sizer.Add(loadButton, (1, 1), (1, 1), flag=wx.EXPAND)
    sizer.Add(negCmap, (2, 0), (1, 1), flag=wx.EXPAND)
    sizer.Add(useNegCmap, (2, 1), (1, 1), flag=wx.EXPAND)

    return sizer, [cmap, negCmap, useNegCmap]
Ejemplo n.º 5
0
    def __init__(self, parent):
        """Create an ``AboutDialog``.

        :arg parent: ``wx`` parent object.
        """
        wx.Dialog.__init__(self, parent, title=strings.about['title'])

        # Load the splash screen
        splashbmp = wx.Bitmap(splash.getSplashFile(), wx.BITMAP_TYPE_PNG)
        splashimg = splashbmp.ConvertToImage()

        # Create all the widgets
        splashPanel = imagepanel.ImagePanel(self, splashimg)
        splashPanel.SetMinSize(splashimg.GetSize())

        textPanel = wx.TextCtrl(
            self,
            size=(-1, 200),
            style=(wx.TE_LEFT | wx.TE_RICH | wx.TE_MULTILINE | wx.TE_READONLY
                   | wx.TE_AUTO_URL))
        closeButton = wx.Button(self, id=wx.ID_CANCEL)

        # Set foreground/background colours
        textPanel.SetBackgroundColour('#000000')
        textPanel.SetForegroundColour('#ffffff')
        textPanel.SetDefaultStyle(wx.TextAttr('#ffffff', '#000000'))

        # Create / retrieve all the content
        verStr = version.__version__
        glVerStr = fslplatform.glVersion
        glRenStr = fslplatform.glRenderer
        swlibs = strings.about['libs']

        swVersions = []
        for lib in swlibs:

            try:
                mod = __import__(lib)

                # Retrieve the sub-module if necessary
                for n in lib.split(".")[1:]:
                    mod = getattr(mod, n)

                if lib == 'PIL':
                    swVer = str(mod.PILLOW_VERSION)
                else:
                    swVer = str(mod.__version__)
            except Exception:
                swVer = ''

            swVersions.append(swVer)

        verStr = strings.about['version'].format(verStr)
        fslVer = strings.about['fslVersion'].format(fslplatform.fslVersion)
        fslDir = strings.about['fslPath'].format(fslplatform.fsldir)
        glVerStr = strings.about['glVersion'].format(glVerStr)
        glCompat = strings.about['glCompat'].format(fslplatform.glVersion)
        glRenStr = strings.about['glRenderer'].format(glRenStr)
        swStr = strings.about['software'].format(*swVersions)

        # Tack the license file contents onto
        # the end of the software description.
        licenseFile = op.join(op.dirname(__file__), '..', '..', 'LICENSE')
        try:
            with open(licenseFile, 'rt') as f:
                licenseStr = f.read()
        except Exception:
            licenseStr = ''

        swStr = swStr + '\n\n' + licenseStr
        swStr = swStr.strip()

        # Set the widget content
        infoStr = '\n'.join((verStr, strings.about['company'],
                             strings.about['author'], strings.about['email'],
                             fslVer, fslDir, glVerStr, glCompat, glRenStr))

        textPanel.SetValue(infoStr + '\n\n' + swStr)
        closeButton.SetLabel('Close')

        # Arrange the widgets
        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer.Add(splashPanel)
        sizer.Add(textPanel, flag=wx.EXPAND, proportion=1)
        sizer.Add(closeButton, flag=wx.EXPAND)

        self.SetSizer(sizer)
        self.Layout()
        self.Fit()