Pygtk GUI Programming Pygtk GUI Programming Table of Contents Pygtk GUI Programming

Total Page:16

File Type:pdf, Size:1020Kb

Pygtk GUI Programming Pygtk GUI Programming Table of Contents Pygtk GUI Programming PyGTK GUI programming PyGTK GUI programming Table of Contents PyGTK GUI programming...............................................................................................................................1 Chapter 1. Introduzione....................................................................................................................................2 1.1. Primo approccio...............................................................................................................................2 1.2. Il toolkit PyGTK..............................................................................................................................2 1.3. PyGTK e Glade................................................................................................................................2 1.4. IDE o editor......................................................................................................................................4 1.5. Installazione.....................................................................................................................................6 1.5.1. Installazione su piattaforma GNU/Linux...............................................................................6 1.5.2. Installazione su piattaforma Windows...................................................................................6 1.6. Supporto e help................................................................................................................................6 Chapter 2. I Widget, le classi ed un primo esempio........................................................................................8 2.1. I widget............................................................................................................................................8 2.2. Un primo esempio di GUI................................................................................................................8 2.3. Estendiamo l'esempio, un classico...Hello, World!.........................................................................9 Chapter 3. Segnali, eventi e callbacks............................................................................................................11 3.1. I segnali e la classe padre gobject.GObject...................................................................................11 3.1.1. Connettere un segnale..........................................................................................................11 3.1.2. Connettere un segnale ad un oggetto....................................................................................13 3.2. Gli eventi........................................................................................................................................14 3.2.1. Capire quale tasto e' stato premuto.......................................................................................14 Chapter 4. Gli attributi e le proprieta' dei widget........................................................................................16 4.1. Gli attributi dei widget...................................................................................................................16 4.2. Le proprieta' dei widget.................................................................................................................16 Chapter 5. Impacchettare i widget.................................................................................................................17 5.1. Utilizzare i packing box.................................................................................................................17 5.1.1. Un po' di pratica con i packing box......................................................................................17 5.2. Utilizzare la packing table.............................................................................................................18 5.2.1. Un po' di pratica con la packing table..................................................................................19 Chapter 6. Il widget contenitore, La finestra................................................................................................20 6.1. gtk.Window().................................................................................................................................20 6.1.1. Associare e leggere un titolo dalla window..........................................................................20 6.1.2. Decidere la posizione della window sullo schermo.............................................................21 6.1.3. I widget transitori.................................................................................................................21 6.1.4. Distruggere la finestra con i widget transitori......................................................................22 6.1.5. Gestire il ridimensionamento della finestra..........................................................................22 6.1.6. Muovere la finestra...............................................................................................................22 6.1.7. Settare le decorazioni della finestra......................................................................................23 6.1.8. Settare le dimensioni della finestra......................................................................................24 6.1.9. Inserire un' icona nelle decorazioni della Window..............................................................24 6.1.10. Segnali ed eventi della Window.........................................................................................25 6.1.11. Le proprieta' della Window................................................................................................27 6.1.12. Gli attributi della Window..................................................................................................30 Chapter 7. I bottoni..........................................................................................................................................32 7.1. La gerarchia dei bottoni.................................................................................................................32 7.2. gtk.Button()....................................................................................................................................32 i PyGTK GUI programming Table of Contents Chapter 7. I bottoni 7.2.1. Utilizzare gli Stock Item.......................................................................................................34 7.2.2. Utilizzare i mnemonic accelerator........................................................................................34 7.2.3. I segnali emessi da Button....................................................................................................34 7.2.4. Le proprieta' del Button........................................................................................................36 7.3. gtk.ToggleButton()........................................................................................................................37 7.3.1. Un primo esempio di ToggleButton.....................................................................................37 7.3.2. I segnali di ToggleButton.....................................................................................................38 7.3.3. Le proprieta' del ToggleButton............................................................................................38 7.3.4. Gli attributi del ToggleButton..............................................................................................39 7.4. gtk.CheckButton()..........................................................................................................................39 7.4.1. Un primo esempio di CheckButton......................................................................................39 7.4.2. Segnali, proprieta' ed attributi del CheckButton..................................................................40 7.5. gtk.RadioButton()..........................................................................................................................40 7.5.1. Un primo esempio di RadioButton.......................................................................................40 7.5.2. Leggere e cambiare i gruppi di appartenenza.......................................................................41 7.5.3. I segnali di RadioButton.......................................................................................................42 7.5.4. Le proprieta' del RadioButton..............................................................................................42 7.5.5. Gli attributi del ToggleButton..............................................................................................42 Chapter 8. Metodi, attributi, proprieta' e segnali delle classi widget, container e bin..............................43 8.1. La classe widget.............................................................................................................................43 8.1.1. Impadronirsi del controllo....................................................................................................43 Chapter 9. Scendiamo di un livello, il wrapper GDK...................................................................................45 9.1. gtk.gdk.Window()..........................................................................................................................45 9.1.1. Catturare una gtk.gdk.Window............................................................................................45
Recommended publications
  • Mysql Workbench Mysql Workbench
    MySQL Workbench MySQL Workbench Abstract This manual documents the MySQL Workbench SE version 5.2 and the MySQL Workbench OSS version 5.2. If you have not yet installed MySQL Workbench OSS please download your free copy from the download site. MySQL Workbench OSS is available for Windows, Mac OS X, and Linux. Document generated on: 2012-05-01 (revision: 30311) For legal information, see the Legal Notice. Table of Contents Preface and Legal Notice ................................................................................................................. vii 1. MySQL Workbench Introduction ..................................................................................................... 1 2. MySQL Workbench Editions ........................................................................................................... 3 3. Installing and Launching MySQL Workbench ................................................................................... 5 Hardware Requirements ............................................................................................................. 5 Software Requirements .............................................................................................................. 5 Starting MySQL Workbench ....................................................................................................... 6 Installing MySQL Workbench on Windows .......................................................................... 7 Launching MySQL Workbench on Windows .......................................................................
    [Show full text]
  • Instruction Manual Model 34988NI-SL
    Instruction Manual (Original Instructions) Model 34988NI-SL Recover, Recycle, Recharge Machine for R-134a A/C Systems ROBINAIR.COM 800.533.6127 (en-US) Description: Recover, recycle, and recharge machine for use with R-134a equipped air conditioning systems. PRODUCT INFORMATION Record the serial number and year of manufacture of this unit for future reference. Refer to the product identification label on the unit for information. Serial Number: _______________________________Year of Manufacture: ____________ DISCLAIMER: Information, illustrations, and specifications contained in this manual are based on the latest information available at the time of publication. The right is reserved to make changes at any time without obligation to notify any person or organization of such revisions or changes. Further, ROBINAIR shall not be liable for errors contained herein or for incidental or consequential damages (including lost profits) in connection with the furnishing, performance, or use of this material. If necessary, obtain additional health and safety information from the appropriate government agencies, and the vehicle, refrigerant, and lubricant manufacturers. Table of Contents Safety Precautions . 2 Maintenance . 26 Explanation of Safety Signal Words . 2 Maintenance Schedule. 26 Explanation of Safety Decals. 2 Load Language. 27 Protective Devices. 4 Adjust Background Fill Target. 28 Refrigerant Tank Test. 4 Tank Fill. 28 Filter Maintenance. 29 Introduction . 5 Check Remaining Filter Capacity. 29 Technical Specifications . 5 Replace the Filter. 30 Features . 6 Calibration Check . 31 Control Panel Functions . 8 Change Vacuum Pump Oil . 32 Icon Legend. 9 Leak Check. 33 Setup Menu Functions. 10 Edit Print Header. 34 Initial Setup . 11 Replace Printer Paper. 34 Unpack the Machine.
    [Show full text]
  • Porting a Window Manager from Xlib to XCB
    Porting a Window Manager from Xlib to XCB Arnaud Fontaine (08090091) 16 May 2008 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version pub- lished by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Contents List of figures i List of listings ii Introduction 1 1 Backgrounds and Motivations 2 2 X Window System (X11) 6 2.1 Introduction . .6 2.2 History . .6 2.3 X Window Protocol . .7 2.3.1 Introduction . .7 2.3.2 Protocol overview . .8 2.3.3 Identifiers of resources . 10 2.3.4 Atoms . 10 2.3.5 Windows . 12 2.3.6 Pixmaps . 14 2.3.7 Events . 14 2.3.8 Keyboard and pointer . 15 2.3.9 Extensions . 17 2.4 X protocol client libraries . 18 2.4.1 Xlib . 18 2.4.1.1 Introduction . 18 2.4.1.2 Data types and functions . 18 2.4.1.3 Pros . 19 2.4.1.4 Cons . 19 2.4.1.5 Example . 20 2.4.2 XCB . 20 2.4.2.1 Introduction . 20 2.4.2.2 Data types and functions . 21 2.4.2.3 xcb-util library . 22 2.4.2.4 Pros . 22 2.4.2.5 Cons . 23 2.4.2.6 Example . 23 2.4.3 Xlib/XCB round-trip performance comparison .
    [Show full text]
  • Gtk Drawing Area Example C
    Gtk Drawing Area Example C Abyssinian Cary always Indianised his examination if Amadeus is lowest or marshalling skywards. Ornithischian Rudd overruled, his deportation backscatters remilitarizing proud. Zodiacal Udale alkalizing: he repay his ceorl jazzily and observantly. End angle bracket iter to indicates data to c gtk drawing area Programming with gtkmm 3. You should only grab from gtk drawing area widget draws with either create. These programmatically hidden from the properties are put there are created and executable program that all gtk app into boxes, i am doing. This locus the 'traits' of the GtkDrawingArea widget are inherited to this class. GtkDrawingArea gtk-30 Valadoc. M cm else return cm m xm def drawself ctx area tops the egg. Gmcs pkggtk-sharp-20 rusrlibmono20MonoCairodll simplecs Here saying how we compile the example DrawingArea darea new. This source code of examples have thrown me at least we will create a button click to retrieve them into those who must be updated. How to integrate those header-only libraries and uses Catch as an example. We just ugly cast. The error comes from C I over no danger about tablet to drift this drawingrb. Useful for detriment to extract multiple copies of chair same dialog. For example if most have created a dialog box for entering some personal information you. Drawing operation draws the examples are the interior of. Application runs the example draws some way to be used for single cell renderer to this will execute it! This is prominent example in object-oriented behavior enforced in C by GTK. GtkDrawingArea getDrawingAreaStructbool transferOwnership false.
    [Show full text]
  • Writing Applications with GTK+ 1 Introduction
    + Writing Applications with GTK Owen Taylor April Introduction Graphical user interfaces have b ecome almost universally familiar However it may b e worth saying a few words ab out how graphical user interfaces work in Linux and X from the p oint of view of the programmer The X server is resp onsible for only the simplest op erations of drawing graphics and text on the screen and for keeping track of the users mouse and keyboard actions Pro grams communicate with the server via the Xlib library However programming applications in straight Xlib would b e a tremendous chore Since Xlib provides only basic drawing commands each application would have to provide their own co de to user interface elements such as buttons or menus Such user interface elemenets are called widgets To avoid such a lab orious job and to provide consistancy b etween dierent applications the normal practice is to use a to olkit a library that builds on top of Xlib and handles the details of the user interface The traditional choices for such a to olkit have b een two libraries built up on X Intrinsics libXt library distributed with X the Athena Widgets which are distributed with X and Mo 1 tif However Xt is complicated to learn and use the Athena Widgets havent lo oked stylish since and Motif while somewhat more up to date is large slow has an app earance disliked by many p eople and most imp ortantly is a proprietary pro duct without freely available source co de For these reasons and others much recent development has fo cused on to olk its that build directly
    [Show full text]
  • Current Status of Win32 Gdk Implementation
    Current status of Win32 Gdk implementation Bertrand Bellenot - [email protected] Features (recall) ! Same environment on every system : ! Same look and feel on every platform. ! Simplify the code maintenance : ! No need to care about a « windows specific code ». ! Simplify functionality extension : ! No need to implement the code twice, once for windows and once for other OS. ! Only use TVirtualX. Actual Status (recall) ! The actual code uses a modified version of gdk and glib, the GIMP low-level libraries ported on win32. In practice, this means that we only need to link with gdk.lib, glib.lib and iconv.dll as additional libraries (hopefully less in the future). These libraries are under LGPL, so there are no licensing issues in using and distributing them. ! As original version of gdk was not doing everything needed by root (as font orientation!), I did have to slightly modify the original code. Points fixed since last year ! Some characters were not displayed. " ! Some problems with icon’s transparency. " ! The event handling was not perfect. " ! OpenGL was not working. " Events handling architecture (actual) TSystem CINT TGClient TVirtualX Gdk Threads issue ! From gdk developper FAQ : ! Without some major restructuring in GDK-Win32, I don't think there is any chance that GTK+ would work, in general, in a multi-threaded app, with different threads accessing windows created by other threads. ! One problem is that each thread in Windows have its own message queue. GDK-Win32 currently uses just one "message pump" in the main thread. It will never see messages for windows created by other threads. Threads issue ! As gdk is not thread safe, I had to create a separate thread from within the gdk calls are made.
    [Show full text]
  • The GNOME Desktop Environment
    The GNOME desktop environment Miguel de Icaza ([email protected]) Instituto de Ciencias Nucleares, UNAM Elliot Lee ([email protected]) Federico Mena ([email protected]) Instituto de Ciencias Nucleares, UNAM Tom Tromey ([email protected]) April 27, 1998 Abstract We present an overview of the free GNU Network Object Model Environment (GNOME). GNOME is a suite of X11 GUI applications that provides joy to users and hackers alike. It has been designed for extensibility and automation by using CORBA and scripting languages throughout the code. GNOME is licensed under the terms of the GNU GPL and the GNU LGPL and has been developed on the Internet by a loosely-coupled team of programmers. 1 Motivation Free operating systems1 are excellent at providing server-class services, and so are often the ideal choice for a server machine. However, the lack of a consistent user interface and of consumer-targeted applications has prevented free operating systems from reaching the vast majority of users — the desktop users. As such, the benefits of free software have only been enjoyed by the technically savvy computer user community. Most users are still locked into proprietary solutions for their desktop environments. By using GNOME, free operating systems will have a complete, user-friendly desktop which will provide users with powerful and easy-to-use graphical applications. Many people have suggested that the cause for the lack of free user-oriented appli- cations is that these do not provide enough excitement to hackers, as opposed to system- level programming. Since most of the GNOME code had to be written by hackers, we kept them happy: the magic recipe here is to design GNOME around an adrenaline response by trying to use exciting models and ideas in the applications.
    [Show full text]
  • Fundamentals of Xlib Programming by Examples
    Fundamentals of Xlib Programming by Examples by Ross Maloney Contents 1 Introduction 1 1.1 Critic of the available literature . 1 1.2 The Place of the X Protocol . 1 1.3 X Window Programming gotchas . 2 2 Getting started 4 2.1 Basic Xlib programming steps . 5 2.2 Creating a single window . 5 2.2.1 Open connection to the server . 6 2.2.2 Top-level window . 7 2.2.3 Exercises . 10 2.3 Smallest Xlib program to produce a window . 10 2.3.1 Exercises . 10 2.4 A simple but useful X Window program . 11 2.4.1 Exercises . 12 2.5 A moving window . 12 2.5.1 Exercises . 15 2.6 Parts of windows can disappear from view . 16 2.6.1 Testing overlay services available from an X server . 17 2.6.2 Consequences of no server overlay services . 17 2.6.3 Exercises . 23 2.7 Changing a window’s properties . 23 2.8 Content summary . 25 3 Windows and events produce menus 26 3.1 Colour . 26 3.1.1 Exercises . 27 i CONTENTS 3.2 A button to click . 29 3.3 Events . 33 3.3.1 Exercises . 37 3.4 Menus . 37 3.4.1 Text labelled menu buttons . 38 3.4.2 Exercises . 43 3.5 Some events of the mouse . 44 3.6 A mouse behaviour application . 55 3.6.1 Exercises . 58 3.7 Implementing hierarchical menus . 58 3.7.1 Exercises . 67 3.8 Content summary . 67 4 Pixmaps 68 4.1 The pixmap resource .
    [Show full text]
  • GTK Lesson 3: Containers
    CSci493.70 Graphical User Interface Programming Prof. Stewart Weiss Lesson 3: Containers Lesson 3: Containers 1 Container Widgets and Packing When you design an application with a graphical user interface, you put various widgets inside of one another and implicitly dene a hierarchy of what's inside of what. This is a containment hierarchy. Some of the widgets you use have specic purposes, such as buttons, text entry boxes, and menus. If you design your GUI on paper, you draw these widgets where you want them and making them the sizes that you want them to be. However, getting them to be in those specic positions with their specic sizes using a library like GTK+ requires that you use widgets whose primary purpose is for laying out other widgets. These widgets are called container widgets. In Lesson 2, we introduced the GtkContainer class, which is the ancestral class of all container widgets and which we now cover in more detail. Recall that containers can be partitioned into two categories: (1) those that can hold only a single child widget, and (2) those that can hold more than one. Containers that can contain only a single widget are called decorator containers, because their principal purpose is to add functionality and decorative eects to the child widget. Containers that can hold several children are called layout containers, because they are used primarily for laying out the child widgets within their (GDK) windows. Layout containers assign sizes and positions to their children. 1.1 The GtkContainer Class Before we look at their concrete subclasses, we will examine what functionality and properties GtkContainers possess.
    [Show full text]
  • The Scite – TEX Integration
    Hans Hagen VOORJAAR 2004 21 The Scite – TEX integration Abstract Editors are a sensitive, often emotional subject. Some editors have exactly the properties a software designer or a writer desires and one gets attached to it. Still, most computer experts such as TEX users often are use three or more different editors each day. Scite is a modern programmers editor which is very flexible, very configurable, and easily extended. We integrated Scite with TEX, CONTEXT, LATEX, METAPOST and viewer and succeeded in that it is now possible to design and write your texts, manuscripts, reports, manuals and books with the Scite editor without having to leave the editor to compile and view your work. The article describes what is available and what you need with special emphasis on highlighting commands with lexers. About Scite Scite is a source code editor written by Neil Hodgson. After playing with several editors we found that this editor is quite configurable and extendible. At PRAGMA ADE we use TEXEDIT, an editor written long ago in Niklaus Wirth’s MODULA as well as a platform independent reimplementation of it called TEXWORK written in PERL/TK. Although our editors possess some functionality that is not (yet) present in Scite, we decided to use Scite because it frees us from the editor maintenance chore. Installing Scite Installing Scite is straightforward. We assume below that you use MS WINDOWS but for other operating systems installation is not much different. First you need to fetch the archive from: www.scintilla.org The MS WINDOWS binaries are in wscite.zip, and you can unzip this in any direc- tory as long as the binary executable ends up in your PATH or as shortcut icon on your desktop.
    [Show full text]
  • The Glib/GTK+ Development Platform
    The GLib/GTK+ Development Platform A Getting Started Guide Version 0.8 Sébastien Wilmet March 29, 2019 Contents 1 Introduction 3 1.1 License . 3 1.2 Financial Support . 3 1.3 Todo List for this Book and a Quick 2019 Update . 4 1.4 What is GLib and GTK+? . 4 1.5 The GNOME Desktop . 5 1.6 Prerequisites . 6 1.7 Why and When Using the C Language? . 7 1.7.1 Separate the Backend from the Frontend . 7 1.7.2 Other Aspects to Keep in Mind . 8 1.8 Learning Path . 9 1.9 The Development Environment . 10 1.10 Acknowledgments . 10 I GLib, the Core Library 11 2 GLib, the Core Library 12 2.1 Basics . 13 2.1.1 Type Definitions . 13 2.1.2 Frequently Used Macros . 13 2.1.3 Debugging Macros . 14 2.1.4 Memory . 16 2.1.5 String Handling . 18 2.2 Data Structures . 20 2.2.1 Lists . 20 2.2.2 Trees . 24 2.2.3 Hash Tables . 29 2.3 The Main Event Loop . 31 2.4 Other Features . 33 II Object-Oriented Programming in C 35 3 Semi-Object-Oriented Programming in C 37 3.1 Header Example . 37 3.1.1 Project Namespace . 37 3.1.2 Class Namespace . 39 3.1.3 Lowercase, Uppercase or CamelCase? . 39 3.1.4 Include Guard . 39 3.1.5 C++ Support . 39 1 3.1.6 #include . 39 3.1.7 Type Definition . 40 3.1.8 Object Constructor . 40 3.1.9 Object Destructor .
    [Show full text]
  • Drawing in GTK+
    CSci493.70 Graphical User Interface Programming Prof. Stewart Weiss Drawing in GTK+ Drawing in GTK+ Background In order to understand how to draw in GTK, you rst have to understand something about how GTK draws widgets, because how GTK draws widgets has an important role in how you design your drawing application. An understanding of how GTK draws widgets is also required if you ever plan to build your own custom widgets. Windows and Clipping Most windowing systems are designed around the idea that an application's visual display lies within a rectangular region on the screen called its window. The windowing system, e.g. Gnome or KDE or Explorer, does not automatically save the graphical content of an application's windows; instead it asks the application itself to repaint 1 its windows whenever it is needed. For example, if a window that is stacked below other windows gets raised to the top, then a client program has to repaint the area that was previously obscured. When the windowing system asks a client program to redraw part of a window, it sends an exposure event to the program that contains that window. An exposure event is simply an event sent from the underlying windowing system to a widget to notify it that it must redraw itself. In this context, a "window" means "a rectangular region with automatic clipping", not a top-level application window. Clipping is the act of removing portions of a window that do not need to be redrawn, or looked at the other way, it is determining which are the only regions of a window that must be redrawn.
    [Show full text]