[pygobject] gtk-demo: Use textwrap to reformat description for Gtk.TextView
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] gtk-demo: Use textwrap to reformat description for Gtk.TextView
- Date: Sun, 28 Apr 2013 21:19:45 +0000 (UTC)
commit f0d4b963c42ac31d4d17ec0f2271940df2568644
Author: Simon Feltman <sfeltman src gnome org>
Date: Sat Apr 27 22:30:35 2013 -0700
gtk-demo: Use textwrap to reformat description for Gtk.TextView
https://bugzilla.gnome.org/show_bug.cgi?id=698547
demos/gtk-demo/gtk-demo.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index 1025eaf..b6583c8 100755
--- a/demos/gtk-demo/gtk-demo.py
+++ b/demos/gtk-demo/gtk-demo.py
@@ -23,6 +23,7 @@
import codecs
import os
import sys
+import textwrap
from gi.repository import GLib, GObject, Pango, GdkPixbuf, Gtk
@@ -179,7 +180,12 @@ class GtkDemoWindow(Gtk.Window):
if demo is None:
return
- description = demo.module.description
+ # Split into paragraphs based on double newlines and use
+ # textwrap to strip out all other formatting whitespace
+ description = ''
+ for paragraph in demo.module.description.split('\n\n'):
+ description += '\n'.join(textwrap.wrap(paragraph, 99999))
+ description += '\n\n' # Add paragraphs back in
f = codecs.open(demo.filename, 'rU', 'utf-8')
code = f.read()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]