GTK+ Programming
GTK+ Programming RSS feed-
No Package Error with Jhbuild in Ubuntu 12.10 64
While building GTK+ with jhbuild on 64-bit Ubuntu 12.10 I encountered an issue in which the
pkgconfigfiles are not found and thus you get a bunch of errors along the lines of:No package 'libxml-2.0' foundIf the corresponding
-devpackage is installed the missing.pcfiles are in/usr/lib/x86_64-linux-gnu/pkgconfig/then the fix is to simply specify that directory in thePKG_CONFIG_PATHenvironment variable:export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig/ -
Close Buttons on Gtk.Notebook Tabs
Every now and then I see somebody ask how they can add close buttons to the tabs of a
Gtk.Notebook. The trick is to make that button small enough so that it doesn't effect the size of the tab too much. Here is how it can be done in GTK+ 3 with the help of some CSS styles.
-
Simple "Hello World" in Python with GTK+ 3
In an old post I showed a "Hello World" application with Python and GTK+ 3 using the
Gtk.Applicationobject. I should have named that post something else as new programmers are intimidated by it's complexity.So, here is a simple "Hello World" application in GTK+ 3.
from gi.repository import Gtk window = Gtk.Window(title="Hello World") window.connect("destroy", lambda w: Gtk.main_quit()) window.add(Gtk.Label("Hello World!")) window.show_all() Gtk.main()If you are new to GTK+ programming in Python, The Python GTK+ 3 Tutorial is a good place to start.
-
GTK Bloatpad in Python
It's been a while since I've tinkered with the
GtkApplicationobject in GTK+ 3 and I was intrigued by the "appmenu" and "menubar" properties. The reference docs for GtkApplication includes a sample application called "Bloatpad" which demonstratesGtkApplicationandGtkApplicationWindow.Basically, the app menu is for actions that are application wide, and the menubar is for actions that are specific to each window instance. GTK+ will put the menus in the right place depending on the platform. For example, OS X puts both menus on the top of the screen, XFCE has both menus on each window, GNOME has the app menu at the top of the screen and the menubar on each window.
So, I ported Bloatpad to Python and it almost works. I put the source code for Python Bloatpad on Github.
-
Asynchronously Read Files in Python with Gio
Most people will learn how to read and write to files in Python using the built-in file objects. That works great for simple read/write operations on the local filesystem. However, if you need a more advanced I/O library, take a look at Gio.
Gio provides an abstract I/O API without having to know what the underlying filesystem is. In other words, you can read files from various sources including http, ftp, ssh, etc. The Gio library has support for asynchronous operations and access to a ton of other useful information (mime types, themed icon names, etc.).
Here is a closer look at asynchronously reading files in Python using Gio.
