sys.exit('Failed to load image file gtk-logo-rgb.gif\n')
scaled = pixbuf.scale_simple(32, 32, 'bilinear')
pixbuf = scaled
iter = text_buffer.get_iter_at_offset(0)
text_buffer.insert(iter, 'The text widget can display text with all kinds of nifty attributes. It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n')
text_buffer.insert_with_tags_by_name(iter, 'a blue foreground', 'blue_foreground')
text_buffer.insert(iter, ' or ')
text_buffer.insert_with_tags_by_name(iter, 'a red background', 'red_background')
text_buffer.insert(iter, ' or even ', -1)
text_buffer.insert_with_tags_by_name(iter, 'a stippled red background', 'red_background', 'background_stipple')
text_buffer.insert(iter, ' or ', -1)
text_buffer.insert_with_tags_by_name(iter, 'a stippled blue foreground on solid red background', 'blue_foreground', 'red_background', 'foreground_stipple')
text_buffer.insert(iter, '(select that to read it) can be used.\n\n', -1)
text_buffer.insert_with_tags_by_name(iter, 'Underline, strikethrough, and rise. ', 'heading')
text_buffer.insert(iter, 'You can adjust the amount of space before each line.\n', -1)
text_buffer.insert_with_tags_by_name(iter, 'This line has a whole lot of space before it.\n', 'big_gap_before_line', 'wide_margins')
text_buffer.insert_with_tags_by_name(iter, 'You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n', 'big_gap_after_line', 'wide_margins')
text_buffer.insert_with_tags_by_name(iter, 'You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n', 'double_spaced_line', 'wide_margins')
text_buffer.insert(iter, 'Also note that those lines have extra-wide margins.\n\n', -1)
text_buffer.insert_with_tags_by_name(iter, "This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n", 'not_editable')
text_buffer.insert(iter, "This line(and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", -1)
text_buffer.insert_with_tags_by_name(iter, "This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", 'char_wrap')
text_buffer.insert_with_tags_by_name(iter, 'This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n', 'no_wrap')
text_buffer.insert_with_tags_by_name(iter, '\nThis line has center justification.\n', 'center')
text_buffer.insert_with_tags_by_name(iter, 'This line has right justification.\n', 'right_justify')
text_buffer.insert_with_tags_by_name(iter, '\nThis line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n', 'wide_margins')
text_buffer.insert(iter, 'You can put all sorts of Unicode text in the buffer.\n\nGerman(Deutsch S\xc3\xbcd) Gr\xc3\xbc\xc3\x9f Gott\nGreek(\xce\x95\xce\xbb\xce\xbb\xce\xb7\xce\xbd\xce\xb9\xce\xba\xce\xac) \xce\x93\xce\xb5\xce\xb9\xce\xac \xcf\x83\xce\xb1\xcf\x82\nHebrew \xd7\xa9\xd7\x9c\xd7\x95\xd7\x9d\nJapanese(\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n', -1)
text_buffer.insert(iter, "Here's a word-wrapped quote in a right-to-left language:\n", -1)
text_buffer.insert(iter, "You can put widgets in the buffer: Here's a button: ", -1)
anchor = text_buffer.create_child_anchor(iter)
text_buffer.insert(iter, ' and a menu: ', -1)
anchor = text_buffer.create_child_anchor(iter)
text_buffer.insert(iter, ' and a scale: ', -1)
anchor = text_buffer.create_child_anchor(iter)
text_buffer.insert(iter, ' and an animation: ', -1)
anchor = text_buffer.create_child_anchor(iter)
text_buffer.insert(iter, ' finally a text entry: ', -1)
anchor = text_buffer.create_child_anchor(iter)
text_buffer.insert(iter, '.\n', -1)
text_buffer.insert(iter, "\n\nThis demo doesn't demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text(doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...", -1)