[Python] Glade3 e statusbar

Gian Mario Tagliaretti g.tagliaretti a gmail.com
Dom 29 Set 2013 20:44:07 CEST


On Sun, Sep 29, 2013 at 4:14 PM, Marcello <marcello a linuxvil.it> wrote:

> no non va.

from gi.repository import Gtk

class StatusSample(Gtk.Application):
    def __init__(self):
        Gtk.Application.__init__(self, application_id="org.app.StatusSample")
        self.main_window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
        self.main_window.set_default_size(200, 150)

        vb = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.main_window.add(vb)

        button = Gtk.Button("Push Message")
        button.connect("clicked", self.on_button_push_clicked)
        vb.pack_start(button, True, True, 0)

        button = Gtk.Button("Pop message")
        button.connect("clicked", self.on_button_pop_clicked)
        vb.pack_start(button, True, True, 0)

        self.status = Gtk.Statusbar()
        vb.pack_start(self.status, True, True, 0)
        self.context = self.status.get_context_id("my_status")
        self.count = 0

    def do_activate(self):
        self.add_window(self.main_window)
        self.main_window.set_position(Gtk.WindowPosition.CENTER)
        self.main_window.show_all()

    def do_startup(self):
        Gtk.Application.do_startup(self)
        self.status.push(self.context, "Primo Messaggio")

    def on_button_push_clicked(self, button, data=None):
        self.status.push(self.context, "Messaggio numero %d" % self.count)
        self.count += 1

    def on_button_pop_clicked(self, button, data=None):
        self.status.pop(self.context)

if __name__ == "__main__":
    statussample = StatusSample()
    statussample.run(None)


ciao
-- 
Gian Mario Tagliaretti
GNOME Foundation member
gianmt a gnome.org


Maggiori informazioni sulla lista Python