Python wx 模块,IconFromBitmap() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用wx.IconFromBitmap()

项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def __init__(self):
        '''
        @summary: Constructor
        @param config_dict: The build configuration, if present
        @param load_config: Handle to a config loader method/object
        '''
        self.language = DEFAULT_LANGUAGE
        self.__builder = None
        self.config_file_path = None

        # Init super - MainFrame
        MainFrame.__init__( self, parent=None )
        self.console = Console(self.ConsoleTextCtrl)
        self.StatusBar.SetStatusText("Ready...")
        self.SetIcon(wx.IconFromBitmap(wx.Bitmap("ExeBuilder\\static\\builder_logo.bmp", wx.BITMAP_TYPE_ANY)))

        # Update GUI Visuals
        self.update_gui_visuals()

        # Set initial event handlers
        self.set_events()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def MakeIcon(self, img):
                """
                The various platforms have different requirements for the
                icon size...
                """
                if "wxMSW" in wx.PlatformInfo:
                    img = img.Scale(16, 16)
                elif "wxGTK" in wx.PlatformInfo:
                    img = img.Scale(22, 22)
                # wxMac can be any size upto 128x128, so leave the source img alone....
                icon = wx.IconFromBitmap(img.ConvertToBitmap())
                return icon
项目:Janet    作者:nosmokingbandit    | 项目源码 | 文件源码
def setup_icon(self):
        icon_file = os.path.join(core.BASE_DIR, 'janet.png')
        if os.path.exists(icon_file):
            icon = wx.IconFromBitmap(wx.Bitmap(icon_file, wx.BITMAP_TYPE_PNG))
            self.SetIcon(icon)
项目:bittray    作者:nkuttler    | 项目源码 | 文件源码
def get_icon(self, text):
        """
        Return a wx icon from a file like object containing the image
        with text.

        TODO: transparency support
        """
        background = self.conf.get_color('Look', 'background')
        foreground = self.conf.get_color('Look', 'color')
        font = ImageFont.truetype(
            self.conf.get_font_path(),
            self.conf.get_int('Look', 'size'),
        )
        if font is None:
            logger.critical("Font could not be looked up. Try setting "
                            "font_path in the configuration file to the full "
                            "path to a truetype font.")
        mask = Image.new('RGB', (WIDTH, HEIGHT), background)
        draw = ImageDraw.Draw(mask)
        draw.text(
            background,
            text,
            font=font,
            fill=foreground,
        )
        mask = self.trim(mask)
        buf = io.StringIO()
        mask.save(buf, 'png')
        buf.seek(0)
        icon = wx.IconFromBitmap(
            wx.BitmapFromImage(
                wx.ImageFromStream(
                    buf,
                    wx.BITMAP_TYPE_PNG
                )
            )
        )
        return icon
项目:wpkg-gp-client    作者:sonicnkt    | 项目源码 | 文件源码
def __init__(self, trayicon, tooltip):
        super(TaskBarIcon, self).__init__()
        self.show_no_updates = False

        # Set trayicon and tooltip
        icon = wx.IconFromBitmap(wx.Bitmap(trayicon))
        self.SetIcon(icon, tooltip)

        self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.on_upgrade)
        self.Bind(wx.EVT_TASKBAR_BALLOON_CLICK, self.on_bubble)
        self.upd_error_count = 0
        self.checking_updates = False
        self.updates_available = False
        self.shutdown_scheduled = False
        self.reboot_scheduled = False
        self.bootup_time = getBootUp()
        if update_interval and update_method:
            self.timer = wx.Timer(self)
            self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
            self.timer.Start(update_interval)
            if update_startup:
                self.on_timer(None)
        if check_bootup_log:
            last_check = ReadLastSyncTime()
            now = datetime.datetime.now()
            if (self.bootup_time + datetime.timedelta(hours=1) > now) and \
               (self.bootup_time + datetime.timedelta(minutes=30) > last_check):
                log, errorlog, reboot = check_eventlog(self.bootup_time)
                if errorlog:
                    error_str = _(u"Update error detected\n"
                                  u"during system start up.")
                    self.ShowBalloon(title=_(u'WPKG Error'), text=error_str, msec=20*1000, flags=wx.ICON_ERROR)
                    title = _(u"System start error")
                    dlg = ViewLogDialog(title=title,log=errorlog)
                    dlg.ShowModal()
        if check_last_upgrade:
            # Check when WPKG-GP sucessfully synced the last time
            # Inform USER that he should upgrade the System
            last_sync = ReadLastSyncTime()
            if last_sync:
                if last_sync < (datetime.datetime.now() - datetime.timedelta(days=last_upgrade_interval)):
                    dlg_str = _(u"System should be updated!\n\n"
                                u"System wasn't updated in over {} days.").format(str(last_upgrade_interval))
                    dlg = wx.MessageDialog(None, dlg_str, _(u"Attention!"), wx.OK | wx.ICON_EXCLAMATION)
                    dlg.ShowModal()
                    self.on_upgrade(None)