Exemple #1
0
    def makeBmpButton(self, main=None, emblem=None):
        """
        Produce buttons for the Runner.

        Parameters
        ----------
        main: str
            Name of main icon from Resources
        emblem: str
            Name of emblem icon from Resources
        Returns
        -------
        wx.BitmapButton
        """
        buttonSize = 32
        rc = self.app.prefs.paths['resources']
        join = os.path.join
        PNG = wx.BITMAP_TYPE_PNG

        if main and emblem:
            bmp = icons.combineImageEmblem(main=join(rc, main),
                                           emblem=join(rc, emblem),
                                           pos='bottom_right')
        else:
            bmp = wx.Bitmap(join(rc, main), PNG)
        return wx.BitmapButton(self,
                               -1,
                               bmp,
                               size=[buttonSize, buttonSize],
                               style=wx.NO_BORDER)
Exemple #2
0
 def AddPsychopyTool(self, fName, label, shortcut, tooltip, func):
     # Load in graphic resource
     rc = self.frame.app.prefs.paths['resources']
     if isinstance(fName, str):
         # If one stimulus is supplied, read bitmap
         bmp = wx.Bitmap(os.path.join(rc, fName + '%i.png' % self.iconSize),
                         wx.BITMAP_TYPE_PNG)
     elif isinstance(fName, tuple) and len(fName) == 2:
         # If two are supplied, create combined bitmap
         bmp = combineImageEmblem(os.path.join(
             rc, fName[0] + '%i.png' % self.iconSize),
                                  os.path.join(rc, fName[1] + '16.png'),
                                  pos='bottom_right')
     else:
         return
     # Create tool object
     if 'phoenix' in wx.PlatformInfo:
         item = self.AddTool(
             wx.ID_ANY,
             _translate(label + " [%s]") % self.keys[shortcut], bmp,
             _translate(tooltip))
     else:
         item = self.AddSimpleTool(
             wx.ID_ANY, bmp,
             _translate(label + " [%s]") % self.keys[shortcut],
             _translate(tooltip))
     # Bind function
     self.Bind(wx.EVT_TOOL, func, item)
     return item