Skip to content

Instantly share code, notes, and snippets.

John Stowers nzjrs

Block or report user

Report or block nzjrs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nzjrs
nzjrs / gtk-theme-swatch.py
Created Jan 21, 2009
PyGtk widget that displays color swatches according you your Gtk theme
View gtk-theme-swatch.py
#!/usr/bin/env python
# gtk-theme-swatch: A PyGtk widget that displays the color swatches of all
# gtk.Styles, in all states. Useful for designing themes
# author: John Stowers <john.stowers@gmail.com>
import gtk
class ThemeSwatch(gtk.DrawingArea):
SWATCH_SIZE = 50 #swatch size
@nzjrs
nzjrs / FooThread.py
Created Jan 25, 2009
PyGtk threading example
View FooThread.py
# Demo application showing how once can combine the python
# threading module with GObject signals to make a simple thread
# manager class which can be used to stop horrible blocking GUIs.
#
# (c) 2008, John Stowers <john.stowers@gmail.com>
#
# This program serves as an example, and can be freely used, copied, derived
# and redistributed by anyone. No warranty is implied or given.
import gtk
import gobject
@nzjrs
nzjrs / emit.py
Created Feb 2, 2009
Python example demonstrating when callbacks are run in a threaded environment
View emit.py
#!/usr/bin/env python
# Python example demonstrating when callbacks are run in a threaded environment
# John Stowers
import threading
import thread
import time
import gobject
import gtk
@nzjrs
nzjrs / mem_usage.py
Created Feb 5, 2009
Prints the memory usage (including private and dirty) for a given PID
View mem_usage.py
#!/usr/bin/env python
# Prints the memory usage (including private and dirty) for a given PID
#
import sys
import re
def permute(args):
ret = []
if args:
@nzjrs
nzjrs / animated-status-icon.py
Created Jun 27, 2009
Animated Gtk+ StatusIcon
View animated-status-icon.py
#!/usr/bin/env python
"""
Animated Gtk+ StatusIcon
Given an icon name or path, animates the icon in a number of ways, rotating,
shrinking, saturating it, etc.
Inspiration from:
http://groups.google.com/group/sage-devel/browse_thread/thread/f9aeba22ac171082
"""
@nzjrs
nzjrs / gtk-curve-test.py
Created Jun 30, 2009
Demo for testing gtk.Curve
View gtk-curve-test.py
#!/usr/bin/env python
# Demo for testing gtk.Curve
# John Stowers 2009
import random
import gtk
class UI:
TYPES = (gtk.CURVE_TYPE_LINEAR, gtk.CURVE_TYPE_SPLINE, gtk.CURVE_TYPE_FREE)
@nzjrs
nzjrs / test-rtgraph.py
Created Jul 12, 2009
python rtgraph demo
View test-rtgraph.py
#!/usr/bin/env python
# A simple example of using multiple rtgraph HScrollLineGraph widgets
# Micah Dowty <micah@picogui.org>, John Stowers
#
import gtk
import time, math, re
import gs.ui.rtgraph as rtgraph
windows = []
@nzjrs
nzjrs / curses-demo.py
Created Aug 8, 2009
Helper for using curses from python
View curses-demo.py
#!/usr/bin/env python
# This module provides a 'with' for using curses in Python.
# from: http://www.finalcog.com/python-with-curses-with_curses
from __future__ import with_statement
import curses
class WithCurses(object):
"""
@nzjrs
nzjrs / datedifference.py
Created Oct 11, 2009
Humanize date differences
View datedifference.py
#!/usr/bin/env python
# This function prints the difference between two python datetime objects
# in a more human readable form
#
# Adapted from: http://www.chimeric.de/blog/2008/0711_smart_dates_in_python
def humanize_date_difference(now, otherdate=None, offset=None):
if otherdate:
dt = otherdate - now
offset = dt.seconds + (dt.days * 60*60*24)
@nzjrs
nzjrs / fix-update-copyright-headers.py
Created Oct 13, 2009
Update or add copyright headers to source files.
View fix-update-copyright-headers.py
You can’t perform that action at this time.