Graduating to GUI. PyGObject for Beginners. Presented by Paul W. Frields Red Hat, Inc. / Fedora Project

Similar documents
GUI Programming with GTK+

CS123. Programming Your Personal Robot. Part 2: Event Driven Behavior

Creating GNOME Applications with Glade. Part I: Introduction

Gobject Gobject 2.26.zip

Project Report Number Plate Recognition

CS 370 The Pseudocode Programming Process D R. M I C H A E L J. R E A L E F A L L

C SCI The X Window System Stewart Weiss

Python and GTK+ This article may be used for Red Hat Magazine

Inside Smalltalk MVC: Patterns for GUI Programming

Canola Application and Framework diving into canola s extensible rich gui framework

Create web pages in HTML with a text editor, following the rules of XHTML syntax and using appropriate HTML tags Create a web page that includes

CMSC201 Computer Science I for Majors

Asynchronous Programming

ApacheCon NA How to Avoid Common Mistakes in OFBiz Development Presented by Adrian Crum

Organization of User Interface Software

AADL Graphical Editor Design

Interface Builders and Interface Description Languages

EXTENSIONS OF THE XML FILE FOR THE HIERARCHICAL SYSTEM EDITOR

MODULE 4.1: KEY FEATURES

15 Minute Traffic Formula. Contents HOW TO GET MORE TRAFFIC IN 15 MINUTES WITH SEO... 3

Carlos Soriano Sanchez. Bastian Ilsø Hougaard. csoriano bastianilso

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

MAXQDA and Chapter 9 Coding Schemes

Core object model EO / EFL++

Tim moves to accept, Chris Z seconds. No objections or comments.

GUI s and Keyboards. Larry Rudolph March 13, Pervasive Computing MIT SMA 5508 Spring 2006 Larry Rudolph

Briefcase Documentation

Reinventing the Enlightenment Object System

How GNOME Obsoleted its Enable Accessibility Setting. Alejandro Piñeiro

Module 1: Information Extraction

Paul de Metter, Lennard Fonteijn 11th April 2017

Lecture 24. GUI Applications

Maintaining accessibility through testing?

Active Workspace 3.4 Configuration. David McLaughlin / Oct 2017

Graphical User Interface (GUI)

Builder Documentation

Construction: High quality code for programming in the large

Goals for this lecture. Lecture 4 Getting Started with ITK! Getting help. Assignments. Assignments, cont. Grading of assignments

USER GUIDE. Blogs. Schoolwires Centricity

Introduction to Human Computer Interaction

News in RSA-RTE 10.2 updated for sprint Mattias Mohlin, May 2018

What is a class? Responding to messages. Short answer 7/19/2017. Code Listing 11.1 First Class. chapter 11. Introduction to Classes

CS354R: Game Technology

Leverage the Power of Progress Developer Studio for OpenEdge. 8 th Oct, 2013

Read & Download (PDF Kindle) Beginning Microsoft SQL Server 2012 Programming

Embedded GUI: Widgets Within Editors

Smalltalk: developed at Xerox Palo Alto Research Center by the Learning Research Group in the 1970 s (Smalltalk-72, Smalltalk-76, Smalltalk-80)

Advanced IQA. DDI: +44 (0) Mobile: +44 (0) Web:

Lab 08. Command Line and Git

Qt + Maemo development

Week - 01 Lecture - 04 Downloading and installing Python

BDM Hyperion Workspace Basics

insight3d quick tutorial

The RASTA Framework. Joel Becker October 3, 2001

Frédéric Crozat SUSE Linux Enterprise Release Manager

MapInfo Pro. Version 17 Overview

Embedding a Python interpreter into your program

CS193P: HelloPoly Walkthrough

BMEGUI Installation Manual BMEGUI2.1.1 Update 1 (Last Edited on: 2009/02/25)

(1) Order confirmation expected If an order confirmation is not given in the expected time frame, a reminder will be sent out

Mount Points Mount Points is a super simple tool for connecting objects together and managing those relationships.

Graphical User Interface (GUI)

The C++ SoftBench Class Editor

IBM Atlas Policy Distribution Administrators Guide: IER Connector. for IBM Atlas Suite v6

Java Programming Lecture 6

Chapter 21 Restart. Types of power supply

A Byte of Python. Swaroop C H

Using Introspect ESP Python Modules in External Python Scripts

Red Hat 3Scale 2-saas

jquery UI Widget Factory

Technical Debt in Eclipse Development. Eclipse Con France 2018

CSE : Python Programming

Yup, left blank on purpose. You can use it to draw whatever you want :-)

BrightWork Project Office Teams and Administrators Training Guide. Configuring the Project Management Process

Making a PowerPoint Accessible

Review. Designing Interactive Systems II. Review. Base Window System. Apps UITK BWS GEL. 4-Layer Model Graphics and Event Library BWS GEL

How to Create a Simple Animation Using MAYA

Basics of Inheritance

Kivy Designer Documentation

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

Runtime Dynamic Models Documentation Release 1.0

Mid Unit Review. Of the four learning outcomes for this unit, we have covered the first two. 1.1 LO1 2.1 LO2 LO2

Quite Hot 3. Installation... 2 About the demonstration edition... 2 Windows... 2 Macintosh... 3

Background Information About GTK+ and Related Libraries

Asynchronous Interactions and Managing Modeless UI with Autodesk Revit API

LHCb Conditions Database Graphical User Interface

CS 11 python track: lecture 2

How to download/install Windows Live Movie Maker 2011

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09

GUI s and Keyboards. User Interface Goal

Hardware versus software

EMF Temporality. Jean-Claude Coté Éric Ladouceur

Introduction to Lablgtk (from its internals) Adrien Nader - OCaml Users in PariS 1/34

A beginner s guide to (GNU) Emacs 24

Configure App Service Authentication for Your Azure Web App

Creating and Updating Websites In-Service Training Supplement

Inheritance and Polymorphism

Decisions, Decisions. Testing, testing C H A P T E R 7

Getting Around the Member Pages

Unit 8: Working with Actions

Transcription:

Graduating to GUI PyGObject for Beginners Presented by Paul W. Frields Red Hat, Inc. / Fedora Project Copyright 2011 Paul W. Frields. This work is licensed under a Creative Commons Attribution 3.0 License.

Today's Topics 1. Getting started 2. GObject introspection 3. Classes, inheritance, hierarchy 4. Signals 5. Putting it together: Simple example

Do you know the way to GTK?

Tools Python PyGObject >= 2.28 GTK+ >= 3.0 Text editor of choice glade3 devhelp

Getting tools Reasonably simple on all distributions use your distro s package manager to easily install the proper collection For example, on Fedora or opensuse: Use Add/Remove Software tool to add gtk3-devel, gtk3-devel-docs, pygobject2

Workflow Glade to design UI (as GtkBuilder) Saved as XML file Can be tweaked in Glade or any editor Python code loads the XML file as a resource Interactive elements assigned to objects Functions called based on interaction

I still have that other gir

Who died & left you king? Every time GTK+ changed, PyGTK had to be updated too Using GObject introspection (GI), that s no longer necessary The GI repository (GIR) for a library makes it simple to generate bindings for many languages PyGTK is the old stuff, PyGObject is the new hotness and where things are going

GObject introspection

So what? So... well, nothing really, unless you need to port existing code not covering that here Beginners should be aware PyGTK code on the intarwebz is in danger of becoming obsolete, or just plain wrong (gasp!) (See earlier version of this talk for specific PyGTK guidance, URL on last page)

A Chair( ) is still a Chair( )

GTK object model Based on classes and inheritance Each object can have its own special properties and methods Real-life example: Chair object, has a location property FoldingChair adds fold( ) function SwivelChair adds rotate( ) function

GTK object hierarchy GtkButton: pushbutton widget, subclass of... GtkBin: widget that contains only one widget, subclass of... GtkContainer: container widget for other widgets, subclass of... GtkWidget: base object for all widgets, subclass of... GObject: base for all objects

How to learn more This is where devhelp comes in provides hierarchical listing of inheritance For example, let's look at GtkButton in the listing Note that GtkButton inherits the properties and methods of the classes above (e.g. visible property from GtkWidget)

Just waiting for you

GTK signals This is the basis for interactivity and response Main loop and input interaction Interaction generates a signal, which can be caught and used to trigger a function Example: a button click, a checkbox filled or cleared

Important Python points To use GTK library bindings, load using GIR: from gi.repository import Gtk Create a GtkBuilder object and use Gtk.Builder.add_from_file( ) to load objects: def init (self): self.builder = Gtk.Builder() self.builder.add_from_file('prog.ui') # Now you can refer to elements using # the self.builder object

Element references The Gtk.Builder.get_object( ) function returns an object based on its name self.close_button = self.builder.get_object('close')

Connecting & callbacks Almost any widget can use the connect( ) function to map a signal to a callback A callback is where you code the reaction to the user s action self.close_button.connect( clicked, self.hide_dialog)

What s it all about, Alfie?

Simple example easy-entry.py Takes text entry from a dialog and outputs the text on the command line Demonstrates very simple interface and signals Window, buttons, text entry Window deletion, clicked signal GTK main loop

Reminder: Program flow XML file defines the GUI elements Python code loads file into Gtk.Builder object Python code continues to refine GUI and assign interactivity through additional functions

GTK can change the UI Everything need not be written in the UI file! Assign label text and other content Hide or show elements Example: PulseCaster

Parting thoughts (Apologies to Burt Bacharach for earlier stuff) PyGObject doesn t make things harder concepts are same as in PyGTK Try contributing to something before reinventing a wheel If you re doing something new, remember: Coding comes last

Questions? http://pfrields.fedorapeople.org/presentations/ Contact: pfrields@fedoraproject.org Copyright 2011 Paul W. Frields. This work is licensed under a Creative Commons Attribution 3.0 License.