[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7064 - in trunk: gnue-designer/src/forms gnue-forms/src gnue-for
From: |
kilo |
Subject: |
[gnue] r7064 - in trunk: gnue-designer/src/forms gnue-forms/src gnue-forms/src/uidrivers/_base gnue-forms/src/uidrivers/wx |
Date: |
Fri, 25 Feb 2005 07:56:00 -0600 (CST) |
Author: kilo
Date: 2005-02-25 07:55:58 -0600 (Fri, 25 Feb 2005)
New Revision: 7064
Modified:
trunk/gnue-designer/src/forms/Debugger.py
trunk/gnue-designer/src/forms/Instance.py
trunk/gnue-forms/src/GFInstance.py
trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
Log:
Enable Run form function in Designer.
Still buggy, if you debug a form, then Designer needs a Ctrl+C on exit.
Modified: trunk/gnue-designer/src/forms/Debugger.py
===================================================================
--- trunk/gnue-designer/src/forms/Debugger.py 2005-02-25 12:46:43 UTC (rev
7063)
+++ trunk/gnue-designer/src/forms/Debugger.py 2005-02-25 13:55:58 UTC (rev
7064)
@@ -1,7 +1,7 @@
#
# Copyright 2001-2005 Free Software Foundation
#
-# This file is part of GNU Enterprise.
+# This file is part of GNU Enterprise
#
# GNU Enterprise is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
@@ -18,13 +18,12 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# FILE:
-# Debugger.py
-#
-# DESCRIPTION:
-#
-# NOTES:
+# $Id$
+"""
+Support class to run/debug a form from within Designer.
+"""
+
import sys, os
from wxPython.wx import *
from gnue.common.apps import GDebug
@@ -32,58 +31,69 @@
from gnue.forms import GFForm, GFInstance, GFParser
from StringIO import StringIO
from gnue.forms.uidrivers.wx import UIdriver as UIwxpython
-
-
+
class DebugSession:
def __init__(self, caller):
self.caller = caller
+
+ #Open output window to show debug messages there
+ #instead of the console
outputWindow = wxFrame(caller, -1, _("Console Output"),
size=wxSize(300,50))
outputWindow.text = wxTextCtrl(outputWindow, -1, style=wxTE_MULTILINE)
outputWindow.Show(true)
caller.outputWindow = outputWindow
-
+ self.outputWindow = outputWindow
+
+ #Redirect stdout and stderr to output window
self.stdoutcatcher = _stdoutcatcher(outputWindow.text)
self.stderrcatcher = _stderrcatcher(outputWindow.text)
try:
self._saveexit = sys.exit
sys.exit = self.debugClosing
-
-# debugInstance = DebugInstance(caller._app)
- debugInstance =
GFInstance.GFInstance(caller._app,connections=caller._app.connections,
- ui=DummyInterfaceModule,disableSplash=1)
+ debugInstance = GFInstance.GFInstance(caller._app, \
+ connections=caller._app.connections, \
+ ui=DummyInterfaceModule, disableSplash=True, \
+ moduleName='gnue.forms.uidrivers.wx.UIdriver')
debugInstance.addDialogs()
- debugInstance.addFormFromBuffer(caller.rootObject.dumpXML(treeDump=1))
+ debugInstance.addFormFromBuffer(caller.rootObject.dumpXML(treeDump=True))
#debugInstance.setForm(GFParser.loadFile(StringIO(caller.rootObject.dumpXML(treeDump=1)),
debugInstance))
+
+ #strictly in this order,
+ #or DebugUserInterfase.exitApplication won't be called
+ debugInstance._uimodule._debuginstance = self
debugInstance.activate()
- debugInstance._ui._debuginstance = self
except:
self.sanityCheck()
raise
self.outputWindow.text.AppendText(_('\n---- Form Closed Abruptly ----'))
+
def debugClosing(self):
self.sanityCheck()
self.outputWindow.text.AppendText(_('\n---- Form Closed ----'))
+ #self.outputWindow.Close()
+
def sanityCheck(self):
self.stdoutcatcher.restore()
self.stderrcatcher.restore()
sys.exit = self._saveexit
+
class DebugUserInterface(UIwxpython.GFUserInterface):
- def closeTrap (self, event):
- UIwxpython.GFUserInterface.closeTrap(self, event)
- eo = event.GetEventObject()
- object = wxPyTypeCast(eo, 'GFDInstance')
- object._debuginstance.debugClosing()
+ def exitApplication(self, event):
+ eo = event._form._instance
+ eo._uimodule._debuginstance.debugClosing()
+ UIwxpython.GFUserInterface.exitApplication(self, event)
# Ack!!!
class DummyInterfaceModule:
GFUserInterface = DebugUserInterface
+
#class DebugInstance(GFInstance.GFInstance):
# def __init__(self, manager, connections=None, ui=DummyInterfaceModule,
disableSplash=1,
# parameters={}):
@@ -133,4 +143,3 @@
self.__stderr__ = self.orig
GDebug._fh = self.origfh
-
Modified: trunk/gnue-designer/src/forms/Instance.py
===================================================================
--- trunk/gnue-designer/src/forms/Instance.py 2005-02-25 12:46:43 UTC (rev
7063)
+++ trunk/gnue-designer/src/forms/Instance.py 2005-02-25 13:55:58 UTC (rev
7064)
@@ -1,6 +1,8 @@
#
-# This file is part of GNU Enterprise.
+# Copyright 2001-2005 Free Software Foundation
#
+# This file is part of GNU Enterprise
+#
# GNU Enterprise is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
@@ -16,17 +18,13 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2001-2005 Free Software Foundation
-#
-# FILE:
-# form/Instance.py
-#
-# DESCRIPTION:
-# Creates a "Form" instance
-#
-# NOTES:
-#
+# $Id$
+"""
+Creates a "Form" instance.
+"""
+
+
__all__ = ['Instance']
from wxPython.wx import *
@@ -70,7 +68,7 @@
self.incubator = Incubator(self)
self.properties = formProperties
self.wizardRunner = WizardRunner
- self.debugLevel = 1
+ self.debugLevel = '1'
# TODO: Can we make it so the GFInstance is not
# TODO: part of the main Instance class, but an
@@ -354,26 +352,29 @@
'block': self.visualEditor.block,
'object': self._currentObject}
+
def __onSetDebugLevel(self, event):
+ """Opens a dialog to let the user set the debug level
+ before running a form inside Designer."""
tmpLevel = self.debugLevel
- tmpRez = 0
- tmpMessage = _("Please enter debugging level - integer [0..n]")
- tmpPrompt = _("Level:")
+ tmpRez = ''
+ tmpMessage = _("Please enter debugging level - integer numbers [0..n]")
tmpCaption = _("Choose debug level")
- tmpRez =
wxGetNumberFromUser(tmpMessage,tmpPrompt,tmpCaption,tmpLevel,0,10,NULL)
- if (tmpRez != -1):
+ tmpRez = wxGetTextFromUser(tmpMessage, tmpCaption, tmpLevel, NULL)
+ if (tmpRez != ''):
self.debugLevel = tmpRez
+
def __onRunForm (self, event):
- #TODO: This does not work... But everyone tried this first...
- #TODO: No, not just you. I mean EVERYONE!!!
- #GDebug.setDebug(self.debugLevel,"");
- #DebugSession(self)
- wxMessageDialog(self,
- _('Running a form within GNUe Designer is\n' + \
- 'not implemented yet.' + \
- '\n\nPlease save the form and run it using\n' + \
- 'the GNUe Forms tool (gnue-forms).'),
- _("NOT IMPLEMENTED"), wxOK|wxICON_EXCLAMATION ).ShowModal()
+ #TODO: This does not work... But everyone tried this first...
+ #TODO: No, not just you. I mean EVERYONE!!!
+ GDebug.setDebug(str(self.debugLevel), "")
+ DebugSession(self)
+ #~ wxMessageDialog(self,
+ #~ _('Running a form within GNUe Designer is\n' + \
+ #~ 'not implemented yet.' + \
+ #~ '\n\nPlease save the form and run it using\n' + \
+ #~ 'the GNUe Forms tool (gnue-forms).'),
+ #~ _("NOT IMPLEMENTED"), wxOK|wxICON_EXCLAMATION ).ShowModal()
Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py 2005-02-25 12:46:43 UTC (rev 7063)
+++ trunk/gnue-forms/src/GFInstance.py 2005-02-25 13:55:58 UTC (rev 7064)
@@ -72,8 +72,10 @@
# ---------------------------------------------------------------------------
def __init__ (self, manager, connections, ui, disableSplash = False,
- parameters = {}, parentContainer = None):
-
+ parameters = {}, parentContainer = None, moduleName = None):
+ # moduleName is here only for Designer to be able to pass it in
+ #when debugging a form.
+
gBeginFunc (4)
# Configure event handling
@@ -163,7 +165,8 @@
gDebug (4, "Initializing user interface driver")
self._uiinstance = self._uimodule.GFUserInterface (self.eventController,
disableSplash = self._disableSplash,
- parentContainer = self._parentContainer)
+ parentContainer = self._parentContainer,
+ moduleName = moduleName)
gEndFunc (4, hasResult = False)
@@ -924,7 +927,7 @@
else:
event._form.processTrigger ('On-Exit')
self.dispatchEvent ('exitApplication', _('Current data is saved'),
- _formName = event._form.name)
+ _formName = event._form.name, _form = event._form)
except AbortRequest, t:
self.displayMessageBox (t, 'Warning')
Modified: trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/UIdriver.py 2005-02-25 12:46:43 UTC
(rev 7063)
+++ trunk/gnue-forms/src/uidrivers/_base/UIdriver.py 2005-02-25 13:55:58 UTC
(rev 7064)
@@ -90,11 +90,13 @@
# ---------------------------------------------------------------------------
def __init__(self, eventHandler, name = "Undefined", disableSplash = None,
- parentContainer = None):
+ parentContainer = None, moduleName = None):
"""
Constructors of descendants must bring their UI into a state where it can
perform simple tasks like showMessage () or showException ().
"""
+ # moduleName is here only for Designer to be able to pass it in
+ #when debugging a form.
GRootObj.__init__(self, 'uiDriver', None, None)
@@ -136,7 +138,11 @@
# Import and register supported widgets in UI driver
self._supportedWidgets = {}
- basedir = os.path.dirname (sys.modules [self.__module__].__file__)
+ if moduleName: #We are within Designer, running a form
+ basedir = os.path.dirname(sys.modules[moduleName].__file__)
+ else: #Normal case
+ basedir = os.path.dirname (sys.modules [self.__module__].__file__)
+
uiDriver = os.path.basename (basedir)
basedir +='/widgets/'
for widgetName in dircache.listdir (basedir):
@@ -156,7 +162,6 @@
try:
self._supportedWidgets [widget.configuration ['provides']] = widget
-
except Exception, mesg:
raise ImportError, mesg
@@ -230,7 +235,6 @@
# ---------------------------------------------------------------------------
def _buildUI (self, object, formName):
-
try:
#
# Look up the parent GObj of the current obj
@@ -285,7 +289,7 @@
gDebug (5, "Widget is %s" % uiWidget.widgets)
except KeyError:
- pass
+ gDebug(4, "KeyError in _buildUI")
#############################################################################
@@ -307,7 +311,6 @@
# Create the UI from the GFForm passed in
form.walk (self._buildUI, formName = formName)
-
self._gfObjToUIWidget [form].phaseInit ()
self._formNameToUIForm [formName]._gfObjToToolkitWidgets = \
Modified: trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/UIdriver.py 2005-02-25 12:46:43 UTC
(rev 7063)
+++ trunk/gnue-forms/src/uidrivers/wx/UIdriver.py 2005-02-25 13:55:58 UTC
(rev 7064)
@@ -262,24 +262,6 @@
# Processes the events from the widget set
#
-
-
- #
- # closeTrap
- #
- # intercepts the applications closure and generates an event to the form
requesting
- # closure. Allows the form to control closure. If the form approves it'll
send
- # back an event closing the application
- #
- def closeTrap(self,event):
- if event.CanVeto():
- self.dispatchEvent('requestEXIT',_form=self._form)
- else:
- object = _eventObjTowxWindow(event)
- object.Destroy()
- # wxExit() TODO: Try and work this into navigator or here if it still
hangs
-
-
# ---------------------------------------------------------------------------
# Show a message dialog
# ---------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7064 - in trunk: gnue-designer/src/forms gnue-forms/src gnue-forms/src/uidrivers/_base gnue-forms/src/uidrivers/wx,
kilo <=