📌  相关文章
📜  wxPython – 鼠标悬停在按钮上时更改光标

📅  最后修改于: 2022-05-13 01:55:28.152000             🧑  作者: Mango

wxPython – 鼠标悬停在按钮上时更改光标

在本文中,我们将学习如何在光标悬停在框架中的按钮上时更改光标。我们需要按照以下步骤进行操作。

代码示例:

Python3
import wx
 
 
class Example(wx.Frame):
 
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
        self.InitUI()
 
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.pnl = wx.Panel(self)
 
 
        # CREATE BUTTON AT POINT (20, 20)
        self.st = wx.Button(self.pnl, id = 1, label ="Button", pos =(20, 20),
                                size = wx.DefaultSize,  name ="button")
        # CREATE CURSOR OBJECT
        c = wx.Cursor(wx.Image('pointer.png'))
        # SET c AS CURSOR
        self.st.SetCursor(c)
        self.SetSize((350, 250))
        self.SetTitle('wx.Button')
        self.Centre()
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


输出窗口: