""" Get text from and put text on the clipboard. """ Import wx Class MyFrame (wx. Frame ): Def _ init _ (self ): Wx. Frame. _ init _ (self, None, title = 'accessing the clipboard', size = (400,300 )) # Components Self. panel = wx. Panel (self) Self. text = wx. TextCtrl (self. panel, pos = (10, 10), size = (370,220 )) Self. copy = wx. Button (self. panel, wx. ID_ANY, label = 'copy', pos = (10,240 )) Self. paste = wx. Button (self. panel, wx. ID_ANY, label = 'paste ', pos = (100,240 )) # Event bindings. Self. Bind (wx. EVT_BUTTON, self. OnCopy, self. copy) Self. Bind (wx. EVT_BUTTON, self. OnPaste, self. paste) Def OnCopy (self, event ): Text_obj = wx. TextDataObject () Text_obj.SetText (self. text. GetValue ()) If wx. th1_board. IsOpened () or wx. th1_board. Open (): Wx. TheClipboard. SetData (text_obj) Wx. TheClipboard. Close () Def OnPaste (self, event ): Text_obj = wx. TextDataObject () If wx. th1_board. IsOpened () or wx. th1_board. Open (): If wx. TheClipboard. GetData (text_obj ): Self. text. SetValue (text_obj.GetText ()) Wx. TheClipboard. Close () App = wx. App (False) Frame = MyFrame () Frame. Show (True) App. MainLoop () |