static-sites/bases/do-blog/resources/documents/python/gtk3/tutorial1.py

45 lines
1.7 KiB
Python
Executable File

#+BEGIN_COMMENT
.. title: Display a GTK window
.. slug: displaying a gtk window
.. date: 2014-01-05 12:00:00 UTC
.. tags: GTK-3, python, window
.. category: python
.. description: GTK Example on loading a window from a glade fiel and displaying it on the screen.
.. type: text
#+END_COMMENT
#append this to module path so we can load from the parent directory
import os
import sys
from scaffold import web
from scaffold.loaders import load
class page:
name = __name__
title = 'Display a GTK3 window'
tags = 'GTK3', 'Python', 'window'
intro = 'GTK Example on loading a window from a glade fiel and displaying it on the screen.'
date = '2014-01-05'
path = os.path.abspath('./')
image = web.template.path_image + '/gtk/tut01-windows.png'
def create_content(self):
web.images.create(self.image, title='GTK Window')
web.page.section(
web.div.create(
web.paragraph.render()
).append(
web.images.render()
).set_classes('sources').render()
)
web.paragraph.create(
"""Simple GTK application load a window from a glade file and exit on hitting the window close button, we use the get_object method to get the window by name then use connect to attach to the close and destroy events.""")
web.paragraph.append('There are lots of event we can connect to like mouse click key press and window minimise maximise check the gtk docs or glade for a list of possible event for each widget.')
web.page.section(web.paragraph.render())
web.pre.create(load(os.path.abspath('./content/gtk3/tut01/tut01-windows.py')))
web.page.section(web.pre.render())