3_button.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Simple window - Just a simple window
  4. # Copyright (c) 2016 Jorge Maldonado Ventura
  5. #
  6. # This file is part of Simple window
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. import gi
  19. gi.require_version('Gtk', '3.0')
  20. from gi.repository import Gtk
  21. class Window(Gtk.Window):
  22. def __init__(self):
  23. Gtk.Window.__init__(self, title='Título original')
  24. self.label = Gtk.Label('asdasd')
  25. self.button = Gtk.Button()
  26. self.button.add(self.label)
  27. self.button.connect('clicked', self.button_clicked)
  28. self.add(self.button)
  29. def button_clicked(self, widget):
  30. print('Me has pulsado.')
  31. if __name__ == '__main__':
  32. win = Window()
  33. win.connect('delete-event', Gtk.main_quit)
  34. win.show_all()
  35. Gtk.main()