Una aplicación mínima en GTK+: una ventana con un título. |
Use una si necesita soporte de . |
from gi.repository import Gtk
import sys
class MyApplication(Gtk.Application):
def do_activate(self):
# create a Gtk Window belonging to the application itself
window = Gtk.Window(application=self)
# set the title
window.set_title("Welcome to GNOME")
# show the window
window.show_all()
# create and run the application, exit with the value returned by
# running the program
app = MyApplication()
exit_status = app.run(sys.argv)
sys.exit(exit_status)
set_default_size(200, 100)
establece el tamaño predeterminado de la ventana a una anchura de 200
y una altura de 100
; si en lugar de un número positivo le pasa -1
tendrá el tamaño predeterminado.
set_position(Gtk.WindowPosition.CENTER)
centra la ventana. Otras opciones son Gtk.WindowPosition.NONE, Gtk.WindowPosition.MOUSE, Gtk.WindowPosition.CENTER_ALWAYS, Gtk.WindowPosition.CENTER_ON_PARENT
.
En este ejemplo se usa lo siguiente:
GtkApplication
GtkWindow