Esempio n. 1
0
 def make_a_sub(self, event):
   text = event.GetText()
   text_n = int(text.split(' ')[0])
   if text_n > 0:
     src = wx.DropSource(self.lineups[text_n])
   else:
     src = wx.DropSource(self.reserves)
   tobj = wx.TextDataObject(text)
   src.SetData(tobj)
   src.DoDragDrop(True)
   self.refresh()
Esempio n. 2
0
 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()))
                         size = typeinfos["size"]
                         data = wx.TextDataObject(
                             str(("%s%s.%d.%d" % (SizeConversion[size],
                                                  bus_id, index, subindex),
                                  "location")))
                         dragSource = wx.DropSource(self.SubindexGrid)
                         dragSource.SetData(data)
                         dragSource.DoDragDrop()
         elif 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 subentry_infos["pdo"] and typeinfos:
                         bus_id = '.'.join(
                             map(str, self.ParentWindow.GetBusId()))
                         node_id = self.ParentWindow.GetCurrentNodeId()
                         size = typeinfos["size"]
                         data = wx.TextDataObject(
                             str(("%s%s.%d.%d.%d" %
                                  (SizeConversion[size], bus_id, node_id,
                                   index, subindex), "location")))
                         dragSource = wx.DropSource(self.SubindexGrid)
                         dragSource.SetData(data)
                         dragSource.DoDragDrop()
     event.Skip()
Esempio n. 3
0
    def onDrag(self, event):
        data = wx.FileDataObject()
        obj = event.GetEventObject()
        dropSource = wx.DropSource(obj)

        dropSource.SetData(data)

        #next line will make the drop target window come to top, allowing us
        #to get the info we need to do the work, if it's Explorer
        result = dropSource.DoDragDrop(0)

        #get foreground window hwnd
        h = win32gui.GetForegroundWindow()

        #get explorer location

        s = gencache.EnsureDispatch('Shell.Application')
        #s = win32com.client.Dispatch("Shell.Application")
        loc, outdir = None, None
        for w in s.Windows():
            if int(w.Hwnd) == h:
                loc = w.LocationURL
        if loc:
            outdir = loc.split('///')[1]
            #print (outdir)

            outdir = unquote(outdir)
        print(outdir)
        #got what we need, now download to outfol
        #if outdir and os.path.isdir(outdir):
        #	self.dloadItems(event, outdir)

        return
Esempio n. 4
0
    def start_drag_opperation(self, evt):
        "Event handler for drag&drop functionality"
    
        # get the control
        ctrl = self.menu_ctrl_map[evt.GetToolId()]

        # create our own data format and use it in a custom data object
        ldata = wx.CustomDataObject("gui")
        ldata.SetData(ctrl._meta.name)      # only strings are allowed!

        # Also create a Bitmap version of the drawing
        bmp = ctrl._image.GetBitmap()

        # Now make a data object for the bitmap and also a composite
        # data object holding both of the others.
        bdata = wx.BitmapDataObject(bmp)
        data = wx.DataObjectComposite()
        data.Add(ldata)
        data.Add(bdata)

        # And finally, create the drop source and begin the drag
        # and drop opperation
        dropSource = wx.DropSource(self)
        dropSource.SetData(data)
        if DEBUG: print("Begining DragDrop\n")
        result = dropSource.DoDragDrop(wx.Drag_AllowMove)
        if DEBUG: print("DragDrop completed: %d\n" % result)

        if result == wx.DragMove:
            if DEBUG: print "dragmove!"
            self.Refresh()
Esempio n. 5
0
	def OnMouseMove(self, event):
		"""
		Handles the ``wx.EVT_MOTION`` event for :class:`OtherImagesCtrl`.

		:param event: a :class:`MouseEvent` event to be processed.
		"""
		
		# -- drag & drop --
		if self._dragging and event.Dragging() and len(self._selectedarray) > 0:
			# Limitation: Can only drag&drop 1 at a time
			image = self.GetSelectedItem().GetOriginalImage()
			
			width, height = image.size
			bmp = wx.Bitmap.FromBuffer(width, height, image.tobytes())
			
			# Create BitmapDataObject
			bmp_data = wx.BitmapDataObject(bmp)
			
			source = wx.DropSource(self)
			source.SetData(bmp_data)
			icon = wx.Icon()
			icon.CopyFromBitmap(bmp)
			source.SetIcon(wx.DragLink, icon)
			source.DoDragDrop(wx.Drag_CopyOnly)
			# TODO: Why the weird effect when dragging?
		
		self.Refresh()
		eventOut = thumbnailctrl.ThumbnailEvent(thumbnailctrl.wxEVT_THUMBNAILS_POINTED, self.GetId())
		self.GetEventHandler().ProcessEvent(eventOut)
		event.Skip()
Esempio n. 6
0
    def OnMotion(self, evt):
        if not evt.LeftIsDown() or not self.leftPressed:
            return
        self.bin.SetFocusIgnoringChildren()
        # Removed for Linux compatibility
        #cursorImg = self.bitmap.ConvertToImage()
        #cursorImg.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, int(self.bitmap.Size[0])/2)
        #cursorImg.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, int(self.bitmap.Size[1])/2)
        #cursor = wx.CursorFromImage(cursorImg)

        # wx crashes unless the data object is assigned to a variable.
        data_object = wx.CustomDataObject("ObjectKey")
        data_object.SetData(
            cPickle.dumps((self.bin.GetId(), self.bin.SelectedKeys())))
        source = wx.DropSource(self)  #, copy=cursor, move=cursor)
        source.SetData(data_object)
        result = source.DoDragDrop(wx.Drag_DefaultMove)
        # def cb():
        #     self.bin.RemoveKeys(self.bin.SelectedKeys()) # Hack to fix drag move
        # wx.CallAfter(cb)
        #if result is wx.DragMove:
        self.bin.RemoveSelectedTiles(
        )  # Removes images which stays during drag and drop
        self.bin.UpdateSizer()
        self.bin.UpdateQuantity()
Esempio n. 7
0
    def OnDragInit(self, event):
        text = self.GetItemText(event.GetIndex())
        tdo = wx.TextDataObject(text)
        tds = wx.DropSource(self)

        tds.SetData(tdo)
        tds.DoDragDrop(True)
Esempio n. 8
0
 def OnDragInit(self, event):
     text = self.lst1.GetItemText(event.GetIndex())
     tobj = wx.PyTextDataObject(text)
     src = wx.DropSource(self.lst1)
     src.SetData(tobj)
     src.DoDragDrop(True)
     self.lst1.DeleteItem(event.GetIndex())
    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()
Esempio n. 10
0
    def startDrag(self, event):
        srcRow = event.GetIndex()

        if srcRow == -1:
            return
        if srcRow in self.blanks:
            return
        try:
            mod = self.mods[srcRow]
        except IndexError:
            return
        if not isinstance(self.mods[srcRow], Module):
            return
        if mod.isEmpty:
            return
        fit = Fit.getInstance().getFit(self.activeFitID)
        if mod not in fit.modules:
            return

        self.unselectAll()
        self.Select(srcRow, True)

        data = wx.TextDataObject()
        dataStr = "fitting:" + str(fit.modules.index(mod))
        data.SetText(dataStr)

        dropSource = wx.DropSource(self)
        dropSource.SetData(data)
        DragDropHelper.data = dataStr
        dropSource.DoDragDrop()
Esempio n. 11
0
    def _handler_series_motion(self, event):
        if not event.Dragging():
            event.Skip()
            return

        # get out current Study instance
        try:
            study = self._study_dict[self._selected_study_uid]
        except KeyError:
            return

        # then the series_dict belonging to that Study
        series_dict = study.series_dict
        # and finally the specific series instance
        # series.filenames is a list of the filenames
        try:
            series = series_dict[self._selected_series_uid]
        except KeyError:
            return

        # according to the documentation, we can only write to this
        # object on Windows and GTK2.  Hrrmmpph.
        # FIXME.  Will have to think up an alternative solution on
        # OS-X
        data_object = wx.FileDataObject()
        for f in series.filenames:
            data_object.AddFile(f)

        drop_source = wx.DropSource(self._view_frame.series_lc)
        drop_source.SetData(data_object)
        # False means that files will be copied, NOT moved
        drop_source.DoDragDrop(False)
Esempio n. 12
0
 def OnBeginDrag(self, event):
     if not self.fnDndAllow(event): return
     indices = []
     start = stop = -1
     for index in xrange(self.GetItemCount()):
         if self.GetItemState(index, _wx.LIST_STATE_SELECTED):
             if stop >= 0 and self.dndOnlyCont:
                 # Only allow moving selections if they are in a
                 # continuous block...they aren't
                 return
             if start < 0:
                 start = index
             indices.append(index)
         else:
             if start >= 0 > stop:
                 stop = index - 1
     if stop < 0: stop = self.GetItemCount()
     selected = pickle.dumps(indices, 1)
     ldata = _wx.CustomDataObject(u'ListIndexes')
     ldata.SetData(selected)
     data_object = _wx.DataObjectComposite()
     data_object.Add(ldata)
     source = _wx.DropSource(self)
     source.SetData(data_object)
     source.DoDragDrop(flags=_wx.Drag_DefaultMove)
Esempio n. 13
0
    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()
Esempio n. 14
0
    def OnLeftMouseDown(self, e):
        if not self.gameState or not self.isLocal:
            e.Skip()
            return

        # Locate any cards we're pointing at.
        (x, y) = self.CoordScreen2World(*e.GetPosition())
        card = self.FindCardAt(*e.GetPosition())

        # Found one?
        if card:
            # Start dragging it
            self.markerOffset = (x - card.x, y - card.y)
            top = not e.AltDown()

            data = dragdrop.CardDropData(cgid=card.cgid,
                                         x=x - card.x,
                                         y=y - card.y,
                                         top=top,
                                         faceUp=card.faceUp)
            src = wx.DropSource(self)
            src.SetData(data)
            self.contextCard = card
            result = src.DoDragDrop(True)
            self.contextCard = None

        e.Skip()
Esempio n. 15
0
    def _startDrag(self, e):
        """ Put together a data object for drag-and-drop _from_ this list. """
        l = ['Series']
        # mostly need the ItemData, which is the record ID in the DataSeries table
        idx = self.GetFirstSelected()
        l.append(self.GetItemData(idx))
        # as a convenience, pass the list row text 
        l.append(self.GetItemText(idx))
        # and the ChannelSegment list column to put it in
        l.append(1)

        # Pickle the object
        itemdata = cPickle.dumps(l, 1)
        # create our own data format and use it in a
        # custom data object
        ldata = wx.CustomDataObject("RecIDandTable")
        ldata.SetData(itemdata)
        # Now make a data object for the  item list.
        data = wx.DataObjectComposite()
        data.Add(ldata)

        # 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 could remove the item from this list.
        if res == wx.DragMove:
            pass # disable removing, we only want to assign its info to the other list
    def start_drag_operation(self, event):
        '''Start dragging whatever is selected'''
        fd = StringIO()
        modules_to_save = [m.module_num for m in self.get_selected_modules()]
        self.__pipeline.savetxt(fd, modules_to_save)
        pipeline_data_object = PipelineDataObject()
        fd.seek(0)
        pipeline_data_object.SetData(fd.read())

        text_data_object = wx.TextDataObject()
        fd.seek(0)
        text_data_object.SetData(fd.read())

        data_object = wx.DataObjectComposite()
        data_object.Add(pipeline_data_object)
        data_object.Add(text_data_object)
        drop_source = wx.DropSource(self.list_ctrl)
        drop_source.SetData(data_object)
        self.drag_underway = True
        self.drag_start = event.Position
        self.drag_time = time.time()
        selected_module_ids = [m.id for m in self.get_selected_modules()]
        self.__pipeline.start_undoable_action()
        try:
            result = drop_source.DoDragDrop(wx.Drag_AllowMove)
            self.drag_underway = False
            if result == wx.DragMove:
                for id in selected_module_ids:
                    for module in self.__pipeline.modules():
                        if module.id == id:
                            self.__pipeline.remove_module(module.module_num)
                            break
        finally:
            self.__pipeline.stop_undoable_action("Drag and drop")
Esempio n. 17
0
 def on_left_down(self, event):
     text = self.source.GetValue()
     data = wx.TextDataObject(text)
     drop_source = wx.DropSource(self)
     drop_source.SetData(data)
     result = drop_source.DoDragDrop(wx.Drag_AllowMove)
     if result == wx.DragMove:
         self.source.SetValue("")
Esempio n. 18
0
 def on_begin_drag(self, evt):
     item = evt.GetItem()
     path = self.GetItemPyData(item)
     if path in self.files:
         data = DropData("FileDropData", path)
         source = wx.DropSource(self)
         source.SetData(data)
         result = source.DoDragDrop(wx.Drag_DefaultMove)
Esempio n. 19
0
 def doDragDrop(self, paths):
     data = wx.FileDataObject()
     for path in paths:
         data.AddFile(path)
     dragSource = wx.DropSource(self.parent)
     dragSource.SetData(data)
     dragSource.DoDragDrop()
     self.parent.updateOutputs()
Esempio n. 20
0
    def onBeginDrag(self, evt):
        item = evt.GetIndex()  #GetItem()

        txtData = wx.TextDataObject(\
        'JournalEntry' + '>' + self.listCtrlImportedJE.GetItemText(item))
        txtDropSource = wx.DropSource(self.listCtrlImportedJE)
        txtDropSource.SetData(txtData)
        txtDropSource.DoDragDrop(True)
Esempio n. 21
0
    def OnDragBegin(self, evt):
        url = self.GetItemPath(evt.GetItem())
        data = wx.FileDataObject()
        data.AddFile(url)

        dropSource = wx.DropSource(self)
        dropSource.SetData(data)
        result = dropSource.DoDragDrop()
Esempio n. 22
0
 def OnDragInit(self, event):
     """Drag the full variable name as text.
     """
     text = self.tree.GetItemData(event.GetItem()) + '\n'
     tdo = wx.TextDataObject(text)
     tds = wx.DropSource(self.tree)
     tds.SetData(tdo)
     tds.DoDragDrop(True)
Esempio n. 23
0
 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()
Esempio n. 24
0
 def __used_drag_init(self, event):
     """
     Start dragging from used operations, for re-aranging
     """
     text = self.usedOperations.GetItemText(event.GetIndex())
     tdo = wx.PyTextDataObject(text)
     tds = wx.DropSource(self.usedOperations)
     tds.SetData(tdo)
     tds.DoDragDrop(True)
Esempio n. 25
0
    def _startDrag(self, e):
        data = wx.CustomDataObject('py_str')
        items = self.getSelected()
        items = ','.join(items)
        data.SetData(items.encode('utf8'))

        dropSource = wx.DropSource(self.sourcelist)
        dropSource.SetData(data)
        res = dropSource.DoDragDrop(flags=wx.Drag_CopyOnly)
Esempio n. 26
0
    def startDrag(self, event):
        row = event.GetIndex()
        if row != -1:
            data = wx.PyTextDataObject()
            data.SetText(str(self.GetItemData(row)))

            dropSource = wx.DropSource(self)
            dropSource.SetData(data)
            res = dropSource.DoDragDrop()
Esempio n. 27
0
 def onBeginDrag(self, evt):
     item = evt.GetItem()
     #check that item should be draggable
     if item not in (self.root, self.lights, self.cameras, self.colliders):
         txtData = wx.TextDataObject(\
         'StoryObject' + '>' + self.treePandaObj.GetItemText(item))
         txtDropSource = wx.DropSource(self.treePandaObj)
         txtDropSource.SetData(txtData)
         txtDropSource.DoDragDrop(True)
Esempio n. 28
0
    def startDrag(self, event):
        row = event.GetIndex()
        if row != -1 and isinstance(self.get(row), eos.types.Drone):
            data = wx.PyTextDataObject()
            data.SetText("command:" + str(self.GetItemData(row)))

            dropSource = wx.DropSource(self)
            dropSource.SetData(data)
            dropSource.DoDragDrop()
Esempio n. 29
0
    def OnStartDrag2(self, evt):
        if evt.Dragging():
            url = self.dragText2.GetValue()
            data = wx.TextDataObject()
            data.SetText(url)

            dropSource = wx.DropSource(self.dragText2)
            dropSource.SetData(data)
            result = dropSource.DoDragDrop()
Esempio n. 30
0
    def startDrag(self, event):
        row = event.GetIndex()
        if row != -1:
            data = wx.PyTextDataObject()
            data.SetText("fighter:" + str(row))

            dropSource = wx.DropSource(self)
            dropSource.SetData(data)
            dropSource.DoDragDrop()