#!/bin/env python3 # # Copyright (C) 2010 John (J5) Palmieri # # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 3.0 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. from gi.repository import Gtk, GtkSource title = "Fedora ♥'s Python 3" source_buffer = GtkSource.Buffer() lm = GtkSource.LanguageManager.get_default() lang = lm.get_language('python') source_buffer.set_language(lang) source_view = GtkSource.View(buffer=source_buffer) heart_label = Gtk.Label( label="", use_markup=True) fedora_image = Gtk.Image.new_from_file('/usr/share/icons/Fedora/96x96/places/start-here.png') python_image = Gtk.Image.new_from_file('Python_logo.svg') button = Gtk.Button(label=title) w = Gtk.Window() w.set_title(title) w.set_size_request(600,400) w.connect('destroy', lambda x: Gtk.main_quit()) main_hbox = Gtk.HBox() w.add(main_hbox) scroll_window = Gtk.ScrolledWindow() scroll_window.add_with_viewport(source_view) main_hbox.pack_start(scroll_window, True, True, 5) vbox = Gtk.VBox() main_hbox.pack_start(vbox, False, False, 5) vbox.pack_start(fedora_image, False, False, 0) vbox.pack_start(heart_label, False, False, 0) vbox.pack_start(python_image, False, False, 0) vbox.pack_start(button, False, False, 0) source_file = open('fed_loves_py3.py', 'r') code = source_file.read() source_file.close() source_buffer.insert_at_cursor(code) w.show_all() Gtk.main()