本文整理汇总了Python中wx.DropSource方法的典型用法代码示例。如果您正苦于以下问题:Python wx.DropSource方法的具体用法?Python wx.DropSource怎么用?Python wx.DropSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.DropSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _startDrag
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def _startDrag(self, e):
""" Put together a data object for drag-and-drop _from_ this list. """
# Create the data object: Just use plain text.
data = wx.PyTextDataObject()
idx = e.GetIndex()
text = self.GetItem(idx).GetText()
data.SetText(text)
# Create drop source and begin drag-and-drop.
dropSource = wx.DropSource(self)
dropSource.SetData(data)
res = dropSource.DoDragDrop(flags=wx.Drag_DefaultMove)
# If move, we want to remove the item from this list.
if res == wx.DragMove:
# It's possible we are dragging/dropping from this list to this list. In which case, the
# index we are removing may have changed...
# Find correct position.
pos = self.FindItem(idx, text)
self.DeleteItem(pos)
示例2: begin_drag
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def begin_drag(window, widget):
do = get_data_object(widget)
set_drag_source(widget)
if widget.IS_SIZER:
msg = "Move sizer to empty or populated slot to insert, to a sizer to append; hold Ctrl to copy"
elif widget.IS_TOPLEVEL:
msg = "Move window to application object; hold Ctrl to copy"
elif widget.WX_CLASS in ("wxToolBar", "wxMenuBar"):
msg = "Move tool or menu bar to application object or frame; hold Ctrl to copy"
else:
msg = "Move control to empty or populated slot to insert, to a sizer to append; hold Ctrl to copy"
common.main.user_message( msg )
drop_source = wx.DropSource(window)
drop_source.SetData(do)
drop_source.DoDragDrop(True)
set_drag_source(None)
示例3: OnStartDrag
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnStartDrag(self, event):
idx = event.GetIndex()
itemData = self.GetItemData(idx)
if itemData[1] != EVENT_ICON:
return
text = itemData[2]
# create our own data format and use it in a
# custom data object
customData = wx.CustomDataObject(wx.CustomDataFormat("DragItem"))
customData.SetData(text.encode("utf-8"))
# And finally, create the drop source and begin the drag
# and drop operation
dropSource = wx.DropSource(self)
dropSource.SetData(customData)
result = dropSource.DoDragDrop(wx.Drag_AllowMove)
if result == wx.DragMove:
self.Refresh()
示例4: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [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)
示例5: OnBeginDragEvent
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnBeginDragEvent(self, event):
"""
Handles wx.EVT_TREE_BEGIN_DRAG
"""
srcItemId = event.GetItem()
srcNode = self.GetPyData(srcItemId)
if not srcNode.isMoveable:
return
self.SelectItem(srcItemId)
dropTarget = self.dropTarget
dropTarget.srcNode = srcNode
dropTarget.isExternalDrag = False
DropSource(self, srcNode.GetXmlString()).DoDragDrop(wx.Drag_AllowMove)
dropTarget.srcNode = eg.EventItem
dropTarget.isExternalDrag = True
self.ClearInsertMark()
if dropTarget.lastHighlighted is not None:
self.SetItemDropHighlight(dropTarget.lastHighlighted, False)
if dropTarget.whereToDrop is not None:
parentNode, pos = dropTarget.whereToDrop
eg.UndoHandler.MoveTo(self.document).Do(srcNode, parentNode, pos)
示例6: OnProcessVariablesGridCellLeftClick
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [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()
示例7: OnTreeBeginDrag
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [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()
示例8: OnStartDrag
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnStartDrag(self, event):
item = self.tree.GetPyData(event.GetItem())
text = item.info.eventPrefix + "." + item.name
# create our own data format and use it in a
# custom data object
customData = wx.CustomDataObject(wx.CustomDataFormat("DragItem"))
customData.SetData(text.encode("utf-8"))
# And finally, create the drop source and begin the drag
# and drop opperation
dropSource = wx.DropSource(self)
dropSource.SetData(customData)
result = dropSource.DoDragDrop(wx.Drag_DefaultMove)
if result == wx.DragMove:
self.Refresh()
示例9: StartDragNDrop
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def StartDragNDrop(self, data):
data_obj = wx.TextDataObject(str(data))
dragSource = wx.DropSource(self.GetCTRoot().AppFrame)
dragSource.SetData(data_obj)
dragSource.DoDragDrop()
示例10: OnVariablesGridCellLeftClick
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnVariablesGridCellLeftClick(self, event):
if event.GetCol() == 0:
row = event.GetRow()
data_type = self.Table.GetValueByName(row, "Type")
var_name = self.Table.GetValueByName(row, "Name")
data = wx.TextDataObject(str((var_name, "Global", data_type,
self.Controler.GetCurrentLocation())))
dragSource = wx.DropSource(self.VariablesGrid)
dragSource.SetData(data)
dragSource.DoDragDrop()
return
event.Skip()
示例11: OnTreeBeginDrag
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnTreeBeginDrag(self, event):
filepath = self.ManagedDir.GetPath()
if os.path.isfile(filepath):
relative_filepath = filepath.replace(os.path.join(self.Folder, ""), "")
data = wx.TextDataObject(str(("'%s'" % relative_filepath, "Constant")))
dragSource = wx.DropSource(self)
dragSource.SetData(data)
dragSource.DoDragDrop()
示例12: OnLeftDown
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnLeftDown(self, event):
"""
Function called when mouse left button is pressed
@param event: wx.MouseEvent
"""
# Get first item
item = self.ItemsDict.values()[0]
# Calculate item path bounding box
_width, height = self.GetSize()
item_path = item.GetVariable(
self.ParentWindow.GetVariableNameMask())
w, h = self.GetTextExtent(item_path)
# Test if mouse has been pressed in this bounding box. In that case
# start a move drag'n drop of item variable
x, y = event.GetPosition()
item_path_bbox = wx.Rect(20, (height - h) / 2, w, h)
if item_path_bbox.InsideXY(x, y):
self.ShowButtons(False)
data = wx.TextDataObject(str((item.GetVariable(), "debug", "move")))
dragSource = wx.DropSource(self)
dragSource.SetData(data)
dragSource.DoDragDrop()
# In other case handle event normally
else:
event.Skip()
示例13: OnVariablesListLeftDown
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnVariablesListLeftDown(self, event):
if self.InstanceChoice.GetSelection() == -1:
wx.CallAfter(self.ShowInstanceChoicePopup)
else:
instance_path = self.InstanceChoice.GetStringSelection()
item, flags = self.VariablesList.HitTest(event.GetPosition())
if item is not None:
item_infos = self.VariablesList.GetPyData(item)
if item_infos is not None:
item_button = self.VariablesList.IsOverItemRightImage(
item, event.GetPosition())
if item_button is not None:
callback = self.ButtonCallBacks[item_button].leftdown
if callback is not None:
callback(item_infos)
elif (flags & CT.TREE_HITTEST_ONITEMLABEL and
item_infos.var_class in ITEMS_VARIABLE):
self.ParentWindow.EnsureTabVisible(
self.ParentWindow.DebugVariablePanel)
item_path = "%s.%s" % (instance_path, item_infos.name)
data = wx.TextDataObject(str((item_path, "debug")))
dragSource = wx.DropSource(self.VariablesList)
dragSource.SetData(data)
dragSource.DoDragDrop()
event.Skip()
示例14: OnProjectTreeBeginDrag
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnProjectTreeBeginDrag(self, event):
selected_item = (self.SelectedItem
if self.SelectedItem is not None
else event.GetItem())
if selected_item.IsOk() and self.ProjectTree.GetPyData(selected_item)["type"] == ITEM_POU:
block_name = self.ProjectTree.GetItemText(selected_item)
block_type = self.Controler.GetPouType(block_name)
if block_type != "program":
data = wx.TextDataObject(str((block_name, block_type, "")))
dragSource = wx.DropSource(self.ProjectTree)
dragSource.SetData(data)
dragSource.DoDragDrop()
self.ResetSelectedItem()
示例15: OnSubindexGridCellLeftClick
# 需要导入模块: import wx [as 别名]
# 或者: from wx import DropSource [as 别名]
def OnSubindexGridCellLeftClick(self, event):
if not self.ParentWindow.ModeSolo:
col = event.GetCol()
if self.Editable and col == 0:
selected = self.IndexList.GetSelection()
if selected != wx.NOT_FOUND:
index = self.ListIndex[selected]
subindex = event.GetRow()
entry_infos = self.Manager.GetEntryInfos(index)
if not entry_infos["struct"] & OD_MultipleSubindexes or subindex != 0:
subentry_infos = self.Manager.GetSubentryInfos(index, subindex)
typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
if typeinfos:
bus_id = '.'.join(map(str, self.ParentWindow.GetBusId()))
var_name = "%s_%04x_%02x" % (self.Manager.GetCurrentNodeName(), index, subindex)
size = typeinfos["size"]
data = wx.TextDataObject(str(
("%s%s.%d.%d"%(SizeConversion[size], bus_id, index, subindex),
"location",
IECTypeConversion.get(typeinfos["name"]),
var_name, "")))
dragSource = wx.DropSource(self.SubindexGrid)
dragSource.SetData(data)
dragSource.DoDragDrop()
return
elif col == 0:
selected = self.IndexList.GetSelection()
node_id = self.ParentWindow.GetCurrentNodeId()
if selected != wx.NOT_FOUND and node_id is not None:
index = self.ListIndex[selected]
subindex = event.GetRow()
entry_infos = self.Manager.GetEntryInfos(index)
if not entry_infos["struct"] & OD_MultipleSubindexes or subindex != 0:
subentry_infos = self.Manager.GetSubentryInfos(index, subindex)
typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
if subentry_infos["pdo"] and typeinfos:
bus_id = '.'.join(map(str, self.ParentWindow.GetBusId()))
var_name = "%s_%04x_%02x" % (self.Manager.GetSlaveName(node_id), index, subindex)
size = typeinfos["size"]
data = wx.TextDataObject(str(
("%s%s.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex),
"location",
IECTypeConversion.get(typeinfos["name"]),
var_name, "")))
dragSource = wx.DropSource(self.SubindexGrid)
dragSource.SetData(data)
dragSource.DoDragDrop()
return
event.Skip()