Taking in changes from other projects
authorEd Page <eopage@byu.net>
Tue, 5 May 2009 01:53:15 +0000 (20:53 -0500)
committerEd Page <eopage@byu.net>
Tue, 5 May 2009 01:53:15 +0000 (20:53 -0500)
Makefile
src/gtk_toolbox.py

index f23e6fd..f95ae6f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@ CTAGS=ctags-exuberant
 all: test
 
 run: $(OBJ)
-       $(SOURCE_PATH)/doneit_glade.py
+       $(SOURCE_PATH)/$(PROJET_NAME)_glade.py
 
 profile: $(OBJ)
        $(PROFILE_GEN) $(PROGRAM)
index c7738a3..5cf4931 100644 (file)
@@ -9,7 +9,7 @@
 
 import sys
 import traceback
-import datetime
+import functools
 import contextlib
 import warnings
 
@@ -126,6 +126,55 @@ class ContextHandler(object):
                self._respond(position)
 
 
+def make_idler(func):
+       """
+       Decorator that makes a generator-function into a function that will continue execution on next call
+       """
+       a = []
+
+       @functools.wraps(func)
+       def decorated_func(*args, **kwds):
+               if not a:
+                       a.append(func(*args, **kwds))
+               try:
+                       a[0].next()
+                       return True
+               except StopIteration:
+                       del a[:]
+                       return False
+
+       return decorated_func
+
+
+def asynchronous_gtk_message(original_func):
+       """
+       @note Idea came from http://www.aclevername.com/articles/python-webgui/
+       """
+
+       def execute(allArgs):
+               args, kwargs = allArgs
+               original_func(*args, **kwargs)
+
+       @functools.wraps(original_func)
+       def delayed_func(*args, **kwargs):
+               gobject.idle_add(execute, (args, kwargs))
+
+       return delayed_func
+
+
+def synchronous_gtk_message(original_func):
+       """
+       @note Idea came from http://www.aclevername.com/articles/python-webgui/
+       """
+
+       @functools.wraps(original_func)
+       def immediate_func(*args, **kwargs):
+               with gtk_lock():
+                       return original_func(*args, **kwargs)
+
+       return immediate_func
+
+
 class LoginWindow(object):
 
        def __init__(self, widgetTree):
@@ -243,11 +292,11 @@ class ErrorDisplay(object):
 
        def push_exception(self, exception = None):
                if exception is None:
-                       userMessage = sys.exc_value.message
-                       warningMessage = traceback.format_exc()
+                       userMessage = str(sys.exc_value)
+                       warningMessage = str(traceback.format_exc())
                else:
-                       userMessage = exception.message
-                       warningMessage = exception
+                       userMessage = str(exception)
+                       warningMessage = str(exception)
                self.push_message(userMessage)
                warnings.warn(warningMessage, stacklevel=3)
 
@@ -481,6 +530,7 @@ if __name__ == "__main__":
                win.show_all()
 
        if False:
+               import datetime
                cal = PopupCalendar(None, datetime.datetime.now())
                cal._popupWindow.connect("destroy", lambda w: gtk.main_quit())
                cal.run()