Python wx 模块,EVT_ENTER_WINDOW 实例源码

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

项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def BindEvents(self):
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None)
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnButtonDown)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnButtonDown)
        self.Bind(wx.EVT_MIDDLE_DOWN, self.OnButtonDown)
        self.Bind(wx.EVT_RIGHT_UP, self.OnButtonUp)
        self.Bind(wx.EVT_LEFT_UP, self.OnButtonUp)
        self.Bind(wx.EVT_MIDDLE_UP, self.OnButtonUp)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
        self.Bind(wx.EVT_MOTION, self.OnMotion)
        self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter)
        self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
        self.Bind(wx.EVT_CHAR, self.OnKeyDown)
        self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
        if wx.Platform == "__WXGTK__":
            # wxGTK requires that the window be created before you can
            # set its shape, so delay the call to SetWindowShape until
            # this event.
            self.Bind(wx.EVT_WINDOW_CREATE, self.OnWindowCreate)
        else:
            # On wxMSW and wxMac the window has already been created.
            self.Bind(wx.EVT_SIZE, self.OnSize)
        if _useCapture and hasattr(wx, 'EVT_MOUSE_CAPTURE_LOST'):
            self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, window, items=[]):
        """
        Constructor
        @param parent: Parent wx.Window of DebugVariableText
        @param window: Reference to the Debug Variable Panel
        @param items: List of DebugVariableItem displayed by Viewer
        """
        DebugVariableViewer.__init__(self, window, items)

        wx.Panel.__init__(self, parent)
        # Set panel background colour
        self.SetBackgroundColour(wx.WHITE)
        # Define panel drop target
        self.SetDropTarget(DebugVariableTextDropTarget(self, window))

        # Bind events
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
        self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter)
        self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
        self.Bind(wx.EVT_SIZE, self.OnResize)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_PAINT, self.OnPaint)

        # Define panel min size for parent sizer layout
        self.SetMinSize(wx.Size(0, 25))

        # Add buttons to Viewer
        for bitmap, callback in [("force", self.OnForceButton),
                                 ("release", self.OnReleaseButton),
                                 ("delete_graph", self.OnCloseButton)]:
            self.Buttons.append(GraphButton(0, 0, bitmap, callback))
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GenerateMethodButtonSizer(self):
        normal_bt_font = wx.Font(faces["size"] / 3,    wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"])
        mouseover_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True)

        msizer = wx.BoxSizer(wx.HORIZONTAL)

        for confnode_method in self.Controler.ConfNodeMethods:
            if "method" in confnode_method and confnode_method.get("shown", True):
                button = GenBitmapTextButton(self.Editor,
                                             bitmap=GetBitmap(confnode_method.get("bitmap", "Unknown")),
                                             label=confnode_method["name"],
                                             style=wx.NO_BORDER)
                button.SetFont(normal_bt_font)
                button.SetToolTipString(confnode_method["tooltip"])
                if confnode_method.get("push", False):
                    button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True))
                else:
                    button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), button)
                # a fancy underline on mouseover

                def setFontStyle(b, s):
                    def fn(event):
                        b.SetFont(s)
                        b.Refresh()
                        event.Skip()
                    return fn
                button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font))
                button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font))
                # hack to force size to mini
                if not confnode_method.get("enabled", True):
                    button.Disable()
                msizer.AddWindow(button, flag=wx.ALIGN_CENTER)
        return msizer
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def add_tools(bar, datas, curids=[]):
    ##! TODO: 
    ## datas? dirpath tree to generate menus/toolsbar?
    ## curids? ??
    box = bar.GetSizer() 
    if curids!=None:
        for curid in curids:
            bar.RemoveChild(curid)
            box.Hide(curid)
            box.Detach(curid)
    if curids!=None:
        del curids[:]
    for data in datas:
        btn = wx.BitmapButton(bar, wx.ID_ANY, 
                              make_bitmap(wx.Bitmap(data[1])), 
                              wx.DefaultPosition, (32,32), 
                              wx.BU_AUTODRAW|wx.RAISED_BORDER )        
        if curids!=None:
            curids.append(btn)        
        if curids==None:
            box.Add(btn)
        else: 
            box.Insert(len(box.GetChildren())-2, btn)

        btn.Bind( wx.EVT_LEFT_DOWN, lambda x, p=data[0]:f(p(), x))
        btn.Bind( wx.EVT_ENTER_WINDOW, 
                  lambda x, p='"{}" Tool'.format(data[0].title): set_info(p))        
        if not isinstance(data[0], Macros) and issubclass(data[0], Tool):
            btn.Bind(wx.EVT_LEFT_DCLICK, lambda x, p=data[0]:p().show())
        btn.SetDefault()
    box.Layout()
    bar.Refresh()
    if curids==None:
        sp = wx.StaticLine( bar, wx.ID_ANY, 
                            wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL )
        box.Add( sp, 0, wx.ALL|wx.EXPAND, 2 )
        box.AddStretchSpacer(1)