Created
March 19, 2010 02:40
-
-
Save rephorm/337170 to your computer and use it in GitHub Desktop.
pygtk drag_abort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gtk | |
| def drag_begin(widget, context): | |
| print "Calling context.drag_abort()" | |
| # why doesn't this do anything? | |
| context.drag_abort(gtk.gdk.CURRENT_TIME) | |
| def drag_data_get(widget, context, selection, target_type, time): | |
| print "Data get" | |
| label = widget.get_label() | |
| print(label) | |
| selection.set_text(widget.get_label(), len(widget.get_label())) | |
| win = gtk.Window() | |
| win.set_size_request(200, 150) | |
| win.connect('destroy', lambda win:gtk.main_quit()) | |
| vbox = gtk.VBox(False, 5) | |
| win.add(vbox) | |
| button = gtk.Button("Drag me") | |
| button.drag_source_set(gtk.gdk.BUTTON1_MASK, [("text/plain", 0, 0)], gtk.gdk.ACTION_COPY) | |
| button.connect('drag-begin', drag_begin) | |
| button.connect('drag-data-get', drag_data_get) | |
| vbox.pack_start(button, False) | |
| win.show_all() | |
| gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment