Line 61: |
Line 61: |
| *[[Development Team/Almanac/Internationalization|Internationalization]] | | *[[Development Team/Almanac/Internationalization|Internationalization]] |
| | | |
− | == Text and Graphics for Sugar Activities == | + | == Texto y gráficos para las actividades de Sugar == |
| * [[Development Team/Almanac/Pango|Pango]] | | * [[Development Team/Almanac/Pango|Pango]] |
− | === How do I create a text box for code editing? === | + | === ¿Cómo puedo crear un cuadro de texto para la edición de código? === |
− | You can use gtksourceview2
| + | Puedes usar gtksourceview2 |
| <pre> | | <pre> |
| import gtk | | import gtk |
Line 72: |
Line 72: |
| ... | | ... |
| | | |
− | # set up the buffer | + | # Configuramos el buffer |
| buffer = gtksourceview2.Buffer() | | buffer = gtksourceview2.Buffer() |
| if hasattr(buffer, 'set_highlight'): # handle different API versions | | if hasattr(buffer, 'set_highlight'): # handle different API versions |
Line 79: |
Line 79: |
| buffer.set_highlight_syntax(True) | | buffer.set_highlight_syntax(True) |
| | | |
− | # set mime type for the buffer | + | # Configuramos el tipo MIME para el buffer |
| lang_manager = gtksourceview2.language_manager_get_default() | | lang_manager = gtksourceview2.language_manager_get_default() |
| if hasattr(lang_manager, 'list_languages'): # again, handle different APIs | | if hasattr(lang_manager, 'list_languages'): # again, handle different APIs |
Line 92: |
Line 92: |
| buffer.set_language(lang) | | buffer.set_language(lang) |
| | | |
− | # set up the view object, use it like gtk.TextView | + | # Establecemos el objeto para la vista, usarlo como gtk.TextView |
| view = gtksourceview2.View(buffer) | | view = gtksourceview2.View(buffer) |
| view.set_size_request(300, 450) | | view.set_size_request(300, 450) |
Line 108: |
Line 108: |
| </pre> | | </pre> |
| | | |
− | To set the text in the buffer:
| + | Para agregar texto al buffer: |
| <pre> | | <pre> |
| buffer.set_text(text) | | buffer.set_text(text) |
| </pre> | | </pre> |
− | To get all the text:
| + | Para obtener todo el texto: |
| <pre> | | <pre> |
| text = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter()) | | text = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter()) |
| </pre> | | </pre> |
| | | |
− | You will probably want to put the view in a gtk.ScrolledWindow
| + | Probablemente quieras poner la view(vista) en un gtk.ScrolledWindow |
| <pre> | | <pre> |
| sw = gtk.ScrolledWindow() | | sw = gtk.ScrolledWindow() |
Line 123: |
Line 123: |
| sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | | sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
| </pre> | | </pre> |
− | and add the sw object instead of the view.
| + | y agregar el el objeto sw en vez de la view(vista). |
| | | |
| | | |
− | You can find more in the Pippy source and in jarabe.view.sourceview.
| + | Puedes encotnrar más en el código fuete de Pippyy en jarabe.view.sourceview. |
| | | |
| == Audio & Video == | | == Audio & Video == |