Python wx.DropSource() Examples
The following are 16
code examples of wx.DropSource().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: dnd_list.py From PandasDataFrameGUI with MIT License | 6 votes |
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)
Example #2
Source File: clipboard.py From wxGlade with MIT License | 6 votes |
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)
Example #3
Source File: LogCtrl.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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()
Example #4
Source File: TreeCtrl.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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)
Example #5
Source File: TreeCtrl.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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)
Example #6
Source File: ConfigEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
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()
Example #7
Source File: LibraryPanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
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()
Example #8
Source File: AddEventDialog.py From EventGhost with GNU General Public License v2.0 | 5 votes |
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()
Example #9
Source File: EthercatCIA402Slave.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def StartDragNDrop(self, data): data_obj = wx.TextDataObject(str(data)) dragSource = wx.DropSource(self.GetCTRoot().AppFrame) dragSource.SetData(data_obj) dragSource.DoDragDrop()
Example #10
Source File: CodeFileEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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()
Example #11
Source File: FileManagementPanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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()
Example #12
Source File: DebugVariableTextViewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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()
Example #13
Source File: PouInstanceVariablesPanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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()
Example #14
Source File: IDEFrame.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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()
Example #15
Source File: subindextable.py From CANFestivino with GNU Lesser General Public License v2.1 | 4 votes |
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()
Example #16
Source File: ConfigEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 4 votes |
def OnVariablesGridLeftClick(self, event): item, _flags, col = self.VariablesGrid.HitTest(event.GetPosition()) if item.IsOk(): entry = self.VariablesGrid.GetItemPyData(item) data_type = entry.get("Type", "") data_size = self.Controler.GetSizeOfType(data_type) if col == -1 and data_size is not None: pdo_mapping = entry.get("PDOMapping", "") access = entry.get("Access", "") entry_index = self.Controler.ExtractHexDecValue(entry.get("Index", "0")) entry_subindex = self.Controler.ExtractHexDecValue(entry.get("SubIndex", "0")) location = self.Controler.GetCurrentLocation() if self.PositionColumn: slave_pos = self.Controler.ExtractHexDecValue(entry.get("Position", "0")) location += (slave_pos,) node_name = self.Controler.GetSlaveName(slave_pos) else: node_name = self.Controler.CTNName() if pdo_mapping != "": var_name = "%s_%4.4x_%2.2x" % (node_name, entry_index, entry_subindex) if pdo_mapping == "T": dir = "%I" else: dir = "%Q" location = "%s%s" % (dir, data_size) + \ ".".join(map(str, location + (entry_index, entry_subindex))) data = wx.TextDataObject(str((location, "location", data_type, var_name, "", access))) dragSource = wx.DropSource(self.VariablesGrid) dragSource.SetData(data) dragSource.DoDragDrop() return elif self.PositionColumn: location = self.Controler.GetCurrentLocation() +\ (slave_pos, entry_index, entry_subindex) data = wx.TextDataObject(str((location, "variable", access))) dragSource = wx.DropSource(self.VariablesGrid) dragSource.SetData(data) dragSource.DoDragDrop() return event.Skip()