Idioma:
English
Temas
Intro
Ventana
Canvas
Caja
Capa
Texto
Caja1
Reloj
Reloj1
El esqueleto del programa mínimo que necesitamos para utilizar GooCanvas. Consiste en solamente una ventara creada con Gtk+.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# demo_goocanvas_0.py
#
# Copyright 2019 John Coppens <john@jcoppens.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('GooCanvas', '2.0')
from gi.repository import Gtk, GooCanvas
class MainWindow(Gtk.Window):
def __init__(self):
super(MainWindow, self).__init__()
self.connect("destroy", lambda x: Gtk.main_quit())
self.set_size_request(400, 300)
# Create the GooCanvas widget
cv = GooCanvas.Canvas()
# And ask for access to the root layer
layer0 = cv.get_root_item()
self.add(cv)
self.show_all()
def run(self):
Gtk.main()
def main(args):
mainwdw = MainWindow()
mainwdw.run()
return 0
if __name__ == '__main__':
import sys
sys.exit(main(sys.argv))
(c) John Coppens ON6JC/LW3HAZ | correo |