wxPython CaptureMouse() in wx.StaticText

wxPython CaptureMouse() in wx.StaticText

Python提供了 wxpython包 ,它允许我们创建高功能的图形用户界面。它是Python的跨平台GUI工具包,Phoenix版本是改进的下一代wxPython,它主要关注速度、可维护性和可扩展性。

在这篇文章中,我们将学习与wxPython的 wx.StaticText 类相关的 CaptureMouse()方法。 CaptureMouse()方法在StaticText上将鼠标指针变成加载模式。 CaptureMouse()函数不需要参数。

语法: wx.StaticText.CaptureMouse(self)

参数: CaptureMouse()方法不需要参数。

示例:

# importing wx library
import wx
 
# create an Example class
class Example(wx.Frame):
   
    # constructor
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
         
        # method calling
        self.InitUI()
     
    # method for user interface creation
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
 
        # create parent panel
        self.pnl = wx.Panel(self)
 
        # create static text at point (20,20)
        self.st = wx.StaticText(self.pnl, id = 1,
                                label = "StaticText",
                                pos = (20,20))
 
        # capture mouse on static text
        self.st.CaptureMouse()
 
        self.SetSize((350, 250))
        self.SetTitle('wx.Button')
        self.Centre()
 
# main function
def main():
  # create an App object
  app = wx.App()
   
  # create an Example object
  ex = Example(None)
  ex.Show()
   
  # running a app
  app.MainLoop()
 
# Driver code
if __name__ == '__main__':
   
  # main function call
  main()

输出:

wxPython - CaptureMouse() in wx.StaticText

捕获鼠标输出

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程