本文整理汇总了Python中wx.TextDataObject方法的典型用法代码示例。如果您正苦于以下问题:Python wx.TextDataObject方法的具体用法?Python wx.TextDataObject怎么用?Python wx.TextDataObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.TextDataObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _paste_from_clipboard
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def _paste_from_clipboard(self):
"""Paste the content of the clipboard to the self._url_list widget.
It also adds a new line at the end of the data if not exist.
"""
if not wx.TheClipboard.IsOpened():
if wx.TheClipboard.Open():
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)):
data = wx.TextDataObject()
wx.TheClipboard.GetData(data)
data = data.GetText()
if data[-1] != '\n':
data += '\n'
self._url_list.WriteText(data)
wx.TheClipboard.Close()
示例2: enter_torrent_url
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def enter_torrent_url(self, widget):
s = ''
if wx.TheClipboard.Open():
do = wx.TextDataObject()
if wx.TheClipboard.GetData(do):
t = do.GetText()
t = t.strip()
if "://" in t or os.path.sep in t or (os.path.altsep and os.path.altsep in t):
s = t
wx.TheClipboard.Close()
d = wx.TextEntryDialog(parent=self.main_window,
message=_("Enter the URL of a torrent file to open:"),
caption=_("Enter torrent URL"),
defaultValue = s,
style=wx.OK|wx.CANCEL,
)
if d.ShowModal() == wx.ID_OK:
path = d.GetValue()
df = self.open_torrent_arg_with_callbacks(path)
示例3: get_data_object
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def get_data_object(widget):
data = dump_widget(widget)
# make a data object
if widget.IS_SIZER:
do = wx.CustomDataObject(sizer_data_format)
elif widget.WX_CLASS=="wxMenuBar":
do = wx.CustomDataObject(menubar_data_format)
elif widget.WX_CLASS=="wxToolBar":
do = wx.CustomDataObject(toolbar_data_format)
elif widget.IS_TOPLEVEL:
do = wx.CustomDataObject(window_data_format)
else:
do = wx.CustomDataObject(widget_data_format)
do.SetData(data)
cdo = wx.DataObjectComposite()
cdo.Add(do)
if widget.name: cdo.Add(wx.TextDataObject(widget.name), True) # the widget name as text, preferred
return cdo
示例4: _to_clipboard
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def _to_clipboard(self, selection):
# place selection on clipboard
selected_rows, selected_cols = selection
all_values = self.editing_values or self.value
text = []
for r in selected_rows:
if r>=len(all_values): continue
row = all_values[r]
if row is not None:
text.append( "\t".join( [str(row[c]) for c in selected_cols] ) )
else:
text.append( "\t".join( [""]*len(selected_cols) ) )
text = "\n".join(text)
if wx.TheClipboard.Open():
wx.TheClipboard.SetData(wx.TextDataObject(text))
wx.TheClipboard.Close()
示例5: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def __init__(self, win, text):
wx.DropSource.__init__(self, win)
# create our own data format and use it in a
# custom data object
customData = wx.CustomDataObject("DragItem")
customData.SetData(text)
# Now make a data object for the text and also a composite
# data object holding both of the others.
textData = wx.TextDataObject(text.decode("UTF-8"))
data = wx.DataObjectComposite()
data.Add(textData)
data.Add(customData)
# We need to hold a reference to our data object, instead it could
# be garbage collected
self.data = data
# And finally, create the drop source and begin the drag
# and drop operation
self.SetData(data)
示例6: Do
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def Do(self, selection):
if not selection.CanDelete() or not selection.AskDelete():
return
def ProcessInActionThread():
self.data = selection.GetFullXml()
self.treePosition = eg.TreePosition(selection)
data = selection.GetXmlString()
selection.Delete()
return data.decode("utf-8")
data = eg.actionThread.Func(ProcessInActionThread)()
self.document.AppendUndoHandler(self)
if data and wx.TheClipboard.Open():
wx.TheClipboard.SetData(wx.TextDataObject(data))
wx.TheClipboard.Close()
示例7: Do
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def Do(self, selection):
self.items = []
if not wx.TheClipboard.Open():
eg.PrintError("Can't open clipboard.")
return
try:
dataObj = wx.CustomDataObject("DragEventItem")
if wx.TheClipboard.GetData(dataObj):
self.PasteEvent(selection, dataObj)
return
dataObj = wx.TextDataObject()
if not wx.TheClipboard.GetData(dataObj):
return
result = eg.actionThread.Func(self.PasteXml)(
selection,
dataObj.GetText()
)
if result:
self.document.AppendUndoHandler(self)
finally:
wx.TheClipboard.Close()
示例8: OnCmdPython
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def OnCmdPython(self):
data = self.GetXmlString()
if data and wx.TheClipboard.Open():
ix1 = data.find("<Action")
ix1 = 3 + data.find(">\r\n ", ix1)
ix2 = data.find("\r\n </Action>")
data = data[ix1:ix2].strip()
if data[:24] == "EventGhost.PythonScript(":
#data = data[24:-1]
data = data[26:-2].replace('\\n', '\n').rstrip() + '\n'
elif data[:25] == "EventGhost.PythonCommand(":
#data = data[25:-1]
data = data[27:-2].replace('\\n', '\n').strip()
else:
data = "eg.plugins." + data
wx.TheClipboard.SetData(wx.TextDataObject(data))
wx.TheClipboard.Close()
示例9: __call__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def __call__(self, text):
self.clipboardString = eg.ParseString(text)
def Do():
if wx.TheClipboard.Open():
tdata = wx.TextDataObject(self.clipboardString)
wx.TheClipboard.Clear()
wx.TheClipboard.AddData(tdata)
wx.TheClipboard.Close()
wx.TheClipboard.Flush()
else:
self.PrintError(self.text.error)
# We call the hot stuff in the main thread. Otherwise we get
# a "CoInitialize not called" error form wxPython (even though we
# surely have called CoInitialize for this thread.
eg.CallWait(Do)
示例10: OnProcessVariablesGridCellLeftClick
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def OnProcessVariablesGridCellLeftClick(self, event):
row = event.GetRow()
if event.GetCol() == 0:
var_name = self.ProcessVariablesTable.GetValueByName(row, "Name")
var_type = self.Controler.GetSlaveVariableDataType(
*self.ProcessVariablesTable.GetValueByName(row, "ReadFrom"))
data_size = self.Controler.GetSizeOfType(var_type)
number = self.ProcessVariablesTable.GetValueByName(row, "Number")
location = "%%M%s" % data_size + \
".".join(map(str, self.Controler.GetCurrentLocation() + (number,)))
data = wx.TextDataObject(str((location, "location", var_type, var_name, "")))
dragSource = wx.DropSource(self.ProcessVariablesGrid)
dragSource.SetData(data)
dragSource.DoDragDrop()
event.Skip()
示例11: OnTreeBeginDrag
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def OnTreeBeginDrag(self, event):
"""
Called when a drag is started in tree
@param event: wx.TreeEvent
"""
selected_item = event.GetItem()
item_pydata = self.Tree.GetPyData(selected_item)
# Item dragged is a block
if item_pydata is not None and item_pydata["type"] == BLOCK:
# Start a drag'n drop
data = wx.TextDataObject(str(
(self.Tree.GetItemText(selected_item),
item_pydata["block_type"],
"",
item_pydata["inputs"])))
dragSource = wx.DropSource(self.Tree)
dragSource.SetData(data)
dragSource.DoDragDrop()
示例12: GetCopyBuffer
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def GetCopyBuffer(self, primary_selection=False):
data = None
if primary_selection and wx.Platform == '__WXMSW__':
return data
else:
wx.TheClipboard.UsePrimarySelection(primary_selection)
if not wx.TheClipboard.IsOpened():
dataobj = wx.TextDataObject()
if wx.TheClipboard.Open():
success = False
try:
success = wx.TheClipboard.GetData(dataobj)
except wx._core.PyAssertionError:
pass
wx.TheClipboard.Close()
if success:
data = dataobj.GetText()
return data
示例13: OnCopySystem
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def OnCopySystem(self, formatted = False):
cd = self.sp.getSelectedAsCD(False)
if not cd:
return
tmpSp = screenplay.Screenplay(cfgGl)
tmpSp.lines = cd.lines
if formatted:
# have to call paginate, otherwise generateText will not
# process all the text
tmpSp.paginate()
s = tmpSp.generateText(False)
else:
s = util.String()
for ln in tmpSp.lines:
txt = ln.text
if tmpSp.cfg.getType(ln.lt).export.isCaps:
txt = util.upper(txt)
s += txt + config.lb2str(ln.lb)
s = str(s).replace("\n", os.linesep)
if wx.TheClipboard.Open():
wx.TheClipboard.UsePrimarySelection(False)
wx.TheClipboard.Clear()
wx.TheClipboard.AddData(wx.TextDataObject(s))
wx.TheClipboard.Flush()
wx.TheClipboard.Close()
示例14: OnPasteSystemCb
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def OnPasteSystemCb(self):
s = ""
if wx.TheClipboard.Open():
wx.TheClipboard.UsePrimarySelection(False)
df = wx.DataFormat(wx.DF_TEXT)
if wx.TheClipboard.IsSupported(df):
data = wx.TextDataObject()
wx.TheClipboard.GetData(data)
s = util.cleanInput(data.GetText())
wx.TheClipboard.Close()
s = util.fixNL(s)
if len(s) == 0:
return
inLines = s.split("\n")
# shouldn't be possible, but...
if len(inLines) == 0:
return
lines = []
for s in inLines:
if s:
lines.append(screenplay.Line(screenplay.LB_LAST,
screenplay.ACTION, s))
self.OnPaste(lines)
示例15: on_copy
# 需要导入模块: import wx [as 别名]
# 或者: from wx import TextDataObject [as 别名]
def on_copy(self, event):
"""Copy the donation address to the clipboard."""
if wx.TheClipboard.Open():
data = wx.TextDataObject()
data.SetText(DONATION_ADDRESS)
wx.TheClipboard.SetData(data)
wx.TheClipboard.Close()