Python Programming
Python Programming RSS feed-
Django 1.5, Python 3.3, and Virtual Environments
Today I wanted to tinker around with the experimental support for Python 3 in Django 1.5 (alpha). So, my first question was, how well does
virtualenvplay with Python 3? And that's when I learned about the new(ish)venvmodule available in Python 3.3. -
A BASE_URL Template Variable in Django
Sometimes a Django template needs to reference the domain's base URL. Hard-coding the URL is obviously a bad idea. I like to use a context variable named
BASE_URLin my templates. A simple context processor creates this variable based on the request. -
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.
