From 69542d8de39648a812457b9ac4309cf1bb22b2c1 Mon Sep 17 00:00:00 2001 From: epage Date: Tue, 28 Apr 2009 02:54:45 +0000 Subject: [PATCH] Improving exception outputing git-svn-id: file:///svnroot/ejpi/trunk@32 df6cc7de-23d0-4ae0-bb86-c17aa67b2a9d --- src/ejpi.glade | 55 +++++++++++++++++++++++++++++++++++++++------------ src/ejpi_glade.py | 33 ++++++++++++++++++++++++++++--- src/gtk_toolbox.py | 14 ++++++++++--- src/gtkhistory.py | 2 ++ src/history.py | 2 +- support/builddeb.py | 5 +++-- 6 files changed, 89 insertions(+), 22 deletions(-) diff --git a/src/ejpi.glade b/src/ejpi.glade index 1b55041..d07f595 100644 --- a/src/ejpi.glade +++ b/src/ejpi.glade @@ -1,7 +1,7 @@ - - - + + + Cluttered Calc 800 @@ -22,8 +22,8 @@ True + gtk-quit True - gtk-quit True True @@ -42,9 +42,30 @@ True + + gtk-copy + True + True + True + + + + + Copy Equation + True + False + + + True + gtk-copy + + + + + + gtk-paste True - gtk-paste True True @@ -52,12 +73,13 @@ + Clear _History True - _Clear History True + False - + True gtk-delete @@ -78,8 +100,8 @@ True + gtk-about True - gtk-about True True @@ -92,6 +114,7 @@ False + 0 @@ -108,6 +131,7 @@ False + 0 @@ -125,12 +149,15 @@ False False + 0 True True + end + True 1 @@ -139,7 +166,6 @@ True - Close Error Message gtk-close @@ -160,8 +186,8 @@ True True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC + automatic + automatic True @@ -182,6 +208,9 @@ + + 0 + @@ -202,7 +231,7 @@ True True - GTK_POS_BOTTOM + bottom True @@ -213,8 +242,8 @@ None - tab False + tab diff --git a/src/ejpi_glade.py b/src/ejpi_glade.py index 5fb1739..afbf7ef 100755 --- a/src/ejpi_glade.py +++ b/src/ejpi_glade.py @@ -12,6 +12,7 @@ @todo Expanded copy/paste (Unusure how far to go) @li Copy formula, value, serialized, mathml, latex? @li Paste serialized, value? +@bug Has the same Maemo tab color bug as DialCentral Some useful things on Maemo @li http://maemo.org/api_refs/4.1/libosso-2.16-1/group__Statesave.html @@ -213,6 +214,8 @@ class Calculator(object): "on_about": self._on_about_activate, } self._widgetTree.signal_autoconnect(callbackMapping) + self._widgetTree.get_widget("copyMenuItem").connect("activate", self._on_copy) + self._widgetTree.get_widget("copyEquationMenuItem").connect("activate", self._on_copy_equation) if self.__window: if hildon is None: @@ -309,6 +312,22 @@ class Calculator(object): finally: gtk.main_quit() + def _on_copy(self, *args): + try: + equationNode = self.__history.history.peek() + result = str(equationNode.evaluate()) + self._clipboard.set_text(result) + except StandardError, e: + self.__errorDisplay.push_exception() + + def _on_copy_equation(self, *args): + try: + equationNode = self.__history.history.peek() + equation = str(equationNode) + self._clipboard.set_text(equation) + except StandardError, e: + self.__errorDisplay.push_exception() + def _on_paste(self, *args): contents = self._clipboard.wait_for_text() self.__userEntry.append(contents) @@ -348,9 +367,17 @@ class Calculator(object): dlg.set_name(self.__pretty_app_name__) dlg.set_version(self.__version__) dlg.set_copyright("Copyright 2008 - LGPL") - dlg.set_comments("") - dlg.set_website("") - dlg.set_authors([""]) + dlg.set_comments(""" +ejpi A Touch Screen Optimized RPN Calculator for Maemo and Linux. + +How do I use this? +The buttons are all pie-menus. Clicking on them will give you the default (center) behavior. If you click and hold, the menu gets displayed showing what other actions you can then perform. While still holding, just drag in the direction of one of these actions. + +This is RPN, where are the swap, roll, etc operations? +This also uses a touch screen, go ahead and feel adventerous by dragging the stack items around. +""") + dlg.set_website("http://ejpi.garage.maemo.org") + dlg.set_authors(["Ed Page"]) dlg.run() dlg.destroy() diff --git a/src/gtk_toolbox.py b/src/gtk_toolbox.py index ef8805d..3abcdcb 100644 --- a/src/gtk_toolbox.py +++ b/src/gtk_toolbox.py @@ -1,5 +1,7 @@ #!/usr/bin/python +import sys +import traceback import warnings import gobject @@ -33,9 +35,15 @@ class ErrorDisplay(object): else: self.__show_message(message) - def push_exception(self, exception): - self.push_message(exception.message) - warnings.warn(exception, stacklevel=3) + def push_exception(self, exception = None): + if exception is None: + userMessage = str(sys.exc_value) + warningMessage = str(traceback.format_exc()) + else: + userMessage = str(exception) + warningMessage = str(exception) + self.push_message(userMessage) + warnings.warn(warningMessage, stacklevel=3) def pop_message(self): if 0 < len(self.__messages): diff --git a/src/gtkhistory.py b/src/gtkhistory.py index d61739a..0b019c8 100755 --- a/src/gtkhistory.py +++ b/src/gtkhistory.py @@ -3,6 +3,8 @@ """ http://www.grigoriev.ru/svgmath/ (MathML->SVG in Python) http://helm.cs.unibo.it/mml-widget/ (MathML widget in C++) + +@bug Columns auto-expand with large items but when they are gone, the columns don't auto-shrink """ diff --git a/src/history.py b/src/history.py index 999a0be..877d2b9 100644 --- a/src/history.py +++ b/src/history.py @@ -150,7 +150,7 @@ class RpnCalcHistory(object): node = self._apply_operation(Node) return node except StandardError, e: - self.errorReporter.push_exception(e) + self.errorReporter.push_exception() return None def serialize_stack(self): diff --git a/support/builddeb.py b/support/builddeb.py index 3643ece..41f113c 100755 --- a/support/builddeb.py +++ b/support/builddeb.py @@ -4,14 +4,15 @@ from py2deb import * __appname__ = "ejpi" -__description__ = "RPN Calculator" +__description__ = "A Touch Screen Optimized RPN Calculator using Pie Menus" __author__ = "Ed Page" __email__ = "eopage@byu.net" __version__ = "0.9.3" __build__ = 0 __changelog__ = ''' 0.9.3 - "" - + * Added +/-, !, sq, and sqrt functions + * Bug fixes 0.9.2 - "" * Experimenting with faster startup by including pyc files in package -- 1.7.9.5