Exemplo n.º 1
0
    def test_box(self):
        box = gtk.Box()
        child = gtk.Button()

        box.pack_start(child)
        expand, fill, padding, pack_type = box.query_child_packing(child)
        self.assertTrue(expand)
        self.assertTrue(fill)
        self.assertEqual(padding, 0)
        self.assertEqual(pack_type, gtk.PACK_START)

        child = gtk.Button()
        box.pack_end(child)
        expand, fill, padding, pack_type = box.query_child_packing(child)
        self.assertTrue(expand)
        self.assertTrue(fill)
        self.assertEqual(padding, 0)
        self.assertEqual(pack_type, gtk.PACK_END)
Exemplo n.º 2
0
    def __init__(self, obj, attr):
        super(TextEditor, self).__init__()
        self.obj = obj

        # The 'value' attribute of the Values Class
        # can only be set via the 'pseudo_values' attribute.
        # We need to account for this particularity.
        if isinstance(obj, Value) and attr == "value":
            attr = "pseudo_values"

        self.attr = attr
        self.set_title("Editing %s" % repr(obj))
        self.set_default_size(600, 600)

        # Text container
        self.text = gtk.TextView()
        text_buffer = self.text.get_buffer()
        text_buffer.set_text(getattr(obj, attr))
        text_container = ScrolledWindow(self.text)

        # Main window container. Using the recommended gtk.Box with
        # gtk.ORIENTATION_VERTICAL fails so we stick
        # to the deprecated VBox for now.
        vbox = gtk.VBox()
        vbox.pack_start(text_container)

        # Button Container
        hbox = gtk.Box(gtk.ORIENTATION_HORIZONTAL)
        save = gtk.Button("Save")
        save.connect('clicked', self.on_ok)
        hbox.add(save)

        cancel = gtk.Button("Cancel")
        cancel.connect('clicked', self.on_cancel)
        hbox.add(cancel)

        h_align = gtk.Alignment(1, 0, 0, 0)
        h_align.add(hbox)

        vbox.pack_start(h_align, False, False)

        self.add(vbox)

        self.show_all()
Exemplo n.º 3
0
 def test_size_request(self):
     import gtk
     box = gtk.Box()
     with capture_gi_deprecation_warnings():
         self.assertEqual(box.size_request(), [0, 0])
Exemplo n.º 4
0
    def test_container_install_child_property(self):
        import gtk

        box = gtk.Box()
        with pytest.warns(gi.PyGIDeprecationWarning):
            box.install_child_property(0, None)
Exemplo n.º 5
0
 def test_size_request(self):
     box = gtk.Box()
     self.assertEqual(box.size_request(), [0, 0])