added errors dialog to show all error messages in flow graph
authorJosh Blum <josh@joshknows.com>
Fri, 18 Sep 2009 09:10:13 +0000 (02:10 -0700)
committerJosh Blum <josh@joshknows.com>
Fri, 18 Sep 2009 09:10:13 +0000 (02:10 -0700)
grc/gui/ActionHandler.py
grc/gui/Actions.py
grc/gui/Bars.py
grc/gui/Dialogs.py
grc/python/Param.py

index 361be1cf8f095dba401f85649e624b01cdc0e5d0..ee3e19a6c6628db3d4e79ab1a4facd3e85bc8a8d 100644 (file)
@@ -210,6 +210,8 @@ class ActionHandler:
                        Dialogs.HelpDialog()
                elif action == Actions.TYPES_WINDOW_DISPLAY:
                        Dialogs.TypesDialog(self.get_flow_graph().get_parent())
+               elif action == Actions.ERRORS_WINDOW_DISPLAY:
+                       Dialogs.ErrorsDialog(self.get_flow_graph())
                ##################################################
                # Param Modifications
                ##################################################
@@ -307,6 +309,7 @@ class ActionHandler:
                # Global Actions for all States
                ##################################################
                #update general buttons
+               Actions.ERRORS_WINDOW_DISPLAY.set_sensitive(not self.get_flow_graph().is_valid())
                Actions.ELEMENT_DELETE.set_sensitive(bool(self.get_flow_graph().get_selected_elements()))
                Actions.BLOCK_PARAM_MODIFY.set_sensitive(bool(self.get_flow_graph().get_selected_block()))
                Actions.BLOCK_ROTATE_CCW.set_sensitive(bool(self.get_flow_graph().get_selected_blocks()))
index b22279c1da12892649562571a23a16007eb30db1..1cc12a8194cac20121c86c2e33a2d7e0efbe2de1 100644 (file)
@@ -215,6 +215,11 @@ BLOCK_PASTE = Action(
        stock_id=gtk.STOCK_PASTE,
        keypresses=(gtk.keysyms.v, gtk.gdk.CONTROL_MASK),
 )
+ERRORS_WINDOW_DISPLAY = Action(
+       label='_Errors',
+       tooltip='Flowgraph error messages',
+       stock_id=gtk.STOCK_DIALOG_ERROR,
+)
 ABOUT_WINDOW_DISPLAY = Action(
        label='_About',
        tooltip='About this program',
index fff5ebc08d1b51f55ed2beab5c55b4cc609da328..17835eb004eabe92aabb5104095a16435804d363 100644 (file)
@@ -81,6 +81,9 @@ MENU_BAR_LIST = (
                None,
                Actions.BLOCK_PARAM_MODIFY,
        ]),
+       (gtk.Action('View', '_View', None, None), [
+               Actions.ERRORS_WINDOW_DISPLAY,
+       ]),
        (gtk.Action('Build', '_Build', None, None), [
                Actions.FLOW_GRAPH_GEN,
                Actions.FLOW_GRAPH_EXEC,
index 3cf617b92c8e03b1a06fdd6d6e457dd8a450f613..a8e7afb057a326381fe23cb5637f6756d905c4f8 100644 (file)
@@ -57,6 +57,20 @@ def MessageDialogHelper(type, buttons, title=None, markup=None):
        message_dialog.destroy()
        return response
 
+
+ERRORS_MARKUP_TMPL="""\
+#for $i, $err_msg in enumerate($errors)
+<b>Error $i:</b>
+$encode($err_msg.replace('\t', '  '))
+
+#end for"""
+def ErrorsDialog(flowgraph): MessageDialogHelper(
+       type=gtk.MESSAGE_ERROR,
+       buttons=gtk.BUTTONS_CLOSE,
+       title='Flowgraph Errors',
+       markup=Utils.parse_template(ERRORS_MARKUP_TMPL, errors=flowgraph.get_error_messages()),
+)
+
 class AboutDialog(gtk.AboutDialog):
        """A cute little about dialog."""
 
index 387fab5481af81c27692cd20169023a7deba58c9..1c151131526a9ca8f175d6841d25da4195adace2 100644 (file)
@@ -254,7 +254,7 @@ class Param(_Param, _GUIParam):
                elif t in ('raw', 'complex', 'real', 'int', 'complex_vector', 'real_vector', 'int_vector', 'hex', 'bool'):
                        #raise exception if python cannot evaluate this value
                        try: e = self.get_parent().get_parent().evaluate(v)
-                       except Exception, e: raise Exception, 'Value "%s" cannot be evaluated: %s'%(v, e)
+                       except Exception, e: raise Exception, 'Value "%s" cannot be evaluated:\n%s'%(v, e)
                        #raise an exception if the data is invalid
                        if t == 'raw': return e
                        elif t == 'complex':