16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2000-2002 Free Software Foundation |
# Copyright 2000-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# UIbase.py |
# UIbase.py |
23 |
# |
# |
24 |
# DESCRIPTION: |
# DESCRIPTION: |
25 |
# A base class for UI modules. Everything in here better |
# A base class for UI modules. This class is to be inherited by |
26 |
# not contain any specific UI widgetisms |
# specific UI drivers. |
27 |
# |
# |
28 |
# NOTES: |
# NOTES: |
29 |
# |
# |
30 |
|
import sys |
31 |
|
|
|
from gnue.forms.GFForm import * |
|
32 |
from gnue.common import events |
from gnue.common import events |
33 |
from gnue.common.GObjects import * |
from gnue.common.GObjects import * |
34 |
|
|
35 |
# Used in updating the status bar |
from gnue.forms.GFForm import * |
|
|
|
|
statusValues = {'saved':'OK', |
|
|
'modified':'MOD', |
|
|
'deleted':'DEL', |
|
|
'query':'QRY'} |
|
|
|
|
|
|
|
|
# Creating base dictionary for language font encodings |
|
36 |
|
|
37 |
encodings = { |
class UIForm: |
38 |
'iso8859-1':None, |
def __init__(self): |
39 |
'iso8859-2':None, |
self._form = None # The GObj based form tree |
40 |
'iso8859-3':None, |
self._interface = None # The widget tree constructed by buildUI |
41 |
'iso8859-4':None, |
self._formToUI = {} # the GFObj to UI widget cross ref |
42 |
'iso8859-5':None, |
self._formToUIWidget = {} # dictionary of driver specific UIfoo |
43 |
'iso8859-6':None, |
# widgets with the GFObj used as the key |
44 |
'iso8859-7':None, |
self._pageList = [] # A list of page widgets created by the form |
|
'iso8859-8':None, |
|
|
'iso8859-9':None, |
|
|
'iso8859-10':None, |
|
|
'iso8859-11':None, |
|
|
'iso8859-12':None, |
|
|
'iso8859-13':None, |
|
|
'iso8859-14':None, |
|
|
'iso8859-15':None, |
|
|
'koi8':None, # TODO: not sure about these |
|
|
'koi8-r':None, |
|
|
'cp1250':None, |
|
|
'cp1251':None, |
|
|
'cp1252':None |
|
|
} |
|
45 |
|
|
46 |
# |
# |
47 |
# GFUserInterfaceBase |
# GFUserInterfaceBase |
48 |
# |
# |
49 |
# Convience class to be inheritance by other GFUserInterface's |
# Convience class to be inherited by other GFUserInterface's |
50 |
# Provides basic functionality. |
# Provides basic functionality. |
51 |
# |
# |
52 |
class GFUserInterfaceBase(events.EventAware): |
class GFUserInterfaceBase(events.EventAware): |
53 |
def __init__(self, eventHandler): |
def __init__(self, eventHandler): |
54 |
events.EventAware.__init__(self, eventHandler) |
############################################################ |
55 |
# |
# |
56 |
# Events I monitor... |
# Things you do not adjust in the individual UI drivers |
57 |
# |
# |
58 |
|
############################################################ |
59 |
|
events.EventAware.__init__(self, eventHandler) |
60 |
|
|
61 |
|
# Configure event handling |
62 |
self.registerEventListeners( { |
self.registerEventListeners( { |
63 |
'gotoENTRY' : self.switchFocus, |
'gotoENTRY' : self.switchFocus, |
64 |
'updateENTRY' : self.updateEntry, |
'updateENTRY' : self.updateEntry, |
65 |
'updateEntryEditor': self.updateEntryEditor, |
'updateEntryEditor': self.updateEntryEditor, |
66 |
'gotoPAGE' : self.gotoPage, |
'gotoPAGE' : self.gotoPage, |
67 |
'formALERT' : self.formAlert, |
'exitApplication' : self.exitApplication, |
68 |
|
|
69 |
|
# User feedback events from the virtual form to the UI |
70 |
'beginWAIT' : self.beginWait, |
'beginWAIT' : self.beginWait, |
71 |
'endWAIT' : self.endWait, |
'endWAIT' : self.endWait, |
|
'uiUPDATESTATUS' : self.updateStatusBar, |
|
|
'uiABOUT' : self.aboutBox, |
|
|
'exitApplication' : self.exitApplication, |
|
72 |
'msgBoxUI' : self.msgBox, |
'msgBoxUI' : self.msgBox, |
73 |
'genericBox' : self.genericBox, |
'formALERT' : self.formAlert, |
74 |
|
'uiABOUT' : self.aboutBox, |
75 |
|
'uiUPDATESTATUS' : self.updateStatusBar, |
76 |
|
|
77 |
# Clipboard contents |
# Clipboard contents |
78 |
'setCLIPBOARD' : self.setClipboardContents, |
'setCLIPBOARD' : self.setClipboardContents, |
79 |
'getCLIPBOARD' : self.getClipboardContents, |
'getCLIPBOARD' : self.getClipboardContents, |
80 |
}) |
}) |
81 |
|
|
82 |
# Our local "clipboard" |
# GFForm objects that can act as containers for other objects |
83 |
self.__clipboard = None |
self.containerWidgets= ['GFPage'] # , 'GFBox'] |
84 |
|
|
|
self.widgets = self._WIDGETS |
|
85 |
|
|
86 |
self._formToUI = {} # the GFObj to UI widget cross ref |
# Mapping - internal record status : displayed on status bar |
87 |
self._formToUIWidget = {} # dictionary of driver specific UIfoo |
self.statusValues = {'saved' :'OK', |
88 |
# widgets with the GFObj used as the key |
'modified' :'MOD', |
89 |
|
'deleted' :'DEL', |
90 |
self.containerWidgets= ['GFPage', 'GFBox'] # GFForm objects that contain others |
'query' :'QRY', |
91 |
|
} |
92 |
|
|
93 |
|
# Our local "clipboard" |
94 |
|
self.__clipboard = None |
95 |
|
|
96 |
self._pageList = [] # A list of page widgets created by the form |
############################################################ |
97 |
|
# |
98 |
|
# Things you may need to adjust in the individual UI drivers |
99 |
|
# |
100 |
|
############################################################ |
101 |
|
|
102 |
self.keyEvents = {} # Keyboard events from the widget set the |
# |
103 |
# UI is expected to respond to |
# A mapping of GFForm string types to an individual driver's |
104 |
|
# UIWidgets derived classes. This MUST be reset in each |
105 |
|
# driver or hideous, vile things will invade your fridge |
106 |
|
# |
107 |
|
self._WIDGETS = { 'GFLabel' : UIFailure, |
108 |
|
'GFBox' : UIFailure, |
109 |
|
'GFPage' : UIFailure, |
110 |
|
'GFForm' : UIFailure, |
111 |
|
'GFEntry' : UIFailure, |
112 |
|
'GFButton' : UIFailure, |
113 |
|
'GFScrollBar' : UIFailure, |
114 |
|
} |
115 |
|
# |
116 |
|
# Dialogs required by base |
117 |
|
# |
118 |
|
# Same notes apply to this as to _WIDGETS above |
119 |
|
# TODO: Once <dialog> works we may be able to |
120 |
|
# do away with these |
121 |
|
# |
122 |
|
self._DIALOGS = {'about' :UIFailure, |
123 |
|
'messageBox' :UIFailure, |
124 |
|
} |
125 |
|
|
126 |
# A dictionary of functions used by buildUI to build the widgets. Can override in |
# |
127 |
# UI specific module if necessary. |
# Widgets that should be represented in the UI and |
128 |
|
# the constructor needed to build them. The constructor |
129 |
|
# can overriden in UI specific module if necessary. |
130 |
|
# |
131 |
self.widgetConstructorFunction = { |
self.widgetConstructorFunction = { |
132 |
'GFBox' : self._stdHandler, |
'GFBox' : self._stdConstructor, |
133 |
'GFButton' : self._stdHandler, |
'GFButton' : self._stdConstructor, |
134 |
'GFEntry' : self._stdHandler, |
'GFEntry' : self._stdConstructor, |
135 |
'GFForm' : self._stdHandler, |
'GFForm' : self._stdConstructor, |
136 |
'GFLabel' : self._stdHandler, |
'GFLabel' : self._stdConstructor, |
137 |
'GFScrollBar' : self._stdHandler, |
'GFScrollBar' : self._stdConstructor, |
138 |
'GFPage' : self._stdHandler, |
'GFPage' : self._stdConstructor, |
|
'GFMainToolBar' : self._stdHandler, |
|
|
'GFMainMenuBar' : self._stdHandler, |
|
139 |
} |
} |
140 |
|
|
|
def _stdHandler(self): |
|
|
object = self._currentObject[0] |
|
|
event = self._updateCreateEvent(events.Event('CreateUIWidget',None, |
|
|
object=object, |
|
|
container=self.currentWidget[0], |
|
|
textWidth=self.textWidth, |
|
|
textHeight=self.textHeight, |
|
|
widgetWidth=self.widgetWidth, |
|
|
widgetHeight=self.widgetHeight, |
|
|
interface=self, |
|
|
initialize=1)) |
|
|
|
|
|
newWidget = self.widgets[object._type](event) |
|
|
return newWidget |
|
|
|
|
|
# Can be used by UI drivers to add more attributes to the event. |
|
|
def _updateCreateEvent(self, event): |
|
|
return event |
|
141 |
|
|
142 |
|
# |
143 |
|
# Multi-form support |
144 |
|
# |
145 |
|
self._uiDictionary = {} |
146 |
|
|
147 |
|
|
148 |
|
self._formToUI = {} # the GFObj to UI widget cross ref |
149 |
|
self._formToUIWidget = {} # dictionary of driver specific UIfoo |
150 |
|
# widgets with the GFObj used as the key |
151 |
|
self._pageList = [] # A list of page widgets created by the form |
152 |
|
|
153 |
# |
# |
154 |
# buildUI |
# buildUI |
155 |
# |
# |
161 |
def _buildUI(self): |
def _buildUI(self): |
162 |
try: |
try: |
163 |
uiWidget = self.widgetConstructorFunction[self._currentObject[0]._type] () |
uiWidget = self.widgetConstructorFunction[self._currentObject[0]._type] () |
164 |
|
uiWidget._form = self._form |
165 |
widget = uiWidget.widgets |
widget = uiWidget.widgets |
166 |
GDebug.printMesg(2, "Widget is %s" % widget) |
GDebug.printMesg(2, "Widget is %s" % widget) |
167 |
|
|
168 |
self._formToUIWidget[self._currentObject[0]]=uiWidget |
self._formToUIWidget[self._currentObject[0]]=uiWidget |
169 |
|
|
170 |
# If the widget list is not empty then do the following |
# If the widget list is not empty then do the following |
172 |
if not widget == []: |
if not widget == []: |
173 |
# Create a cross reference to the GFObject that created |
# Create a cross reference to the GFObject that created |
174 |
# one or more UI widgets |
# one or more UI widgets |
175 |
|
|
176 |
self._formToUI[self._currentObject[0]] = widget |
self._formToUI[self._currentObject[0]] = widget |
177 |
|
|
178 |
# If the current object is a container then add the |
# If the current object is a container then add the |
179 |
# just created first created widget to it's widget list |
# just created first created widget to it's widget list |
180 |
if self._currentObject[0]._type in self.containerWidgets: |
if self._currentObject[0]._type in self.containerWidgets: |
183 |
except KeyError: |
except KeyError: |
184 |
pass |
pass |
185 |
|
|
|
|
|
186 |
if self._currentObject[0]._children: |
if self._currentObject[0]._children: |
187 |
for child in self._currentObject[0]._children: |
for child in self._currentObject[0]._children: |
188 |
if isinstance(child, GObj): |
if isinstance(child, GObj): |
193 |
if self._currentObject[0]._type in self.containerWidgets: |
if self._currentObject[0]._type in self.containerWidgets: |
194 |
self.currentWidget.pop(0) |
self.currentWidget.pop(0) |
195 |
|
|
196 |
|
# |
197 |
|
# _stdConstructor |
198 |
|
# |
199 |
|
# The default function that builds a specific widget |
200 |
|
# |
201 |
|
def _stdConstructor(self): |
202 |
|
object = self._currentObject[0] |
203 |
|
event = self._updateCreateEvent(events.Event('CreateUIWidget',None, |
204 |
|
object=object, |
205 |
|
container=self.currentWidget[0], |
206 |
|
textWidth=self.textWidth, |
207 |
|
textHeight=self.textHeight, |
208 |
|
widgetWidth=self.widgetWidth, |
209 |
|
widgetHeight=self.widgetHeight, |
210 |
|
interface=self, |
211 |
|
initialize=1)) |
212 |
|
newWidget = self._WIDGETS[object._type](event) |
213 |
|
return newWidget |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
############################################################################# |
############################################################################# |
218 |
# |
# |
219 |
# Public Interface |
# Public Interface |
228 |
# when passed a GObj tree constructed from a .gfd file |
# when passed a GObj tree constructed from a .gfd file |
229 |
# it handles the creatation of the user interface |
# it handles the creatation of the user interface |
230 |
# |
# |
231 |
def buildForm(self, form): |
def buildForm(self, form, formName): |
232 |
self._currentObject = [form] |
currentForm = self._uiDictionary[formName] = UIForm() |
233 |
|
|
234 |
|
# self._formToUI = {} |
235 |
|
# self._formToUIWidget = {} |
236 |
|
self._pageList = [] |
237 |
self._form = form |
self._form = form |
238 |
|
self._currentObject = [form] |
239 |
|
|
240 |
# Create the UI from the GFForm passed in |
# Create the UI from the GFForm passed in |
241 |
self._buildUI() |
self._buildUI() |
242 |
|
|
243 |
|
currentForm._formToUI = self._formToUI |
244 |
|
currentForm._formToUIWidget = self._formToUIWidget |
245 |
|
currentForm._pageList = self._pageList |
246 |
|
currentForm._userInterface = self._pageList[0] |
247 |
|
currentForm._form = form |
248 |
|
currentForm._currentWidget = self.currentWidget |
249 |
|
|
250 |
|
def activateForm(self,formName): |
251 |
|
|
252 |
|
form = self._uiDictionary[formName] |
253 |
|
|
254 |
|
# self._formToUI = form._formToUI |
255 |
|
# self._formToUIWidget = form._formToUIWidget |
256 |
|
self._pageList = form._pageList |
257 |
|
self.currentWidget = form._currentWidget |
258 |
|
self._form = form._form |
259 |
|
|
260 |
|
self._activateForm(form._form) |
261 |
|
|
262 |
|
|
263 |
############################################################################# |
############################################################################# |
264 |
# |
# |
265 |
# Generic Incoming Event Handlers |
# EVENT FUNCTIONS |
266 |
# |
# |
267 |
# Handles incoming events and calls UI instance specific functions to |
# Handles incoming events and calls UI instance specific functions to |
268 |
# execute the actions. These events come from the forms back end. |
# execute the actions. These events come from the forms back end. |
269 |
# |
# |
270 |
|
|
271 |
# |
# |
|
# Clipboard routines |
|
|
# |
|
|
# If a particular UI has a system-wide clipboard, |
|
|
# these methods should be overridden to use that |
|
|
# clipboard. |
|
|
# |
|
|
def getClipboardContents(self, event): |
|
|
GDebug.printMesg(5, "Getting clipboard '%s'" % self.__clipboard) |
|
|
event.__result__ = "%s" % self.__clipboard |
|
|
|
|
|
def setClipboardContents(self, event): |
|
|
GDebug.printMesg(5, "Setting clipboard '%s'" % event.text) |
|
|
self.__clipboard = "%s" % event.text |
|
|
|
|
|
# |
|
|
# exitApplication |
|
|
# |
|
|
# Form has told the application to close so call the UIs private exit routine |
|
|
# |
|
|
def exitApplication(self,event): |
|
|
self._exit() |
|
|
|
|
|
# |
|
|
# updateStatusBar |
|
|
# |
|
|
# Calls the UIs function to update status |
|
|
def updateStatusBar(self,event): |
|
|
|
|
|
tip, recordStatus, insertMode, currentRecord, maxRecord, currentPage, maxPage =event.data |
|
|
|
|
|
status = None |
|
|
if recordStatus != None: |
|
|
status = statusValues[recordStatus] |
|
|
|
|
|
insertValue = None |
|
|
if insertMode != None: |
|
|
insertValue = insertMode and 'INS' or 'OVR' |
|
|
self._setStatusBar(tip, status, insertValue, currentRecord, maxRecord, currentPage, maxPage) |
|
|
|
|
|
# |
|
|
# exitApplication |
|
|
# |
|
|
# Forces closure of the form by passing a non-vetoable close |
|
|
# to the application's frame. closeTrap will then exit w/o |
|
|
# asking the form for permission again. |
|
|
# |
|
|
def exitApplication(self,event): |
|
|
self._exit() |
|
|
|
|
|
# |
|
272 |
# switchFocus |
# switchFocus |
273 |
# |
# |
274 |
# Moves the focus to a specific UI widget |
# Moves the focus to a specific UI widget |
275 |
# |
# |
276 |
def switchFocus(self, event): |
def switchFocus(self, event): |
277 |
formObject = event.data['object'] |
object = event.object |
278 |
if formObject: # Some pages might not have any widgets that can be active |
if object: # Some pages might not have any widgets that can be active |
279 |
index = formObject._visibleIndex |
index = object._visibleIndex |
280 |
self._formToUIWidget[formObject].indexedFocus(index) |
self._formToUIWidget[object].indexedFocus(index) |
|
|
|
|
self.dispatchEvent(events.Event('beginEDITMODE', formObject)) |
|
|
|
|
|
|
|
|
# |
|
|
# aboutBox |
|
|
# |
|
|
# Displays a modal about box on the screen. |
|
|
# |
|
|
def aboutBox(self, event): |
|
|
programVersion = event.data[0] |
|
|
formName = event.data[1] |
|
|
formVersion = event.data[2] |
|
|
author = event.data[3] |
|
|
description = event.data[4] |
|
|
|
|
|
about = self._DIALOGS['about'](self.mainWindow, programVersion, formName, formVersion, author, description) |
|
|
about.showModal() |
|
|
about.destroy() |
|
|
|
|
|
# |
|
|
# msgBox |
|
|
# |
|
|
def msgBox(self,event): |
|
|
message = event.data.message |
|
|
caption = event.data.caption |
|
|
|
|
|
dialog = self._DIALOGS['messageBox'](self.mainWindow, message, caption) |
|
|
dialog.showModal() |
|
|
dialog.destroy() |
|
|
|
|
|
|
|
|
# |
|
|
# genericBox |
|
|
# |
|
|
def genericBox(self,event): |
|
|
message = event.data[0] |
|
|
caption = "Aviso" |
|
|
buttonSet = event.data[1] |
|
|
if len(event.data) > 2: |
|
|
defaultButton = event.data[2] |
|
|
else: |
|
|
defaultButton = -1 |
|
|
if len(event.data) > 3: |
|
|
cancelButton = event.data[3] |
|
|
else: |
|
|
cancelButton = -1 |
|
|
|
|
|
self.genericBox = uiDlg = self._DIALOGS['genericBox'](self.mainWindow, caption) |
|
|
self.genericBox = dlg = uiDlg.createGenericBox(message, buttonSet) |
|
|
|
|
|
dlg.ShowModal() |
|
|
|
|
|
event.data = [uiDlg.getResult()] |
|
|
|
|
|
# |
|
|
# updateEntryEditor |
|
|
# |
|
|
def updateEntryEditor(self, event): |
|
|
index = event.object._visibleIndex |
|
|
widget = self._formToUIWidget[event.object] |
|
|
widget.setValue(event.display, index) |
|
|
widget.setCursorPosition(event.cursor, index) |
|
|
|
|
|
if event.selection != None: |
|
|
selection1, selection2 = event.selection |
|
|
widget.setSelectedArea(selection1, selection2, index) |
|
281 |
|
|
282 |
|
self.dispatchEvent('beginEDITMODE', object, _form=object._form) |
283 |
|
|
284 |
# |
# |
285 |
# updateEntry |
# updateEntry |
289 |
return |
return |
290 |
|
|
291 |
entry = event.data |
entry = event.data |
292 |
|
field = entry._field |
293 |
handler = entry._displayHandler |
handler = entry._displayHandler |
294 |
prehandling = handler.editing |
prehandling = handler.editing |
295 |
handler.editing = 0 |
handler.editing = 0 |
300 |
# Fill the prior spots |
# Fill the prior spots |
301 |
for count in range(index): |
for count in range(index): |
302 |
value = handler.getDisplayFiller(block._resultSet.getRecord(currentRecord- \ |
value = handler.getDisplayFiller(block._resultSet.getRecord(currentRecord- \ |
303 |
(index-count)).getField(entry.field)) |
(index-count)).getField(field.field)) |
|
|
|
304 |
self._formToUIWidget[entry].setValue(value,count) |
self._formToUIWidget[entry].setValue(value,count) |
305 |
|
|
|
|
|
|
|
|
306 |
# Fill current spot |
# Fill current spot |
307 |
value = handler.getDisplayFiller(entry.getValue()) |
value = handler.getDisplayFiller(entry.getValue()) |
308 |
self._formToUIWidget[entry].setValue(value, index) |
self._formToUIWidget[entry].setValue(value, index) |
325 |
# Don't ask... but it's needed |
# Don't ask... but it's needed |
326 |
lastRow -= 1 |
lastRow -= 1 |
327 |
else: |
else: |
328 |
value = handler.getDisplayFiller(rec.getField(entry.field)) |
value = handler.getDisplayFiller(rec.getField(field.field)) |
329 |
|
|
330 |
self._formToUIWidget[entry].setValue(value, count, cr <= lastRow) |
self._formToUIWidget[entry].setValue(value, count, cr <= lastRow) |
331 |
count += 1 |
count += 1 |
332 |
|
|
333 |
handler.editing = prehandling |
handler.editing = prehandling |
334 |
|
|
335 |
|
# |
336 |
|
# updateEntryEditor |
337 |
|
# |
338 |
|
def updateEntryEditor(self, event): |
339 |
|
index = event.object._visibleIndex |
340 |
|
widget = self._formToUIWidget[event.object] |
341 |
|
#print "lookups in",self._formToUIWidget |
342 |
|
widget.setValue(event.display, index) |
343 |
|
widget.setCursorPosition(event.cursor, index) |
344 |
|
|
345 |
|
if event.selection != None: |
346 |
|
selection1, selection2 = event.selection |
347 |
|
widget.setSelectedArea(selection1, selection2, index) |
348 |
|
|
349 |
|
# |
350 |
|
# Clipboard routines |
351 |
|
# |
352 |
|
# If a particular UI has a system-wide clipboard, |
353 |
|
# these methods should be overridden to use that |
354 |
|
# clipboard. |
355 |
|
# |
356 |
|
def getClipboardContents(self, event): |
357 |
|
GDebug.printMesg(5, "Getting clipboard '%s'" % self.__clipboard) |
358 |
|
event.__result__ = "%s" % self.__clipboard |
359 |
|
|
360 |
|
def setClipboardContents(self, event): |
361 |
|
GDebug.printMesg(5, "Setting clipboard '%s'" % event.text) |
362 |
|
self.__clipboard = "%s" % event.text |
363 |
|
|
364 |
|
# |
365 |
|
# updateStatusBar |
366 |
|
# |
367 |
|
# Calls the UIs function to update status |
368 |
|
def updateStatusBar(self,event): |
369 |
|
|
370 |
|
#tip, recordStatus, insertMode, currentRecord, maxRecord, currentPage, maxPage =event.data |
371 |
|
|
372 |
|
status = None |
373 |
|
if event.recordStatus != None: |
374 |
|
status = self.statusValues[event.recordStatus] |
375 |
|
|
376 |
|
insertValue = None |
377 |
|
if event.insertMode != None: |
378 |
|
insertValue = event.insertMode and 'INS' or 'OVR' |
379 |
|
self._setStatusBar(event.tip, status, insertValue, event.currentRecord, event.maxRecord, event.currentPage, event.maxPage) |
380 |
|
|
381 |
|
# |
382 |
|
# msgBox |
383 |
|
# |
384 |
|
def msgBox(self,event): |
385 |
|
message = event.data.message |
386 |
|
caption = event.data.caption |
387 |
|
|
388 |
|
dialog = self._DIALOGS['messageBox'](self.mainWindow, message, caption) |
389 |
|
dialog.showModal() |
390 |
|
dialog.destroy() |
391 |
|
|
392 |
|
# |
393 |
|
# aboutBox |
394 |
|
# |
395 |
|
# Displays a modal about box on the screen. |
396 |
|
# |
397 |
|
def aboutBox(self, event): |
398 |
|
programVersion = event.data[0] |
399 |
|
formName = event.data[1] |
400 |
|
formVersion = event.data[2] |
401 |
|
author = event.data[3] |
402 |
|
description = event.data[4] |
403 |
|
|
404 |
|
about = self._DIALOGS['about'](self.mainWindow, programVersion, formName, formVersion, author, description) |
405 |
|
about.showModal() |
406 |
|
about.destroy() |
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
############################################################################# |
411 |
|
# |
412 |
|
# Optional Functions |
413 |
|
# |
414 |
|
# UIDrivers can override the following functions |
415 |
|
# |
416 |
|
|
417 |
|
# |
418 |
|
# beginWait |
419 |
# Called whenever forms goes into a "wait" state in which user cannot |
# Called whenever forms goes into a "wait" state in which user cannot |
420 |
# interact with interface (e.g., while waiting for a query or a commit) |
# interact with interface (e.g., while waiting for a query or a commit) |
421 |
|
# |
422 |
def beginWait (self, event): |
def beginWait (self, event): |
423 |
pass |
pass |
424 |
|
|
425 |
|
# |
426 |
|
# endWait |
427 |
|
# |
428 |
# Called whenever forms leaves a "wait" state |
# Called whenever forms leaves a "wait" state |
429 |
|
# |
430 |
def endWait (self, event): |
def endWait (self, event): |
431 |
pass |
pass |
432 |
|
|
433 |
|
# exitApplication |
434 |
|
# |
435 |
|
# Form has told the application to close so call the UIs private exit routine |
436 |
|
# |
437 |
|
def exitApplication(self,event): |
438 |
|
self._exit() |
439 |
|
|
440 |
|
# |
441 |
|
# _updateCreateEvent |
442 |
|
# |
443 |
|
# Can be used by UI drivers to add more attributes to the event that |
444 |
|
# creates a widget. Called by the _stdConstructor during the building of the UI |
445 |
|
# |
446 |
|
def _updateCreateEvent(self, event): |
447 |
|
return event |
448 |
|
|
449 |
|
|
450 |
|
|
451 |
|
|
452 |
|
############################################################################# |
453 |
|
# |
454 |
|
# Required Functions |
455 |
|
# |
456 |
|
# UIDrivers must implement the following features |
457 |
|
|
458 |
|
# |
459 |
|
# |
460 |
|
# |
461 |
|
def _activateForm(self): |
462 |
|
GDebug.printMesg(0, "Fatal UI driver error. Required function not implemented") |
463 |
|
sys.exit(1) |
464 |
|
|
465 |
|
def _exit(self): |
466 |
|
GDebug.printMesg(0, "Fatal UI driver error. Required function not implemented") |
467 |
|
sys.exit(1) |
468 |
|
|
469 |
|
def gotoPage(self,event): |
470 |
|
GDebug.printMesg(0, "Fatal UI driver error. Required function not implemented") |
471 |
|
sys.exit(1) |
472 |
|
|
473 |
|
|
474 |
|
################################################################################ |
475 |
|
# |
476 |
|
# Bogus class designed to force system failure if an individual ui driver |
477 |
|
# doesn't override GFUserInterfaceBase's _WIDGETS variable |
478 |
|
# |
479 |
|
################################################################################ |
480 |
|
class UIFailure: |
481 |
|
def __init__(self, event): |
482 |
|
print "Fatal UI driver error. _WIDGETS not properly setup in UI driver" |
483 |
|
sys.exit(1) |
484 |
|
|
485 |
|
|
486 |
|
# Creating base dictionary for language font encodings |
487 |
|
encodings = { |
488 |
|
'iso8859-1':None, |
489 |
|
'iso8859-2':None, |
490 |
|
'iso8859-3':None, |
491 |
|
'iso8859-4':None, |
492 |
|
'iso8859-5':None, |
493 |
|
'iso8859-6':None, |
494 |
|
'iso8859-7':None, |
495 |
|
'iso8859-8':None, |
496 |
|
'iso8859-9':None, |
497 |
|
'iso8859-10':None, |
498 |
|
'iso8859-11':None, |
499 |
|
'iso8859-12':None, |
500 |
|
'iso8859-13':None, |
501 |
|
'iso8859-14':None, |
502 |
|
'iso8859-15':None, |
503 |
|
'koi8':None, # TODO: not sure about these |
504 |
|
'koi8-r':None, |
505 |
|
'cp1250':None, |
506 |
|
'cp1251':None, |
507 |
|
'cp1252':None |
508 |
|
} |
509 |
|
|