最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python中wx將圖標顯示在右下角的腳本代碼

 更新時間:2013年03月08日 12:11:08   作者:  
python中wx將圖標顯示在右下腳的代碼,此程序摘自wxdemo,不夠完善,只供參考用

復制代碼 代碼如下:

import wx
import images
class DemoTaskBarIcon(wx.TaskBarIcon):
    TBMENU_RESTORE = wx.NewId()
    TBMENU_CLOSE   = wx.NewId()
    TBMENU_CHANGE  = wx.NewId()
    TBMENU_REMOVE  = wx.NewId()

    def __init__(self, frame):
        wx.TaskBarIcon.__init__(self)
        self.frame = frame

        # Set the image
        icon = self.MakeIcon(images.getWXPdemoImage())
        self.SetIcon(icon, "wxPython Demo")
        self.imgidx = 1

        # bind some events
        self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnTaskBarActivate)
        self.Bind(wx.EVT_MENU, self.OnTaskBarActivate, id=self.TBMENU_RESTORE)
        self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=self.TBMENU_CLOSE)
        self.Bind(wx.EVT_MENU, self.OnTaskBarChange, id=self.TBMENU_CHANGE)
        self.Bind(wx.EVT_MENU, self.OnTaskBarRemove, id=self.TBMENU_REMOVE)


    def CreatePopupMenu(self):
        """
        This method is called by the base class when it needs to popup
        the menu for the default EVT_RIGHT_DOWN event.  Just create
        the menu how you want it and return it from this function,
        the base class takes care of the rest.
        """
        menu = wx.Menu()
        menu.Append(self.TBMENU_RESTORE, "Restore wxPython Demo")
        menu.Append(self.TBMENU_CLOSE,   "Close wxPython Demo")
        menu.AppendSeparator()
        menu.Append(self.TBMENU_CHANGE, "Change the TB Icon")
        menu.Append(self.TBMENU_REMOVE, "Remove the TB Icon")
        return menu


    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
   

    def OnTaskBarActivate(self, evt):
        if self.frame.IsIconized():
            self.frame.Iconize(False)
        if not self.frame.IsShown():
            self.frame.Show(True)
        self.frame.Raise()


    def OnTaskBarClose(self, evt):
        self.frame.Close()


    def OnTaskBarChange(self, evt):
        names = [ "WXPdemo", "Mondrian", "Pencil", "Carrot" ]                 
        name = names[self.imgidx]

        getFunc = getattr(images, "get%sImage" % name)
        self.imgidx += 1
        if self.imgidx >= len(names):
            self.imgidx = 0

        icon = self.MakeIcon(getFunc())
        self.SetIcon(icon, "This is a new icon: " + name)


    def OnTaskBarRemove(self, evt):
        self.RemoveIcon()


class MyFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, -1, "My Frame", size=(300, 300))
        panel = wx.Panel(self, -1)
        panel.Bind(wx.EVT_MOTION,  self.OnMove)
        wx.StaticText(panel, -1, "Pos:", pos=(10, 12))
        self.posCtrl = wx.TextCtrl(panel, -1, "", pos=(40, 10))

     try:
            self.tbicon = DemoTaskBarIcon(self)
        except:
            self.tbicon = None

        #wx.CallAfter(self.ShowTip)

        #self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        #self.Bind(wx.EVT_ICONIZE, self.OnIconfiy)
    def OnCloseWindow(self, event):
        self.dying = True
        self.demoPage = None
        self.codePage = None
        self.mainmenu = None
        if self.tbicon is not None:
            self.tbicon.Destroy()
        self.Destroy()
    def OnIconfiy(self, evt):
        wx.LogMessage("OnIconfiy: %s" % evt.Iconized())
        evt.Skip()
    def OnMove(self, event):
        pos = event.GetPosition()
        self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MyFrame()
    frame.Show(True)
    app.MainLoop()

相關文章

  • 已安裝tensorflow-gpu,但keras無法使用GPU加速的解決

    已安裝tensorflow-gpu,但keras無法使用GPU加速的解決

    今天小編就為大家分享一篇已安裝tensorflow-gpu,但keras無法使用GPU加速的解決,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-02-02
  • python中的列表推導淺析

    python中的列表推導淺析

    這篇文章主要介紹了python中的列表推導,需要的朋友可以參考下
    2014-04-04
  • Python中Numpy的深拷貝和淺拷貝

    Python中Numpy的深拷貝和淺拷貝

    這篇文章主要介紹了Python中Numpy的深拷貝和淺拷貝,通過講解Python中對Numpy數(shù)組操作的淺拷貝和深拷貝的概念和背后的原理展開全文,需要的小伙伴可以參考一下
    2022-05-05
  • Python學習筆記之錯誤和異常及訪問錯誤消息詳解

    Python學習筆記之錯誤和異常及訪問錯誤消息詳解

    這篇文章主要介紹了Python學習筆記之錯誤和異常及訪問錯誤消息,結合實例形式分析了Python錯誤和異常及訪問錯誤消息try...except語句相關使用技巧,需要的朋友可以參考下
    2019-08-08
  • python?列表的查詢操作和切片

    python?列表的查詢操作和切片

    這篇文章主要介紹了python?列表的查詢操作和切片,列表是python內(nèi)置的數(shù)據(jù)結構,相當于數(shù)組,列表中所有數(shù)據(jù)都是按順序有序排列,列表屬于序列類型,接下來一起學習下面的文章內(nèi)容吧
    2022-01-01
  • 一文秒懂pandas中iloc()函數(shù)

    一文秒懂pandas中iloc()函數(shù)

    iloc[]函數(shù)屬于pandas庫全稱為index?location,即對數(shù)據(jù)進行位置索引,從而在數(shù)據(jù)表中提取出相應的數(shù)據(jù),本文通過實例代碼介紹pandas中iloc()函數(shù),感興趣的朋友一起看看吧
    2023-04-04
  • 可能是史上最細的python中import詳解

    可能是史上最細的python中import詳解

    import在python中的意思是用來調(diào)用模塊的,下面這篇文章主要給大家介紹了關于python中import詳解的相關資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2022-02-02
  • 如何在Python中妥善使用進度條詳解

    如何在Python中妥善使用進度條詳解

    python的進度條有很多第三方庫,有些做的比較炫酷,下面這篇文章主要給大家介紹了關于如何在Python中妥善使用進度條的相關資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下
    2022-04-04
  • 一文帶你掌握Python中enumerate函數(shù)和for循環(huán)的對比

    一文帶你掌握Python中enumerate函數(shù)和for循環(huán)的對比

    在Python編程中,循環(huán)是一項常見的任務,而for循環(huán)是最常見的一種,然而,Python提供了enumerate函數(shù),它允許在迭代過程中訪問元素的同時獲得它們的索引,下面我們就來學習一下二者的區(qū)別吧
    2023-11-11
  • 用于統(tǒng)計項目中代碼總行數(shù)的Python腳本分享

    用于統(tǒng)計項目中代碼總行數(shù)的Python腳本分享

    這篇文章主要介紹了用于統(tǒng)計項目中代碼總行數(shù)的Python腳本分享,本文直接給出實現(xiàn)代碼,需要的朋友可以參考下
    2015-04-04

最新評論

广昌县| 依安县| 乌鲁木齐县| 津市市| 都江堰市| 恭城| 斗六市| 长阳| 云龙县| 兴隆县| 琼结县| 禹州市| 肥东县| 蓝田县| 信宜市| 太和县| 凤翔县| 于都县| 武川县| 年辖:市辖区| 通渭县| 全州县| 启东市| 仲巴县| 凤台县| 中卫市| 七台河市| 灯塔市| 邓州市| 连平县| 青河县| 抚松县| 松滋市| 堆龙德庆县| 逊克县| 贵溪市| 眉山市| 肃南| 清水河县| 洪湖市| 南开区|