Changes
Jump to navigation
Jump to search
Line 1:
Line 1:
+
+
Line 4:
Line 6:
−
Line 45:
Line 46:
+
− Note that when you cut or copy text programmatically, you must first select a region in the widget. That is why we have the call to select_region() in the _copyClipInput_cb method. The -1 argument ensures that all text in the widget is selected. <ref>http://www.pygtk.org/docs/pygtk/class-gtkeditable.html#method-gtkeditable--select-region</ref>+
Development Team/Almanac/GTK's Clipboard Module (view source)
Revision as of 13:24, 25 July 2008
, 13:24, 25 July 2008no edit summary
= Working With Text on the Clipboard =
=== How do I copy and paste text from GTK widgets? ===
=== How do I copy and paste text from GTK widgets? ===
The code below creates a simple gtk.Entry widget where text can be entered. Right below this widget, there is one button to copy text inside of the entry and another to paste text from the clipboard in to the Entry widget. In addition to using the "Copy" and "Paste" buttons, users can also use '''CONTROL-X''', '''CONTROL-C''', and '''CONTROL-V''' to cut, copy and paste text from widgets that implement the Editable interface. The meat of the work is done in short callbacks that are connected to the Copy and Paste buttons. The code for creating the UI has been included primarily for completeness and added clarity.
The code below creates a simple gtk.Entry widget where text can be entered. Right below this widget, there is one button to copy text inside of the entry and another to paste text from the clipboard in to the Entry widget. In addition to using the "Copy" and "Paste" buttons, users can also use '''CONTROL-X''', '''CONTROL-C''', and '''CONTROL-V''' to cut, copy and paste text from widgets that implement the Editable interface. The meat of the work is done in short callbacks that are connected to the Copy and Paste buttons. The code for creating the UI has been included primarily for completeness and added clarity.
<pre>
<pre>
</pre>
</pre>
Note that when you cut or copy text programmatically, you must first select a region in the widget. That is why we have the call to select_region() in the _copyClipInput_cb method. The -1 argument ensures that all text in the widget is selected. <ref>http://www.pygtk.org/docs/pygtk/class-gtkeditable.html#method-gtkeditable--select-region</ref>
= Working with More Complex Data Structures on the Clipboard =
= Notes =
= Notes =
<references />
<references />