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()  

wxpython wx.TextCtrl返回鼠标选中的字符串_第1张图片

你可能感兴趣的:(代码,python,wxpython)