# 取得剪贴板并确保其为打开状态 text_obj = wx.TextDataObject() wx.TheClipboard.Open() if wx.TheClipboard.IsOpened() or wx.TheClipboard.Open(): # do something... wx.TheClipboard.Close()
if wx.TheClipboard.GetData(text_obj): text = text_obj.GetText()
text_obj.SetText(‘要写入的值') wx.TheClipboard.SetData(text_obj)
"""
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.TheClipboard.IsOpened() or wx.TheClipboard.Open():
wx.TheClipboard.SetData(text_obj)
wx.TheClipboard.Close()
def OnPaste(self, event):
text_obj = wx.TextDataObject()
if wx.TheClipboard.IsOpened() or wx.TheClipboard.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()
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有