zoukankan      html  css  js  c++  java
  • wxpyhon 鼠标事件例子

    #encoding:utf-8
    import wx
    import wx.aui
    class MyFrame(wx.Frame):
        def __init__(self, *args, **kwargs):
    
            wx.Frame.__init__(self, *args, **kwargs)
            self.mgr = wx.aui.AuiManager(self)
    
            leftpanel = wx.Panel(self, -1, size=(200, 150))
            rightpanel = wx.Panel(self, -1, size=(200, 150))
            bottompanel = wx.Panel(self, -1, size=(200, 150))
            bottompane2 = wx.Panel(self, -1, size=(200, 150))
            wangjiAN = wx.TextCtrl(rightpanel,style=wx.TE_RICH|wx.TE_AUTO_URL)
            btn = wx.Button(leftpanel)
            self.mgr.AddPane(bottompanel, wx.aui.AuiPaneInfo().Center().MaximizeButton(True).Layer(2))
            self.mgr.AddPane(leftpanel, wx.aui.AuiPaneInfo().Caption("hello2").Bottom().Layer(4))
            self.mgr.AddPane(rightpanel, wx.aui.AuiPaneInfo().Left().MaximizeButton(True).Layer(5))
            self.mgr.AddPane(bottompane2, wx.aui.AuiPaneInfo().Caption("hello1").Bottom().Layer(0))
            wangjiAN.Bind(wx.EVT_LEFT_DOWN, self.fun) #使用控件.Bind才能激活鼠标事件,self.Bind(wx.EVT,self.fun, wangjiAN)这个方法无法激活鼠标事件,谁响应鼠标事件谁bind
            wangjiAN.Bind(wx.EVT_LEFT_UP, self.fun)
            self.Bind(wx.EVT_BUTTON, self.fun)
            self.mgr.Update()
        def fun(self, event):
            print "**********************"
    
    class MyApp(wx.App):
        def OnInit(self):
    
            frame = MyFrame(None, -1, 'ax.aui')
            frame.Show()
            self.SetTopWindow(frame)
            return 1
    
    app = MyApp()
    app.MainLoop()

    EVT_LEFT_DOWN 鼠标左键按下。
    EVT_LEFT_UP 鼠标左键抬起。
    EVT_LEFT_DCLICK 鼠标左键双击

    控件.Bind(WX.EVENT, FUN)

  • 相关阅读:
    linux cut的用法
    删除表的语句(drop truncate delete)
    mysql中的模糊查询
    linux之软连接 硬链接 link ln
    使用robot合并Robot Framework测试报告
    Python中的字典
    python logger 动态设置日志名
    K8S(Kubernetes)学习笔记
    [转]CURL常用命令
    python网站目录扫描器2.0版
  • 原文地址:https://www.cnblogs.com/whwywzhj/p/6115890.html
Copyright © 2011-2022 走看看