dabo Commit Revision 2073 Date: 2006-03-31 15:28:34 -0800 (Fri, 31 Mar 2006) Author: paul
Changed: U trunk/dabo/ui/uitk/__init__.py U trunk/dabo/ui/uitk/dPemMixin.py U trunk/dabo/ui/uitk/uiApp.py U trunk/dabo/ui/uiwx/__init__.py U trunk/dabo/ui/uiwx/uiApp.py
Log: Updated the Tkinter code enough so that the dCheckbox demo instantiates, very very minimally.
Diff: Modified: trunk/dabo/ui/uitk/__init__.py =================================================================== --- trunk/dabo/ui/uitk/__init__.py 2006-03-31 22:15:52 UTC (rev 2072) +++ trunk/dabo/ui/uitk/__init__.py 2006-03-31 23:28:34 UTC (rev 2073) @@ -5,6 +5,7 @@ dabo.infoLog.write("The Tkinter module is experimental only, and doesn't work. You've been warned.") uiType = {'shortName': 'tk', 'moduleName': 'uitk', 'longName': 'Tkinter'} +_uiApp = None # Import dPemMixin first, and then manually put into dabo.ui module. This is # because dControlMixin, which is in dabo.ui, descends from dPemMixin, which @@ -103,3 +104,19 @@ #ed["unicodeKey"] = wxEvt.GetUnicodeKey() #ed["hasModifiers"] = wxEvt.HasModifiers() return ed + + +def getUiApp(app, callback=None): + """This returns an instance of uiApp. If one is already running, that + instance is returned. Otherwise, a new instance is created. + """ + ret = _uiApp + if ret is None: + ret = uiApp(app, callback) + else: + # existing app; fire the callback, if any + if callback is not None: + callback() + return ret + +
Modified: trunk/dabo/ui/uitk/dPemMixin.py =================================================================== --- trunk/dabo/ui/uitk/dPemMixin.py 2006-03-31 22:15:52 UTC (rev 2072) +++ trunk/dabo/ui/uitk/dPemMixin.py 2006-03-31 23:28:34 UTC (rev 2073) @@ -17,11 +17,10 @@ # code. # self.properties can be set in the userland beforeInit() hook. - self.properties = {} + self._properties = {} # This will implicitly call the following user hooks: # beforeInit() - # initStyleProperties() self._beforeInit() # The keyword properties can come from either, both, or none of: @@ -32,8 +31,8 @@ if properties is not None: # Override the class values for k,v in properties.items(): - self.properties[k] = v - properties = self._extractKeywordProperties(kwargs, self.properties) + self._properties[k] = v + properties = self._extractKeywordProperties(kwargs, self._properties) # If a Name isn't given, a default name will be used, and it'll # autonegotiate by adding an integer until it is a unique name. @@ -47,7 +46,11 @@ self._initName(name, _explicitName=_explicitName) self._afterInit() - self.setProperties(properties) + print properties + try: + self.setProperties(properties) + except: + pass def __getattr__(self, att): @@ -74,7 +77,6 @@ def _beforeInit(self): self._name = '?' - self.initStyleProperties() # Call the subclass hook: self.beforeInit() @@ -84,7 +86,6 @@ self.debug = False self.initProperties() - self.initChildObjects() self.afterInit() self._mouseLeftDown, self._mouseRightDown = False, False @@ -177,8 +178,10 @@ def raiseEvent(self, eventClass, nativeEvent=None, *args, **kwargs): # Call the Dabo-native raiseEvent(), passing along the Tkinter after_idle # function, so that the Dabo events can be processed at next idle. - return self.super(eventClass, nativeEvent, callAfterFunc=self.after_idle, - *args, **kwargs) +# return self.super(eventClass, nativeEvent, callAfterFunc=self.after_idle, +# *args, **kwargs) + super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, callAfterFunc=self.after_idle, + *args, **kwargs) def getPropertyInfo(self, name): @@ -375,7 +378,7 @@ def _setName(self, val, _userExplicit=False): # Can't set tk name after initialized. However, we should try to implement # our own Dabo name which we can refer to and set/reset as we please. - self._initProperties["name"] = val + self._properties["name"] = val # Also, see ui/uiwx/dPemMixin._setName(), where we enforce a unique name # among siblings. That code should be refactored into dPemMixinBase...
Modified: trunk/dabo/ui/uitk/uiApp.py =================================================================== --- trunk/dabo/ui/uitk/uiApp.py 2006-03-31 22:15:52 UTC (rev 2072) +++ trunk/dabo/ui/uitk/uiApp.py 2006-03-31 23:28:34 UTC (rev 2073) @@ -12,16 +12,17 @@ # It doesn't look like Tkinter has an application object, just a mainloop() method. class uiApp(dObject): - def __init__(self): + def __init__(self, app, callback=None, *args): + self.Name = "uiApp" + self.dApp = app + self.callback = callback self.super() - self.Name = "uiApp" - - def setup(self, dApp): - self.dApp = dApp - if dApp.MainFormClass is not None: - dApp.MainForm = dApp.MainFormClass() + def setup(self): + if self.dApp.MainFormClass is not None: + self.dApp.MainForm = self.dApp.MainFormClass() + def start(self, dApp): self.raiseEvent(dEvents.Activate) Tkinter.mainloop() @@ -184,3 +185,13 @@ user, password = dlg.user, dlg.password dlg.Destroy() return user, password + + def setMainForm(self, val): + pass +# try: +# self.dApp.MainForm.Destroy() +## except: +# pass +# self.SetTopWindow(val) +# val.Show(self.dApp.showMainFormOnStart) +
Modified: trunk/dabo/ui/uiwx/__init__.py =================================================================== --- trunk/dabo/ui/uiwx/__init__.py 2006-03-31 22:15:52 UTC (rev 2072) +++ trunk/dabo/ui/uiwx/__init__.py 2006-03-31 23:28:34 UTC (rev 2073) @@ -163,7 +163,7 @@ artConstants["file"] = artConstants.get("normalfile") -def getUiApp(app, callback): +def getUiApp(app, callback=None): """This returns an instance of uiApp. If one is already running, that instance is returned. Otherwise, a new instance is created. """
Modified: trunk/dabo/ui/uiwx/uiApp.py =================================================================== --- trunk/dabo/ui/uiwx/uiApp.py 2006-03-31 22:15:52 UTC (rev 2072) +++ trunk/dabo/ui/uiwx/uiApp.py 2006-03-31 23:28:34 UTC (rev 2073) @@ -98,7 +98,7 @@ class uiApp(wx.App, dObject): - def __init__(self, app, callback, *args): + def __init__(self, app, callback=None, *args): self.dApp = app self.callback = callback wx.App.__init__(self, 0, *args)
©2006 Paul McNett |
|