def test_pygtkcompat(self): has_error = False try: import gi import pygtkcompat pygtkcompat.enable() pygtkcompat.enable_gtk(version='3.0') except (ImportError, ValueError) as _: has_error = True self.assertFalse(has_error)
def original_gtk(): logger.debug("Using GTK3") try: import pygtkcompat pygtkcompat.enable() pygtkcompat.enable_gtk(version='3.0') except ImportError: logger.warning('"import pygtkcompat" did not work, trying old ' 'deprecated way') import gi.pygtkcompat gi.pygtkcompat.enable() gi.pygtkcompat.enable_gtk(version='3.0') import gtk return gtk
import pygtkcompat pygtkcompat.enable() pygtkcompat.enable_gtk(version='3.0') import gtk class MessageDialog(gtk.MessageDialog): def __init__(self, parent, primary_msg, secondary_msg): super(MessageDialog, self).__init__() self.add_button('OK', 1) self.set_property('text', primary_msg) self.set_property('secondary-text', secondary_msg) self.set_transient_for(parent) def display(self): self.run() self.destroy() class ErrorDialog(MessageDialog): def __init__(self, parent, primary_msg, secondary_msg): super(ErrorDialog, self).__init__(parent, primary_msg, secondary_msg) self.set_property('message-type', gtk.MessageType.ERROR) self.display() class InfoDialog(MessageDialog): def __init__(self, parent, primary_msg, secondary_msg): super(InfoDialog, self).__init__(parent, primary_msg, secondary_msg) self.set_property('message-type', gtk.MessageType.INFO)
def test_main(self): pygtkcompat.enable() pygtkcompat.enable()
def setUp(self): pygtkcompat.enable()
# vim: tabstop=4 shiftwidth=4 expandtab import unittest from gi.repository import GLib try: from gi.repository import Pango from gi.repository import Atk from gi.repository import Gdk from gi.repository import Gtk (Atk, Gtk, Pango) # pyflakes import pygtkcompat pygtkcompat.enable() pygtkcompat.enable_gtk(version='3.0') import atk import pango import pangocairo import gtk import gtk.gdk except ImportError: Gtk = None @unittest.skipUnless(Gtk, 'Gtk not available') class TestATKCompat(unittest.TestCase): def test_object(self): self.assertTrue(hasattr(atk, 'Object'))