Pygtk 2.0 Tutorial

Total Page:16

File Type:pdf, Size:1020Kb

Pygtk 2.0 Tutorial PyGTK 2.0 Tutorial John Finlay October 7, 2012 PyGTK 2.0 Tutorial by John Finlay Published March 2, 2006 ii Contents 1 Introduction 1 1.1 Exploring PyGTK . .2 2 Getting Started 5 2.1 Hello World in PyGTK . .7 2.2 Theory of Signals and Callbacks . .9 2.3 Events . 10 2.4 Stepping Through Hello World . 11 3 Moving On 15 3.1 More on Signal Handlers . 15 3.2 An Upgraded Hello World . 15 4 Packing Widgets 19 4.1 Theory of Packing Boxes . 19 4.2 Details of Boxes . 20 4.3 Packing Demonstration Program . 22 4.4 Packing Using Tables . 27 4.5 Table Packing Example . 28 5 Widget Overview 31 5.1 Widget Hierarchy . 31 5.2 Widgets Without Windows . 34 6 The Button Widget 35 6.1 Normal Buttons . 35 6.2 Toggle Buttons . 38 6.3 Check Buttons . 40 6.4 Radio Buttons . 42 7 Adjustments 45 7.1 Creating an Adjustment . 45 7.2 Using Adjustments the Easy Way . 45 7.3 Adjustment Internals . 46 8 Range Widgets 49 8.1 Scrollbar Widgets . 49 8.2 Scale Widgets . 49 8.2.1 Creating a Scale Widget . 49 8.2.2 Methods and Signals (well, methods, at least) . 50 8.3 Common Range Methods . 50 8.3.1 Setting the Update Policy . 50 8.3.2 Getting and Setting Adjustments . 51 8.4 Key and Mouse Bindings . 51 8.5 Range Widget Example . 51 9 Miscellaneous Widgets 57 9.1 Labels . 57 9.2 Arrows . 60 9.3 The Tooltips Object . 61 9.4 Progress Bars . 63 9.5 Dialogs . 67 9.5.1 Message Dialogs . 68 9.6 Images . 68 9.6.1 Pixmaps . 71 iii CONTENTS 9.7 Rulers . 77 9.8 Statusbars . 79 9.9 Text Entries . 81 9.10 Spin Buttons . 83 9.11 Combo Widget . 89 9.12 Calendar . 90 9.13 Color Selection . 96 9.14 File Selections . 100 9.15 Font Selection Dialog . 102 10 Container Widgets 105 10.1 The EventBox . 105 10.2 The Alignment widget . 106 10.3 Fixed Container . 107 10.4 Layout Container . 108 10.5 Frames . 111 10.6 Aspect Frames . 113 10.7 Paned Window Widgets . 115 10.8 Viewports . 118 10.9 Scrolled Windows . 118 10.10Button Boxes . 120 10.11Toolbar . 124 10.12Notebooks . 128 10.13Plugs and Sockets . 133 10.13.1 Plugs . 133 10.13.2 Sockets . 134 11 Menu Widget 137 11.1 Manual Menu Creation . 137 11.2 Manual Menu Example . 139 11.3 Using ItemFactory . 141 11.4 Item Factory Example . 141 12 Drawing Area 145 12.1 Graphics Context . 145 12.2 Drawing Methods . 149 13 TextView Widget 155 13.1 TextView Overview . 155 13.2 TextViews . 155 13.3 Text Buffers . 160 13.3.1 TextBuffer Status Information . 161 13.3.2 Creating TextIters . 161 13.3.3 Text Insertion, Retrieval and Deletion . 162 13.3.4 TextMarks . 163 13.3.5 Creating and Applying TextTags . 163 13.3.6 Inserting Images and Widgets . 164 13.4 Text Iters . 165 13.4.1 TextIter Attributes ..
Recommended publications
  • In Silico Docking Analysis of CCL28 (CC Motif Chemokine Ligand
    F1000Research 2019, 8:313 Last updated: 21 SEP 2021 RESEARCH ARTICLE In silico docking analysis of CCL28 (C-C motif chemokine ligand 28) and astragalin as the potential inhibitor of rheumatoid arthritis [version 1; peer review: 1 approved, 1 approved with reservations] Sadaf Noor, Syeda Tahira Qousain, Syed Aun Muhammad Institute of Molecular Biology and Biotechnology, Bahauddin Zakariya University, Multan, Punjab, 60800, Pakistan v1 First published: 20 Mar 2019, 8:313 Open Peer Review https://doi.org/10.12688/f1000research.18541.1 Latest published: 20 Mar 2019, 8:313 https://doi.org/10.12688/f1000research.18541.1 Reviewer Status Invited Reviewers Abstract Background: Rheumatoid arthritis is an inflammatory and chronic 1 2 disease of the joints affecting 1% of the world’s population. Women are three times more likely to be affected than men. Many drugs are version 1 being used for the treatment of rheumatoid arthritis but they often 20 Mar 2019 report report have severe side effects. C-C motif chemokine ligand 28 (CCL28) recruits leukocytes and other proinflammatory factors to the site of 1. Ihsan Ul Haq, Quaid-i-Azam University, joint inflammation. The purpose of the present research is the computational evaluation of astragalin, a natural flavonoid extracted Islamabad, Pakistan from black tea, as an inhibitor of CCL28 by in silico docking. 2. Sagarika Biswas, Institute of Genomics and Methods: The three-dimensional structure of CCL28 to act as a molecular target was obtained from the Protein Data Bank (PDB ID: Integrative Biology, New Delhi, India 6CWS). The quality of the CCL28 structure was assessed using Phyre2 and Molecular Operating Environment (MOE) software was used for Any reports and responses or comments on the binding affinity analysis.
    [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]
  • CHERI C/C++ Programming Guide
    UCAM-CL-TR-947 Technical Report ISSN 1476-2986 Number 947 Computer Laboratory CHERI C/C++ Programming Guide Robert N. M. Watson, Alexander Richardson, Brooks Davis, John Baldwin, David Chisnall, Jessica Clarke, Nathaniel Filardo, Simon W. Moore, Edward Napierala, Peter Sewell, Peter G. Neumann June 2020 15 JJ Thomson Avenue Cambridge CB3 0FD United Kingdom phone +44 1223 763500 https://www.cl.cam.ac.uk/ c 2020 Robert N. M. Watson, Alexander Richardson, Brooks Davis, John Baldwin, David Chisnall, Jessica Clarke, Nathaniel Filardo, Simon W. Moore, Edward Napierala, Peter Sewell, Peter G. Neumann, SRI International This work was supported by the Defense Advanced Research Projects Agency (DARPA) and the Air Force Research Laboratory (AFRL), under contracts FA8750-10-C-0237 (“CTSRD”) and HR0011-18-C-0016 (“ECATS”). The views, opinions, and/or findings contained in this report are those of the authors and should not be interpreted as representing the official views or policies of the Department of Defense or the U.S. Government. This work was supported in part by the Innovate UK project Digital Security by Design (DSbD) Technology Platform Prototype, 105694. This project has received funding from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No 789108), ERC Advanced Grant ELVER. We also acknowledge the EPSRC REMS Programme Grant (EP/K008528/1), Arm Limited, HP Enterprise, and Google, Inc. Approved for Public Release, Distribution Unlimited. Technical reports published by the University of Cambridge Computer Laboratory are freely available via the Internet: https://www.cl.cam.ac.uk/techreports/ ISSN 1476-2986 3 Abstract This document is a brief introduction to the CHERI C/C++ programming languages.
    [Show full text]
  • Optimizing the Use of High Performance Software Libraries
    Optimizing the Use of High Performance Software Libraries Samuel Z. Guyer and Calvin Lin The University of Texas at Austin, Austin, TX 78712 Abstract. This paper describes how the use of software libraries, which is preva- lent in high performance computing, can benefit from compiler optimizations in much the same way that conventional computer languages do. We explain how the compilation of these informal languages differs from the compilation of more conventional computer languages. In particular, such compilation requires precise pointer analysis, requires domain-specific information about the library’s seman- tics, and requires a configurable compilation scheme. Finally, we show that the combination of dataflow analysis and pattern matching form a powerful tool for performing configurable optimizations. 1 Introduction High performance computing, and scientific computing in particular, relies heavily on software libraries. Libraries are attractive because they provide an easy mechanism for reusing code. Moreover, each library typically encapsulates a particular domain of ex- pertise, such as graphics or linear algebra, and the use of such libraries allows program- mers to think at a higher level of abstraction. In many ways, libraries are simply in- formal domain-specific languages whose only syntactic construct is the procedure call. This procedural interface is significant because it couches these informal languages in a familiar form, which is less imposing than a new computer language that introduces new syntax. Unfortunately, while libraries are not viewed as languages by users, they also are not viewed as languages by compilers. With a few exceptions, compilers treat each invocation of a library routine the same as any other procedure call.
    [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]
  • IP Log for Eclipse.Platform Release 4.0, July 2010 Licenses
    IP Log for eclipse.platform Release 4.0, July 2010 Licenses • Eclipse Public License v1.0 Third-Party Code CQ Third-Party Code License Use ICU4J (core and extended ICU4J License (X License, 1065 function) and ICU4J MIT Style) Replacement plug-in Version: 3.6 ICU4J License (X License, 1116 ICU4J Version: 3.4.5.20061213 MIT Style) 1153 JSch 0.1.31 Version: 0.1.31 New BSD license Apache Lucene Version: 1.9.1 243 (Core+Contrib Analyzers Apache License, 2.0 Analysis Src) 257 APT Version: 1 New BSD license Mozilla Public License 1.1 (MPL), MIT Style with No 262 Cairo Version: 1.0.2 Endorsement Clause, Historical Permissive Notice & Disclaimer ICU4J License (X License, 280 ICU4J Version: 3.4 MIT Style) ICU4J License (X License, 281 ICU4J Version: 3.4.3 MIT Style) 293 jsch Version: 0.1.28 New BSD license 308 PNG unload Version: 1 MIT license 1232 Apache Ant Version: 1.7.0 Apache License, 2.0 ICU4J and ICU4J Replacement ICU4J License (X License, 1367 Version: 3.6.1 MIT Style) Olsen time zone data Version: 1368 Public Domain 2007e Work derived from IJG JPEG 1596 IJG License Version: Release 6b,337 unmodified 1826 JSch 0.1.35 New BSD license source & binary ICU4J and ICU4J replacement MIT License with "no unmodified 1919 Version: 3.8.1 edorsement" clause source & binary unmodified 2014 jsch Version: 0.1.37 New BSD license source & binary XHTML DTDs Version: unmodified 2044 W3C Document License Versions 1.0 and 1.1 (PB CQ331) source org.apache.ant Version: 1.6.5 2404 (ATO CQ1013) (using Orbit Apache License, 2.0 CQ2209) org.apache.lucene Version: 1.4.3 2405 (Core Source Only) (ATO Apache License, 2.0 CQ1014) (using Orbit CQ2210) Junit Version: 3.8.2 (ATO 2406 Common Public License 1.0 CQ299) (using Orbit CQ2206) Historical support for Java SSH modified 2410 Applet + Blowfish Version - v.
    [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]
  • 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]
  • Eagle: Tcl Implementation in C
    Eagle: Tcl Implementation in C# Joe Mistachkin <[email protected]> 1. Abstract Eagle [1], Extensible Adaptable Generalized Logic Engine, is an implementation of the Tcl [2] scripting language for the Microsoft Common Language Runtime (CLR) [3]. It is designed to be a universal scripting solution for any CLR based language, and is written completely in C# [4]. Su- perficially, it is similar to Jacl [5], but it was written from scratch based on the design and imple- mentation of Tcl 8.4 [6]. It provides most of the functionality of the Tcl 8.4 interpreter while bor- rowing selected features from Tcl 8.5 [7] and the upcoming Tcl 8.6 [8] in addition to adding en- tirely new features. This paper explains how Eagle adds value to both Tcl/Tk and CLR-based applications and how it differs from other “dynamic languages” hosted by the CLR and its cousin, the Microsoft Dy- namic Language Runtime (DLR) [9]. It then describes how to use, integrate with, and extend Ea- gle effectively. It also covers some important implementation details and the overall design phi- losophy behind them. 2. Introduction This paper presents Eagle, which is an open-source [10] implementation of Tcl for the Microsoft CLR written entirely in C#. The goal of this project was to create a dynamic scripting language that could be used to automate any host application running on the CLR. 3. Rationale and Motivation Tcl makes it relatively easy to script applications written in C [11] and/or C++ [12] and so can also script applications written in many other languages (e.g.
    [Show full text]
  • SSC Reference Manual SDK 2017-1-17, Version 170
    SSC Reference Manual SDK 2017-1-17, Version 170 Aron Dobos and Paul Gilman January 13, 2017 The SSC (SAM Simulation Core) software library is the collection of simu- lation modules used by the National Renewable Energy Laboratory’s System Advisor Model (SAM). The SSC application programming interface (API) al- lows software developers to integrate SAM’s modules into web and desktop applications. The API includes mechanisms to set input variable values, run simulations, and retrieve values of output variables. The SSC modules are available in pre-compiled binary dynamic libraries minimum system library de- pendencies for Windows, OS X, and Linux operating systems. The native API language is ISO-standard C, and language wrappers are available for C#, Java, MATLAB, Python, and PHP. The API and model implementations are thread- safe and reentrant, allowing the software to be used in a parallel computing environment. This document describes the SSC software architecture, modules and data types, provides code samples, introduces SDKtool, and describes the language wrappers. Contents 2 Contents 1 Overview4 1.1 Framework Description.............................. 4 1.2 Modeling an Energy System........................... 4 2 An Example: Running PVWatts5 2.1 Write the program skeleton ........................... 6 2.2 Create the data container ............................ 6 2.3 Assign values to the module input variables.................. 7 2.4 Run the module.................................. 7 2.5 Retrieve results from the data container and display them.......... 8 2.6 Cleaning up.................................... 8 2.7 Compile and run the C program ........................ 9 2.8 Some additional comments............................ 9 3 Data Variables9 3.1 Variable Names.................................. 10 3.2 Variable Types .................................
    [Show full text]