Test Foro de elhacker.net SMF 2.1

Programación => Scripting => Mensaje iniciado por: Softrix18 en 2 Octubre 2013, 23:33 PM

Título: [Python/Gtk] Tutorial Interfaz gráfica de usuario PyGobject
Publicado por: Softrix18 en 2 Octubre 2013, 23:33 PM
Buenas Tarde.

Acá le presento un breve tutorial de como vosotro podeis utilizar esta biblioteca.

PyGObject es un módulo dinámico Python que permite a los desarrolladores utilizar el poder de GObject, que forma parte de la plataforma GNOME.

Código (python) [Seleccionar]

from gi.repository import Gtk

class VentanaPrincipal(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self)
self.set_title('Menu')
self.connect("delete-event", Gtk.main_quit)
self.show_all()

ventana = VentanaPrincipal()
Gtk.main()



Código (python) [Seleccionar]


from gi.repository import Gtk

class About(Gtk.AboutDialog):

     def __init__(self):
        Gtk.AboutDialog.__init__(self)
      self.set_name("PyGObject Tutorial")
self.set_program_name('Tutorial Foro elhacker')
self.set_documenters('')
self.set_version("1.0")
self.set_authors('Pablo Cariel')
self.set_website("http://www.google.com")
self.set_copyright("Software Libre - 2013")
self.set_license('')
self.set_logo_icon_name(Gtk.STOCK_ABOUT)
self.run()
self.destroy()

class VentanaPrincipal(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self)
self.set_title('Ventana Principal')
self.connect("delete-event", Gtk.main_quit)
self.button = Gtk.Button(label="Prueba About")
        self.button.connect("clicked", self.botton)
        self.add(self.button)
self.show_all()

    def botton(self, widget):
        About()



ventana = VentanaPrincipal()
Gtk.main()
Título: Re: [Python/Gtk] Tutorial Interfaz gráfica de usuario PyGobject
Publicado por: 0xDani en 6 Octubre 2013, 14:33 PM
Bueno, estos dos códigos de ejemplo no están mal (por ejemplo no conocía el uso de la clase AboutDialog). Si tengo tiempo a lo mejor escribo algo sobre la creación de GUIs con GTK 3 y CSS, usando PyGObject.