wxpython wx.TextCtrl返回鼠标选中的字符串

import wx  
  
class ButtonFrame(wx.Frame):  
    def __init__(self):  
        wx.Frame.__init__(self, None, -1, 'Button Example',   
                size=(300, 300))  
        panel = wx.Panel(self, -1)  
        self.button = wx.Button(panel, -1, "Hello", pos=(50, 20))  
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)  
        self.button.SetDefault()  
        self.text = wx.TextCtrl(panel, wx.ID_ANY,pos=(0,140), size =(200,200 ), value="1234567890qwertyu",style = wx.TE_RICH|wx.TE_MULTILINE)
        self.text.Bind(wx.EVT_LEFT_UP, self.leftUP)
  
    def OnClick(self, event):  
        self.button.SetLabel("Clicked") 
        
    def leftUP(self,event):
        print(self.text.GetStringSelection())
          
if __name__ == '__main__':  
    app = wx.PySimpleApp()  
    frame = ButtonFrame()  
    frame.Show()  
    app.MainLoop()  

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_33595571/article/details/86500649
今日推荐