[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/forms/src/uidrivers _base/UIdriver.py wx/U...
From: |
James Thompson |
Subject: |
gnue/forms/src/uidrivers _base/UIdriver.py wx/U... |
Date: |
Sun, 17 Feb 2002 17:25:31 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: James Thompson <address@hidden> 02/02/17 17:25:31
Modified files:
forms/src/uidrivers/_base: UIdriver.py
forms/src/uidrivers/wx: UIdriver.py
Log message:
More ui driver cleanup (syncing machines)
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/_base/UIdriver.py.diff?tr1=1.58&tr2=1.59&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/wx/UIdriver.py.diff?tr1=1.144&tr2=1.145&r1=text&r2=text
Patches:
Index: gnue/forms/src/uidrivers/_base/UIdriver.py
diff -c gnue/forms/src/uidrivers/_base/UIdriver.py:1.58
gnue/forms/src/uidrivers/_base/UIdriver.py:1.59
*** gnue/forms/src/uidrivers/_base/UIdriver.py:1.58 Sun Feb 17 14:54:06 2002
--- gnue/forms/src/uidrivers/_base/UIdriver.py Sun Feb 17 17:25:31 2002
***************
*** 74,89 ****
# Our local "clipboard"
self.__clipboard = None
!
! #
! # UGLY, UGLY, NASTY, NASY
! #
! # Someone tell me theres a better way to get to the classes in a specific
UI driver
! #
!
self.widgets = self._WIDGETS
- self._loginHandler = None # A handle to the login dialog box
- # implemented by the UIdriver
self._formToUI = {} # the GFObj to UI widget cross ref
self._formToUIWidget = {} # dictionary of driver specific
UIfoo
--- 74,81 ----
# Our local "clipboard"
self.__clipboard = None
!
self.widgets = self._WIDGETS
self._formToUI = {} # the GFObj to UI widget cross ref
self._formToUIWidget = {} # dictionary of driver specific
UIfoo
***************
*** 141,149 ****
GDebug.printMesg(2, "Widget is %s" % widget)
self._formToUIWidget[self._currentObject[0]]=uiWidget
- #for id in widget:
- # self._screenWidgetToGFObject[id] = self._currentObject[0]
-
# If the widget list is not empty then do the following
if not widget == []:
# Create a cross reference to the GFObject that created
--- 133,138 ----
***************
*** 254,261 ****
author = event.data[3]
description = event.data[4]
! about = self._aboutDialog(self.mainWindow, programVersion, formName,
formVersion, author, description)
!
about.showModal()
about.destroy()
--- 243,249 ----
author = event.data[3]
description = event.data[4]
! about = self._DIALOGS['about'](self.mainWindow, programVersion, formName,
formVersion, author, description)
about.showModal()
about.destroy()
***************
*** 265,273 ****
def msgBox(self,event):
message = event.data.message
caption = event.data.caption
! dialog = self._messageDialog(self.mainWindow, message, caption)
! dialog.ShowModal()
! dialog.Destroy()
#
# updateEntryEditor
--- 253,262 ----
def msgBox(self,event):
message = event.data.message
caption = event.data.caption
!
! dialog = self._DIALOGS['messageBox'](self.mainWindow, message, caption)
! dialog.showModal()
! dialog.destroy()
#
# updateEntryEditor
***************
*** 385,425 ****
# Called whenever forms leaves a "wait" state
def endWait (self, event):
pass
-
-
- #############################################################################
- #
- # UIWidget class
- #
- # A generic class that handles most the internals of widget management in
- # gnue forms
- #
-
- class UIWidget:
- def __init__(self, object, container, textWidth, textHeight, widgetWidth,
widgetHeight, interface, initialize=1):
- self.widgets = []
- if not hasattr(object,'_rows'):
- object._rows = 1
-
- if not hasattr(object,'_gap'):
- object._gap = 0
-
- if hasattr(object,'width'):
- self.itemWidth = object.width*int(textWidth)
- self.itemHeight = object.height*int(textHeight)
- else:
- self.itemWidth = -1
- self.itemHeight = -1
-
- if not object.hidden:
- for spacer in range(int(object._rows)):
- newWidget = self.createWidget(object, container, textWidth,
textHeight,
- widgetWidth, widgetHeight, interface,
spacer, initialize)
- self.widgets.append(newWidget)
-
- def createWidget(self, object, container, textWidth, textHeight,
- widgetWidth, widgetHeight, interface, spacer,initialize=1):
- GDebug.printMesg(1,"UI doesn't support %s" % self.__class__)
-
-
-
--- 374,376 ----
Index: gnue/forms/src/uidrivers/wx/UIdriver.py
diff -c gnue/forms/src/uidrivers/wx/UIdriver.py:1.144
gnue/forms/src/uidrivers/wx/UIdriver.py:1.145
*** gnue/forms/src/uidrivers/wx/UIdriver.py:1.144 Sun Feb 17 14:54:06 2002
--- gnue/forms/src/uidrivers/wx/UIdriver.py Sun Feb 17 17:25:31 2002
***************
*** 34,39 ****
--- 34,40 ----
from GFForm import *
from GFEvent import *
from gnue.forms.uidrivers._base.UIdriver import *
+ from gnue.forms.uidrivers._base.UIWidget import *
import GFKeyMapper
***************
*** 53,71 ****
_IdToGFObj = {}
_IdToUIObj = {}
##
## Only create one instance of wxApp
## Use getWxApp() to get or create the
## single instance
##
!
__wxApp = None
! # hack for wxPython 2.2 (2.3+ doesn't need this)
! def _eventObjTowxWindow(event):
! eo = event.GetEventObject()
! return wxPyTypeCast(eo, 'wxWindow')
!
class GFwxApp(wxApp):
def OnInit(self):
--- 54,83 ----
_IdToGFObj = {}
_IdToUIObj = {}
+ # hack for wxPython 2.2 (2.3+ doesn't need this)
+ def _eventObjTowxWindow(event):
+ eo = event.GetEventObject()
+ return wxPyTypeCast(eo, 'wxWindow')
+
+
##
## Only create one instance of wxApp
## Use getWxApp() to get or create the
## single instance
##
! ## TODO: It seems this could all be folded
! ## TODO: into an __init__ inside GFwxApp
! ##
__wxApp = None
! def getWxApp():
! global __wxApp
!
! if not __wxApp:
! GDebug.printMesg(7,"WxApp initializing3")
! __wxApp = GFwxApp(0)
! return __wxApp
!
class GFwxApp(wxApp):
def OnInit(self):
***************
*** 73,89 ****
wxInitAllImageHandlers()
return true
- def getWxApp():
- global __wxApp
-
- if __wxApp == None:
- __wxApp = GFwxApp(0)
- GDebug.printMesg(7,"WxApp initializing3")
- return __wxApp
#
# Little global helper routine to set font according to options
#
def initFont(widget, affectsLayout=1):
if int(GConfig.get('fixedWidthFont')):
widget.SetFont(wxFont(int(GConfig.get('pointSize')),wxMODERN,wxNORMAL,wxNORMAL))
--- 85,96 ----
wxInitAllImageHandlers()
return true
#
# Little global helper routine to set font according to options
#
+ # TODO: Not completed
+ #
def initFont(widget, affectsLayout=1):
if int(GConfig.get('fixedWidthFont')):
widget.SetFont(wxFont(int(GConfig.get('pointSize')),wxMODERN,wxNORMAL,wxNORMAL))
***************
*** 96,129 ****
#
class GFUserInterface(GFUserInterfaceBase):
def __init__(self, eventController, disableSplash = None):
self._aboutDialog = UIAbout
self._messageDialog = UIMessageBox
- self._WIDGETS = {'GFLabel' : UILabel,
- 'GFBox' : UIBox,
- 'GFPage' : UIPage,
- 'GFForm' : UIForm,
- 'GFEntry' : UIEntry,
- 'GFButton' : UIButton,
- 'GFScrollBar' : UIScrollBar}
- global _EVENTPROCESSOR
self._wxapp = getWxApp()
self._disableSplash = disableSplash
GFUserInterfaceBase.__init__(self,eventController)
_EVENTPROCESSOR = self.dispatchEvent
self.forms = {}
self.init()
#
- # mainLoop
- #
- # The primary loop of the user interface. Called once the UI is
- # fully activated
- #
- def mainLoop(self):
- self._wxapp.MainLoop() # simply call the wxApp's MainLoop method
-
- #
# init
#
# Routine called by wxWindows when wxApp instance is created
--- 103,135 ----
#
class GFUserInterface(GFUserInterfaceBase):
def __init__(self, eventController, disableSplash = None):
+ self._WIDGETS = {'GFLabel' : UILabel,
+ 'GFBox' : UIBox,
+ 'GFPage' : UIPage,
+ 'GFForm' : UIForm,
+ 'GFEntry' : UIEntry,
+ 'GFButton' : UIButton,
+ 'GFScrollBar' : UIScrollBar,
+ }
+
+ self._DIALOGS = {'about' :UIAbout,
+ 'messageBox' :UIMessageBox,
+ }
+
self._aboutDialog = UIAbout
self._messageDialog = UIMessageBox
self._wxapp = getWxApp()
self._disableSplash = disableSplash
GFUserInterfaceBase.__init__(self,eventController)
+
+ global _EVENTPROCESSOR
_EVENTPROCESSOR = self.dispatchEvent
+
self.forms = {}
self.init()
#
# init
#
# Routine called by wxWindows when wxApp instance is created
***************
*** 171,177 ****
# Create the main window
#
self.mainWindow = wxFrame(NULL, -1, "", wxDefaultPosition)
-
initFont(self.mainWindow,1)
#
--- 177,182 ----
***************
*** 293,306 ****
self.mainWindow.Show(true)
return true
- # Called by SplashScreen when timer expires
- def onCloseSplash(self):
- # For some reason, a simple Close() doesn't cooperate with
- # the modal login box and all hell breaks loose
- self.splash.Show(0)
- self.splash.Destroy()
-
-
def activateForm(self, form):
width = int(self._form.width)
height = int(self._form.height)
--- 298,303 ----
***************
*** 389,394 ****
--- 386,400 ----
#
#
+ # mainLoop
+ #
+ # The primary loop of the user interface. Called once the UI is
+ # fully activated
+ #
+ def mainLoop(self):
+ self._wxapp.MainLoop() # simply call the wxApp's MainLoop method
+
+ #
# gotoPage
#
# makes the requested page visible on the screen
***************
*** 418,423 ****
--- 424,438 ----
wxBell()
self.statusBar.SetStatusText(event.data,0)
+ # Called whenever forms goes into a "wait" state in which user cannot
+ # interact with interface (e.g., while waiting for a query or a commit)
+ def beginWait (self, event):
+ wxBeginBusyCursor()
+
+ # Called whenever forms leaves a "wait" state
+ def endWait (self, event):
+ wxEndBusyCursor()
+
#############################################################################
#
# Internal Event Processors
***************
*** 460,482 ****
else:
object.Destroy()
! # Called whenever forms goes into a "wait" state in which user cannot
! # interact with interface (e.g., while waiting for a query or a commit)
! def beginWait (self, event):
! wxBeginBusyCursor()
- # Called whenever forms leaves a "wait" state
- def endWait (self, event):
- wxEndBusyCursor()
#############################################################################
#
# UI Objects
#
# A set of standard UI objects that allow us to move more code into UIbase
# These map generic functionality to the specific UI widget set in use by
! # this driver
#
#
# UIHelper
--- 475,499 ----
else:
object.Destroy()
! # Called by SplashScreen when timer expires
! def onCloseSplash(self):
! # For some reason, a simple Close() doesn't cooperate with
! # the modal login box and all hell breaks loose
! self.splash.Show(0)
! self.splash.Destroy()
#############################################################################
+ #############################################################################
#
# UI Objects
#
# A set of standard UI objects that allow us to move more code into UIbase
# These map generic functionality to the specific UI widget set in use by
! # this driver.
#
+ #############################################################################
+ #############################################################################
#
# UIHelper
***************
*** 487,500 ****
def showModal(self):
self.ShowModal()
! def show(self, flag=TRUE, index=None):
! if index:
! # TODO: I don't thing this is ever called
! # TODO: with an index
! print "UIwxpython show using an index"
! self.widgets[index].Show(flag)
! else:
! self.Show(flag)
def destroy(self):
self.Destroy()
--- 504,511 ----
def showModal(self):
self.ShowModal()
! def show(self, flag=TRUE):
! self.Show(flag)
def destroy(self):
self.Destroy()
***************
*** 771,777 ****
if action:
_EVENTPROCESSOR(action)
!
#
# UIAbout
#
--- 782,793 ----
if action:
_EVENTPROCESSOR(action)
! #####################################################################
! ##
! ## Required Dialog box support
! ##
! #####################################################################
!
#
# UIAbout
#
***************
*** 800,811 ****
message = lineWrap(message,60)
wxMessageDialog.__init__(self, interface, message, caption,
style=wxOK|wxICON_EXCLAMATION)
! #
! # Translate from wx keystrokes
! # to our virtual keystrokes
! #
from GFKeyMapper import vk
wxKeyTranslations = {
vk.F1 : WXK_F1, vk.F2 : WXK_F2,
vk.F3 : WXK_F3, vk.F4 : WXK_F4,
--- 816,829 ----
message = lineWrap(message,60)
wxMessageDialog.__init__(self, interface, message, caption,
style=wxOK|wxICON_EXCLAMATION)
! #####################################################################
! ##
! ## Keymapper Support
! ##
! #####################################################################
from GFKeyMapper import vk
+ # Translate from wx keystrokes to our virtual keystrokes
wxKeyTranslations = {
vk.F1 : WXK_F1, vk.F2 : WXK_F2,
vk.F3 : WXK_F3, vk.F4 : WXK_F4,
***************
*** 823,842 ****
GFKeyMapper.KeyMapper.setUIKeyMap(wxKeyTranslations)
- #
- # Create a mapping for use by UIBase
- #
- WIDGETS = {'GFLabel' : UILabel,
- 'GFBox' : UIBox,
- 'GFPage' : UIPage,
- 'GFForm' : UIForm,
- 'GFEntry' : UIEntry,
- 'GFButton' : UIButton,
- 'GFScrollBar' : UIScrollBar}
-
#####################################################################
##
! ## Event Processing
##
#####################################################################
--- 841,849 ----
GFKeyMapper.KeyMapper.setUIKeyMap(wxKeyTranslations)
#####################################################################
##
! ## Basic Event Processing
##
#####################################################################
***************
*** 924,929 ****
--- 931,937 ----
#
# UILoginHandler
+ #
class UILoginHandler(GLoginHandler.LoginHandler):
def __init__(self):
self._wxapp = getWxApp()
***************
*** 986,999 ****
dlgWidth = max(dlgWidth, loginButton.GetSize().GetWidth() +
cancelButton.GetSize().GetWidth() + 6) + 20
! dlgHeight = dlgHeight + \
! max(loginButton.GetSize().GetHeight(),
! cancelButton.GetSize().GetHeight()) - 6
firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
lastY = firstY
! xSpacing = xSpacing + 10 # Add whitespace between widgets
! ySpacing = ySpacing + 6 # Add whitespace between widgets
xPos = dlgWidth/2 - fieldLabelWidth/2
--- 994,1006 ----
dlgWidth = max(dlgWidth, loginButton.GetSize().GetWidth() +
cancelButton.GetSize().GetWidth() + 6) + 20
! dlgHeight += max(loginButton.GetSize().GetHeight(),
! cancelButton.GetSize().GetHeight()) - 6
firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
lastY = firstY
! xSpacing += 10 # Add whitespace between widgets
! ySpacing += 6 # Add whitespace between widgets
xPos = dlgWidth/2 - fieldLabelWidth/2
***************
*** 1041,1052 ****
# If user cancels, this will be set to 0
self._completed = 0
self.dlg.ShowModal()
-
- #if sys.platform == 'win32':
- # import time
- # time.sleep(3)
- #self.dlg.Destroy()
- #self.dlg = None
if not self._completed:
raise GLoginHandler.UserCanceledLogin
--- 1048,1053 ----
***************
*** 1083,1090 ****
--- 1084,1095 ----
def destroyLoginDialog(self):
self.dlg.Destroy()
+ #
+ # LoginFieldHandler
+ #
# Used by the login handler
# enables the user to press return and have it jump to the next box
+ #
class LoginFieldHandler:
def __init__(self, app, seq):
self.app = app
***************
*** 1104,1108 ****
--- 1109,1119 ----
self.app.loginCompleted(1)
else:
event.Skip()
+
+
+
+
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/forms/src/uidrivers _base/UIdriver.py wx/U...,
James Thompson <=