summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2013-04-27 22:30:35 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2013-04-28 13:48:58 -0700
commitf0d4b963c42ac31d4d17ec0f2271940df2568644 (patch)
tree074f980ecce9d89cc3d30ad8283e089d5acc5b96
parented41e260dcf5745fcc0656412be3c4a520ee20fc (diff)
downloadpygobject-f0d4b963c42ac31d4d17ec0f2271940df2568644.tar.gz
gtk-demo: Use textwrap to reformat description for Gtk.TextView
https://bugzilla.gnome.org/show_bug.cgi?id=698547
-rwxr-xr-xdemos/gtk-demo/gtk-demo.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index 1025eafb..b6583c8c 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()