Changeset 2650
- Timestamp:
- 01/10/07 21:44:36 (2 years ago)
- Files:
-
- branches/paul_sandbox/dabo/__init__.py (modified) (3 diffs)
- branches/paul_sandbox/dabo/dApp.py (modified) (1 diff)
- branches/paul_sandbox/dabo/dEvents.py (modified) (1 diff)
- branches/paul_sandbox/dabo/db/dCursorMixin.py (modified) (3 diffs)
- branches/paul_sandbox/dabo/db/dbFirebird.py (modified) (1 diff)
- branches/paul_sandbox/dabo/db/dbMsSQL.py (modified) (3 diffs)
- branches/paul_sandbox/dabo/icons/__init__.py (modified) (2 diffs)
- branches/paul_sandbox/dabo/lib/DesignerXmlConverter.py (modified) (2 diffs)
- branches/paul_sandbox/dabo/lib/datanav/Form.py (modified) (5 diffs)
- branches/paul_sandbox/dabo/lib/datanav/Grid.py (modified) (1 diff)
- branches/paul_sandbox/dabo/lib/datanav/Page.py (modified) (1 diff)
- branches/paul_sandbox/dabo/lib/propertyHelperMixin.py (modified) (5 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/__init__.py (modified) (7 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dBaseMenuBar.py (modified) (6 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dDateTextBox.py (modified) (1 diff)
- branches/paul_sandbox/dabo/ui/uiwx/dEditor.py (modified) (7 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dFormMixin.py (modified) (5 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dGrid.py (modified) (2 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dImage.py (modified) (2 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dMenu.py (modified) (9 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dPemMixin.py (modified) (7 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dShell.py (modified) (4 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dSplitter.py (modified) (1 diff)
- branches/paul_sandbox/dabo/ui/uiwx/dToolBar.py (modified) (10 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/dTreeView.py (modified) (17 diffs)
- branches/paul_sandbox/dabo/ui/uiwx/uiApp.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/paul_sandbox/dabo/__init__.py
r2340 r2650 118 118 sys.exit(msg) 119 119 120 # dApp will change the following values upon its __init__: 121 dAppRef = None 122 120 123 # Instantiate the logger object, which will send messages to user-overridable 121 124 # locations. Do this before any other imports. … … 131 134 from settings import * 132 135 133 # dApp will change the following values upon its __init__:134 dAppRef = None135 136 136 from __version__ import version 137 137 import dColors … … 145 145 from dPref import dPref 146 146 147 # Make sure dabo.db, dabo.biz, and dabo.ui are imported: 148 import dabo.db 149 import dabo.biz 150 import dabo.ui branches/paul_sandbox/dabo/dApp.py
r2559 r2650 587 587 self.uiApp.onEditPreferences(evt) 588 588 # These handle MRU menu requests 589 def addToMRU(self, menu, prmpt, bindfunc=None ):590 self.uiApp.addToMRU(menu, prmpt, bindfunc )589 def addToMRU(self, menu, prmpt, bindfunc=None, *args, **kwargs): 590 self.uiApp.addToMRU(menu, prmpt, bindfunc, *args, **kwargs) 591 591 def onMenuOpenMRU(self, menu): 592 592 self.uiApp.onMenuOpenMRU(menu) branches/paul_sandbox/dabo/dEvents.py
r2542 r2650 3 3 from dabo.dObject import dObject 4 4 import dabo.ui as ui 5 import dabo.biz.dBizobj as dBizobj6 5 from dabo.dLocalize import _ 7 6 branches/paul_sandbox/dabo/db/dCursorMixin.py
r2649 r2650 1 # dabo/db/dCursorMixin 2 1 3 import types 2 4 import datetime … … 195 197 # change self.Encoding and log the message 196 198 self.Encoding = enc 197 dabo.errorLog.write(_(" Incorrect unicode encoding set; using '%s' instead")198 % enc)199 dabo.errorLog.write(_("Field %(fname)s: Incorrect unicode encoding set; using '%(enc)s' instead") 200 % {'fname':field_name, 'enc':enc} ) 199 201 break 200 202 else: … … 2003 2005 2004 2006 def __getattr__(self, att): 2005 err = False2006 2007 return self.cursor.getFieldVal(att) 2007 2008 branches/paul_sandbox/dabo/db/dbFirebird.py
r2323 r2650 12 12 self.fieldPat = re.compile("([A-Za-z_][A-Za-z0-9-_]+)\.([A-Za-z_][A-Za-z0-9-_]+)") 13 13 import kinterbasdb 14 kinterbasdb.init(type_conv=200) 14 if not kinterbasdb.initialized: 15 kinterbasdb.init(type_conv=200) 15 16 self.dbapi = kinterbasdb 16 17 branches/paul_sandbox/dabo/db/dbMsSQL.py
r2612 r2650 27 27 password = connectInfo.revealPW() 28 28 database = connectInfo.Database 29 30 # hack to make this work. I am sure there is a better way. 31 self.database = database 29 32 30 33 self._connection = pymssql.connect(host=host, user=user,password=password, database=database) … … 61 64 tempCursor = self._connection.cursor() 62 65 # jfcs 11/01/06 assumed public schema 63 tempCursor.execute("select name from sysobjects where xtype = 'U' order by name") 66 # cfk: this worries me: how does it know what db is being used? 67 # tempCursor.execute("select name from sysobjects where xtype = 'U' order by name") 68 69 dbName = self.database 70 tempCursor.execute("select table_name" 71 " from INFORMATION_SCHEMA.TABLES" 72 " where table_catalog = '%(db)s'" 73 " and table_type = 'BASE TABLE'" 74 " order by table_name" 75 % {'db':dbName} ) 64 76 rs = tempCursor.fetchall() 65 tables = [] 66 for record in rs: 67 tables.append(record[0]) 77 tables = [x[0] for x in rs] 68 78 return tuple(tables) 69 79 … … 71 81 def getTableRecordCount(self, tableName): 72 82 tempCursor = self._connection.cursor() 73 tempCursor.execute("select count(*) as ncount from %s" % tableName)83 tempCursor.execute("select count(*) as ncount from '%(tablename)'" % tableName) 74 84 return tempCursor.fetchall()[0][0] 75 85 86 def _fieldTypeNativeToDabo(self, nativeType): 87 """ converts the results of 88 select DATA_TYPE from INFORMATION_SCHEMA.COLUMNS 89 to a dabo datatype. 90 """ 91 92 # todo: break out the dict into a constant defined somewhere 93 # todo: make a formal definition of the dabo datatypes. 94 # (at least document them) 95 96 try: 97 ret = { 98 "BINARY": "I", 99 "BIT": "I", 100 "BIGINT": "I", 101 "BLOB": "M", 102 "CHAR": "C", 103 "DATE": "D", 104 "DATETIME": "T", 105 "DECIMAL": "N", 106 "DOUBLE": "G", 107 "ENUM": "C", 108 "FLOAT": "F", 109 "GEOMETRY": "?", 110 "INT": "I", 111 "IMAGE": "?", 112 "INTERVAL": "?", 113 "LONG": "G", 114 "LONGBLOB": "M", 115 "LONGTEXT": "M", 116 "MEDIUMBLOB": "M", 117 "MEDIUMINT": "I", 118 "MEDIUMTEXT": "M", 119 "MONEY": "F", 120 "NEWDATE": "?", 121 "NCHAR": "C", 122 "NTEXT": "M", 123 "NUMERIC": "N", 124 "NVARCHAR": "C", 125 "NULL": "?", 126 "SET": "?", 127 "SHORT": "I", 128 "SMALLINT": "I", 129 "STRING": "C", 130 "TEXT": "M", 131 "TIME": "?", 132 "TIMESTAMP": "T", 133 "TINY": "I", 134 "TINYINT": "I", 135 "TINYBLOB": "M", 136 "TINYTEXT": "M", 137 "UNIQUEIDENTIFIER": "?", 138 "VARBINARY": "I", 139 "VARCHAR": "C", 140 "VAR_STRING": "C", 141 "YEAR": "?"}[nativeType.upper()] 142 except KeyError: 143 print 'KeyError:', nativeType 144 ret = '?' 145 return ret 76 146 77 147 def getFields(self, tableName): 148 """ Returns the list of fields of the passed table 149 field: ( fieldname, dabo data type, key ) 150 """ 78 151 tempCursor = self._connection.cursor() 79 # Ok get the 'field name', 'field type' 80 tempCursor.execute("""SELECT table_name=sysobjects.name, 81 column_name=syscolumns.name, 82 datatype=systypes.name, 83 length=syscolumns.length 84 FROM sysobjects 85 JOIN syscolumns ON sysobjects.id = syscolumns.id 86 JOIN systypes ON syscolumns.xtype=systypes.xtype 87 WHERE sysobjects.xtype='U' and sysobjects.name = '%s' 88 ORDER BY sysobjects.name,syscolumns.colid 89 """ % tableName) 90 notcleanRS = tempCursor.fetchall() 91 #jfcs 11/09/06 added below to remove dup-records that contain the field type as 'sysname' 92 # the funny things is the above sql statements works in MS enterprize manager and the 93 # record do not contain the 'sysname' record????? 94 rs=[] 95 for cleanrow in notcleanRS: 96 if 'sysname' not in cleanrow: 97 rs.append(cleanrow) 98 99 ## get the PK 100 tempCursor.execute("""select c.name from sysindexes i 101 join sysobjects o ON i.id = o.id 102 join sysobjects pk ON i.name = pk.name 103 AND pk.parent_obj = i.id 104 AND pk.xtype = 'PK' 105 join sysindexkeys ik on i.id = ik.id 106 and i.indid = ik.indid 107 join syscolumns c ON ik.id = c.id 108 AND ik.colid = c.colid 109 where o.name = '%s' 110 order by ik.keyno""" % tableName) 111 rs2=tempCursor.fetchall() 112 113 if rs2==[]: 114 thePKFieldName = None 115 else: 116 #thestr = rs2[0][0] 117 #thePKFieldName = thestr[thestr.find("(") + 1: thestr.find(")")].split(", ") 118 thePKFieldName = rs2[0][0] 119 152 # fairly standard way of getting column settings 153 # this may be standard wnough to put in the super class 154 155 dbName = self.database 156 157 tempCursor.execute( 158 "select COLUMN_NAME, DATA_TYPE" 159 " from INFORMATION_SCHEMA.COLUMNS" 160 " where table_catalog = '%(db)s'" 161 " and table_name = '%(table)s'" 162 " order by ORDINAL_POSITION" 163 % {'table':tableName, 'db':dbName} ) 164 fieldDefs = tempCursor.fetchall() 165 166 tempCursor.execute( 167 "select COLUMN_NAME " 168 " from information_schema.Constraint_Column_Usage CCU" 169 " join information_schema.TABLE_CONSTRAINTS TC" 170 " on CCU.CONSTRAINT_NAME = TC.CONSTRAINT_NAME" 171 " where" 172 " CONSTRAINT_TYPE = 'PRIMARY KEY'" 173 " and TC.CONSTRAINT_CATALOG = '%(db)s'" 174 " and TC.Table_Name = '%(table)s'" 175 % {'table':tableName, 'db':dbName} ) 176 pkFields = tempCursor.fetchall() 177 120 178 fields = [] 121 for r in rs: 122 name = r[1] 123 fldType =r[2] 124 pk = False 125 if thePKFieldName is not None: 126 pk = (name in thePKFieldName) 127 if "int" in fldType: 128 fldType = "I" 129 elif "char" in fldType : 130 fldType = "C" 131 elif "bool" in fldType : 132 fldType = "B" 133 elif "text" in fldType: 134 fldType = "M" 135 elif "numeric" in fldType: 136 fldType = "N" 137 elif "datetime" in fldType: 138 fldType = "T" 139 elif "money" in fldType : 140 fldType = "N" 141 elif "bit" in fldType : 142 fldType = "I" 143 else: 144 fldType = "?" 145 fields.append((name.strip(), fldType, pk)) 179 for r in fieldDefs: 180 name = r[0] 181 ft = self._fieldTypeNativeToDabo(r[1]) 182 # pk = (r[2] == "PRI") 183 pk = (name,) in pkFields 184 # if pk: 185 # print r[0] 186 fields.append((name, ft, pk)) 146 187 return tuple(fields) 147 148 188 149 189 #def getUpdateTablePrefix(self, tbl): branches/paul_sandbox/dabo/icons/__init__.py
r1632 r2650 1 1 import sys 2 2 import os 3 import glob 3 4 4 5 defaultExtension = "png" … … 33 34 break 34 35 return ret 36 37 38 def getAvailableIcons(): 39 """Returns a list of all available icon names.""" 40 ret = [] 41 pth = __path__[0] 42 defExt = ".%s" % defaultExtension 43 exts = ["png", "jpg", "gif", "bmp"] 44 for ext in exts: 45 ics = glob.glob("%s/*.%s" % (pth, ext)) 46 ret += [os.path.split(ic)[-1].replace(defExt, "") for ic in ics] 47 return ret branches/paul_sandbox/dabo/lib/DesignerXmlConverter.py
r2612 r2650 549 549 # Standard class template 550 550 self.containerClassTemplate = """class %(clsName)s(%(superName)s): 551 def __init__(self, parent=%(prnt)s, attProperties=%(cleanAtts)s ):552 super(%(clsName)s, self).__init__(parent=parent, attProperties=attProperties )551 def __init__(self, parent=%(prnt)s, attProperties=%(cleanAtts)s, *args, **kwargs): 552 super(%(clsName)s, self).__init__(parent=parent, attProperties=attProperties, *args, **kwargs) 553 553 self.Sizer = None 554 554 %(indCode)s … … 556 556 """ 557 557 self.classTemplate = """class %s(dabo.ui.%s): 558 def __init__(self, parent=%s, attProperties=%s ):559 dabo.ui.%s.__init__(self, parent=parent, attProperties=attProperties )558 def __init__(self, parent=%s, attProperties=%s, *args, **kwargs): 559 dabo.ui.%s.__init__(self, parent=parent, attProperties=attProperties, *args, **kwargs) 560 560 %s 561 561 branches/paul_sandbox/dabo/lib/datanav/Form.py
r2612 r2650 146 146 147 147 if self.FormType != 'Edit': 148 self.appendToolBarButton("First", "leftArrows", bindfunc=self.onFirst,148 self.appendToolBarButton("First", "leftArrows", OnHit=self.onFirst, 149 149 tip=_("First"), help=_("Go to the first record")) 150 self.appendToolBarButton("Prior", "leftArrow", bindfunc=self.onPrior,150 self.appendToolBarButton("Prior", "leftArrow", OnHit=self.onPrior, 151 151 tip=_("Prior"), help=_("Go to the prior record")) 152 self.appendToolBarButton("Requery", "requery", bindfunc=self.onRequery,152 self.appendToolBarButton("Requery", "requery", OnHit=self.onRequery, 153 153 tip=_("Requery"), help=_("Requery dataset")) 154 self.appendToolBarButton("Next", "rightArrow", bindfunc=self.onNext,154 self.appendToolBarButton("Next", "rightArrow", OnHit=self.onNext, 155 155 tip=_("Next"), help=_("Go to the next record")) 156 self.appendToolBarButton("Last", "rightArrows", bindfunc=self.onLast,156 self.appendToolBarButton("Last", "rightArrows", OnHit=self.onLast, 157 157 tip=_("Last"), help=_("Go to the last record")) 158 158 tb.appendSeparator() 159 159 160 160 if self.FormType == 'Normal': 161 self.appendToolBarButton("New", "blank", bindfunc=self.onNew,161 self.appendToolBarButton("New", "blank", OnHit=self.onNew, 162 162 tip=_("New"), help=_("Add a new record")) 163 self.appendToolBarButton("Delete", "delete", bindfunc=self.onDelete,163 self.appendToolBarButton("Delete", "delete", OnHit=self.onDelete, 164 164 tip=_("Delete"), help=_("Delete this record")) 165 165 tb.appendSeparator() 166 166 167 167 if self.FormType != 'PickList': 168 self.appendToolBarButton("Save", "save", bindfunc=self.onSave,168 self.appendToolBarButton("Save", "save", OnHit=self.onSave, 169 169 tip=_("Save"), help=_("Save changes")) 170 self.appendToolBarButton("Cancel", "revert", bindfunc=self.onCancel,170 self.appendToolBarButton("Cancel", "revert", OnHit=self.onCancel, 171 171 tip=_("Cancel"), help=_("Cancel changes")) 172 172 tb.appendSeparator() 173 173 174 174 if self.FormType != "Edit": 175 self.appendToolBarButton("SQL", "zoomNormal", bindfunc=self.onShowSQL,175 self.appendToolBarButton("SQL", "zoomNormal", OnHit=self.onShowSQL, 176 176 tip=_("Show SQL"), help=_("Show the last executed SQL statement")) 177 177 178 178 if self.FormType == "Normal": 179 179 self.appendToolBarButton(_("Quick Report"), "print", 180 bindfunc=self.onQuickReport, tip=_("Quick Report"),180 OnHit=self.onQuickReport, tip=_("Quick Report"), 181 181 help=_("Run a Quick Report on the current dataset")) 182 182 … … 187 187 188 188 menu.append(_("Set Selection &Criteria")+"\tAlt+1", 189 bindfunc=self.onSetSelectionCriteria, bmp="checkMark",189 OnHit=self.onSetSelectionCriteria, bmp="checkMark", 190 190 help=_("Set the selection criteria for the recordset.")) 191 191 192 192 menu.append(_("&Browse Records")+"\tAlt+2", 193 bindfunc=self.onBrowseRecords, bmp="browse",193 OnHit=self.onBrowseRecords, bmp="browse", 194 194 help=_("Browse the records in the current recordset.")) 195 195 … … 208 208 index+1) 209 209 210 menu.append(title, bindfunc=self.onEditCurrentRecord, bmp="edit",210 menu.append(title, OnHit=self.onEditCurrentRecord, bmp="edit", 211 211 help=_("Edit the fields of the currently selected record."), 212 212 Tag=self.pageFrame.Pages[index].DataSource) … … 214 214 215 215 if self.FormType != "Edit": 216 menu.append(_("&Requery")+"\tCtrl+R", bindfunc=self.onRequery, bmp="requery",216 menu.append(_("&Requery")+"\tCtrl+R", OnHit=self.onRequery, bmp="requery", 217 217 help=_("Get a new recordset from the backend."), menutype="check") 218 218 219 219 if self.FormType != "PickList": 220 menu.append(_("&Save Changes")+"\tCtrl+S", bindfunc=self.onSave, bmp="save",220 menu.append(_("&Save Changes")+"\tCtrl+S", OnHit=self.onSave, bmp="save", 221 221 help=_("Save any changes made to the records.")) 222 menu.append(_("&Cancel Changes"), bindfunc=self.onCancel, bmp="revert",222 menu.append(_("&Cancel Changes"), OnHit=self.onCancel, bmp="revert", 223 223 help=_("Cancel any changes made to the records.")) 224 224 menu.appendSeparator() … … 232 232 233 233 menu.append(_("Select &First Record")+"\t%s+UP" % altKey, 234 bindfunc=self.onFirst, bmp="leftArrows",234 OnHit=self.onFirst, bmp="leftArrows", 235 235 help=_("Go to the first record in the set.")) 236 236 menu.append(_("Select &Prior Record")+"\t%s+LEFT" % altKey, 237 bindfunc=self.onPrior,bmp="leftArrow",237 OnHit=self.onPrior,bmp="leftArrow", 238 238 help=_("Go to the prior record in the set.")) 239 239 menu.append(_("Select Ne&xt Record")+"\t%s+RIGHT" % altKey, 240 bindfunc=self.onNext, bmp="rightArrow",240 OnHit=self.onNext, bmp="rightArrow", 241 241 help=_("Go to the next record in the set.")) 242 242 menu.append(_("Select &Last Record")+"\t%s+DOWN" % altKey, 243 bindfunc=self.onLast, bmp="rightArrows",243 OnHit=self.onLast, bmp="rightArrows", 244 244 help=_("Go to the last record in the set.")) 245 245 menu.appendSeparator() 246 246 247 247 if self.FormType == "Normal": 248 menu.append(_("&New Record")+"\tCtrl+N", bindfunc=self.onNew, bmp="blank",248 menu.append(_("&New Record")+"\tCtrl+N", OnHit=self.onNew, bmp="blank", 249 249 help=_("Add a new record to the dataset.")) 250 menu.append(_("&Delete Current Record"), bindfunc=self.onDelete, bmp="delete",250 menu.append(_("&Delete Current Record"), OnHit=self.onDelete, bmp="delete", 251 251 help=_("Delete the current record from the dataset.")) 252 252 menu.appendSeparator() 253 253 254 254 if self.FormType != "Edit": 255 menu.append(_("Show S&QL"), bindfunc=self.onShowSQL, bmp="zoomNormal")255 menu.append(_("Show S&QL"), OnHit=self.onShowSQL, bmp="zoomNormal") 256 256 257 257 if self.FormType == "Normal": 258 menu.append(_("Quick &Report"), bindfunc=self.onQuickReport, bmp="print",258 menu.append(_("Quick &Report"), OnHit=self.onQuickReport, bmp="print", 259 259 DynamicEnabled=self.enableQuickReport) 260 260 branches/paul_sandbox/dabo/lib/datanav/Grid.py
r2539 r2650 164 164 try: 165 165 if self.Form.FormType == 'PickList': 166 menu.append(_("&Pick"), bindfunc=self.pickRecord, bmp="edit",166 menu.append(_("&Pick"), OnHit=self.pickRecord, bmp="edit", 167 167 help=_("Pick this record")) 168 168 else: 169 menu.append(_("&New"), bindfunc=self.newRecord, bmp="blank",169 menu.append(_("&New"), OnHit=self.newRecord, bmp="blank", 170 170 help=_("Add a new record")) 171 menu.append("&Edit", bindfunc=self.editRecord, bmp="edit",171 menu.append("&Edit", OnHit=self.editRecord, bmp="edit", 172 172 help=_("Edit this record")) 173 menu.append("&Delete", bindfunc=self.deleteRecord, bmp="delete",173 menu.append("&Delete", OnHit=self.deleteRecord, bmp="delete", 174 174 help=_("Delete this record")) 175 175 return menu branches/paul_sandbox/dabo/lib/datanav/Page.py
r2623 r2650 143 143 mn = dabo.ui.dMenu() 144 144 if self.sortFields: 145 mn.append(_("Show sort order"), bindfunc=self.handleSortOrder)145 mn.append(_("Show sort order"), OnHit=self.handleSortOrder) 146 146 if self.sortFields.has_key(self.sortDS): 147 147 mn.append(_("Remove sort on ") + self.sortCap, 148 bindfunc=self.handleSortRemove)149 150 mn.append(_("Sort Ascending"), bindfunc=self.handleSortAsc)151 mn.append(_("Sort Descending"), bindfunc=self.handleSortDesc)148 OnHit=self.handleSortRemove) 149 150 mn.append(_("Sort Ascending"), OnHit=self.handleSortAsc) 151 mn.append(_("Sort Descending"), OnHit=self.handleSortDesc) 152 152 self.PopupMenu(mn, obj.formCoordinates(evt.EventData["mousePosition"]) ) 153 153 mn.release() branches/paul_sandbox/dabo/lib/propertyHelperMixin.py
r2572 r2650 4 4 5 5 class PropertyHelperMixin(object): 6 """ Helper functions for getting information on class properties. 7 """ 6 """ Helper functions for getting information on class properties.""" 8 7 9 8 def _expandPropStringValue(self, value, propList): … … 61 60 del kwdict[arg] 62 61 return propdict 62 63 64 def _extractKeyWordEventBindings(self, kwdict, evtdict): 65 """ Called from __init__: puts any On* event keyword arguments into 66 the event dictionary. 67 """ 68 if evtdict is None: 69 evtdict = {} 70 evts = self.getEventList() 71 onKWs = [(kw, kw[2:]) for kw in kwdict.keys() 72 if kw.startswith("On")] 73 for kw, evtName in onKWs: 74 if evtName in evts: 75 evtdict[evtName] = kwdict[kw] 76 del kwdict[kw] 77 return evtdict 63 78 64 79 … … 223 238 raise ValueError, "Could not set property '%s' to value: %s" % (prop, val) 224 239 225 240 241 def _setKwEventBindings(self, kwEvtDict): 242 """This method takes a dict of event names and method to which they are 243 to be bound, and binds the corresponding event to that method. 244 """ 245 for evtName, mthd in kwEvtDict.items(): 246 from dabo import dEvents 247 evt = dEvents.__dict__[evtName] 248 self.bindEvent(evt, mthd) 249 250 226 251 def getPropertyList(cls, refresh=False): 227 """ Returns the list of properties for this object (class or instance). 228 """ 252 """ Returns the list of properties for this object (class or instance).""" 229 253 try: 230 254 propLists = cls._propLists … … 261 285 262 286 def getPropertyInfo(cls, name): 263 """ Returns a dictionary of information about the passed property name. 264 """ 287 """ Returns a dictionary of information about the passed property name.""" 265 288 # cls can be either a class or self 266 289 classRef = cls … … 311 334 getPropertyInfo = classmethod(getPropertyInfo) 312 335 336 337 def getEventList(cls): 338 """Returns a list of all defined events.""" 339 from dabo import dEvents 340 return dEvents.__dict__.keys() 341 getEventList = classmethod(getEventList) branches/paul_sandbox/dabo/ui/uiwx/__init__.py
r2612 r2650 384 384 ed["hasModifiers"] = wxEvt.HasModifiers() 385 385 try: 386 if wx.Platform == "__WXMAC__":386 if wx.Platform in ("__WXMAC__", "__WXGTK__"): 387 387 ed["keyChar"] = chr(wxEvt.GetKeyCode()) 388 388 else: … … 644 644 return None 645 645 try: 646 prnt = self.Application.ActiveForm646 prnt = dabo.dAppRef.ActiveForm 647 647 except: 648 648 prnt = None … … 839 839 840 840 841 def createForm(srcFile, show=False ):841 def createForm(srcFile, show=False, *args, **kwargs): 842 842 """Pass in a .cdxml file from the Designer, and this will 843 843 instantiate a form from that spec. Returns a reference … … 847 847 conv = DesignerXmlConverter() 848 848 cls = conv.classFromXml(srcFile) 849 frm = cls( )849 frm = cls(*args, **kwargs) 850 850 if show: 851 851 frm.show() … … 866 866 """ 867 867 def addMenu(mb, menuDict, form, previewFunc): 868 if form is None: 869 form = dabo.dAppRef.ActiveForm 868 870 menu = dabo.ui.dMenu(mb) 869 871 atts = menuDict["attributes"] … … 885 887 cap = itmatts["Caption"] 886 888 hk = itmatts["HotKey"] 889 pic = itmatts["Picture"] 887 890 if hk: 888 891 cap += "\t%s" % hk … … 890 893 binding = previewFunc 891 894 fnc = "" 892 useFunc = (" Function" in itmatts) and (itmatts["Function"])895 useFunc = ("Action" in itmatts) and (itmatts["Action"]) 893 896 if useFunc: 894 fnc = itmatts[" Function"]897 fnc = itmatts["Action"] 895 898 if (binding is None) and fnc: 896 899 binding = eval(fnc) 897 900 help = itmatts["HelpText"] 898 menuItem = menu.append(cap, bindfunc=binding, help=help)899 menuItem._bindingText = fnc901 menuItem = menu.append(cap, OnHit=binding, help=help, 902 picture=pic) 900 903 901 904 mnd = dabo.lib.xmltodict.xmltodict(srcFile) branches/paul_sandbox/dabo/ui/uiwx/dBaseMenuBar.py
r2517 r2650 31 31 32 32 if self.Application.ShowCommandWindowMenu: 33 self.append(_("Command Win&dow") + "\tCtrl+D", bindfunc=app.onCmdWin,33 self.append(_("Command Win&dow") + "\tCtrl+D", OnHit=app.onCmdWin, 34 34 help=_("Open up a command window for debugging") ) 35 35 36 36 prmpt = _("Close Windo&w") + "\tCtrl+W" 37 self.append(prmpt, bindfunc=app.onWinClose, bmp="close",37 self.append(prmpt, OnHit=app.onWinClose, bmp="close", 38 38 help=_("Close the current window") ) 39 39 … … 43 43 # if wx.Platform == '__WXWIN__': 44 44 # prmpt = _("E&xit") + "\tAlt+F4" 45 self.append(prmpt, id=wx.ID_EXIT, bindfunc=app.onFileExit,45 self.append(prmpt, id=wx.ID_EXIT, OnHit=app.onFileExit, 46 46 bmp="exit", help=_("Exit the application") ) 47 47 … … 54 54 self.Caption = _("&Edit") 55 55 56 self.append(_("&Undo") + "\tCtrl+Z", bindfunc=app.onEditUndo, bmp="undo",56 self.append(_("&Undo") + "\tCtrl+Z", OnHit=app.onEditUndo, bmp="undo", 57 57 help=_("Undo last action") ) 58 58 59 self.append(_("&Redo") + "\tCtrl+R", bindfunc=app.onEditRedo, bmp="redo",59 self.append(_("&Redo") + "\tCtrl+R", OnHit=app.onEditRedo, bmp="redo", 60 60 help=_("Undo last undo") ) 61 61 62 62 self.appendSeparator() 63 63 64 self.append(_("Cu&t") + "\tCtrl+X", bindfunc=app.onEditCut, bmp="cut",64 self.append(_("Cu&t") + "\tCtrl+X", OnHit=app.onEditCut, bmp="cut", 65 65 help=_("Cut selected text") ) 66 66 67 self.append(_("&Copy") + "\tCtrl+C", bindfunc=app.onEditCopy, bmp="copy",67 self.append(_("&Copy") + "\tCtrl+C", OnHit=app.onEditCopy, bmp="copy", 68 68 help=_("Copy selected text") ) 69 69 70 self.append(_("&Paste") + "\tCtrl+V", bindfunc=app.onEditPaste, bmp="paste",70 self.append(_("&Paste") + "\tCtrl+V", OnHit=app.onEditPaste, bmp="paste", 71 71 help=_("Paste text from clipboard") ) 72 72 73 self.append(_("Select &All") + "\tCtrl+A", bindfunc=app.onEditSelectAll,73 self.append(_("Select &All") + "\tCtrl+A", OnHit=app.onEditSelectAll, 74 74 help=_("Select all text") ) 75 75 … … 78 78 # By default, the Find and Replace functions use a single dialog. The 79 79 # commented lines below this enable the plain Find dialog call. 80 self.append(_("&Find / Replace") + "\tCtrl+F", bindfunc=app.onEditFind,80 self.append(_("&Find / Replace") + "\tCtrl+F", OnHit=app.onEditFind, 81 81 bmp="find", help=_("Find text in the active window") ) 82 82 83 # self.append(_("Find") + "\tShift+Ctrl+F", bindfunc=app.onEditFindAlone,83 # self.append(_("Find") + "\tShift+Ctrl+F", OnHit=app.onEditFindAlone, 84 84 # bmp="find", help=_("Find text in the active window") ) 85 85 86 self.append(_("Find A&gain") + "\tCtrl+G", bindfunc=app.onEditFindAgain, bmp="",86 self.append(_("Find A&gain") + "\tCtrl+G", OnHit=app.onEditFindAgain, bmp="", 87 87 help=_("Repeat the last search") ) 88 88 89 89 self.appendSeparator() 90 90 91 itm = self.append(_("&Preferences"), bindfunc=app.onEditPreferences, bmp="configure",91 itm = self.append(_("&Preferences"), OnHit=app.onEditPreferences, bmp="configure", 92 92 help=_("Set user preferences") ) 93 93 # Put the prefs item in the App Menu on Mac … … 103 103 104 104 itm = self.append(_("Show/Hide Sizer &Lines")+"\tCtrl+L", 105 bindfunc=app.onShowSizerLines, menutype="check",105 OnHit=app.onShowSizerLines, menutype="check", 106 106 help=_("Cool sizer visualizing feature; check it out!")) 107 107 … … 114 114 115 115 itm = self.append(_("&About"), id=wx.ID_ABOUT, 116 bindfunc=app.onHelpAbout, bmp="apply",116 OnHit=app.onHelpAbout, bmp="apply", 117 117 help=_("About this application") ) 118 118 # Put the about menu in the App Menu on Mac branches/paul_sandbox/dabo/ui/uiwx/dDateTextBox.py
r2240 r2650 169 169 menu = dabo.ui.dMenu() 170 170 for nm, format in self.formats.items(): 171 itm = menu.append(format["prompt"], bindfunc=self.onRClickMenu)171 itm = menu.append(format["prompt"], OnHit=self.onRClickMenu) 172 172 format["id"] = itm.GetId() 173 173 self.showContextMenu(menu) branches/paul_sandbox/dabo/ui/uiwx/dEditor.py
r2612 r2650 292 292 with their starting positions in the text. 293 293 """ 294 pat = re.compile(r"^([ \t]*(?:def )|(?:class ))([^\(]+)\(", re.M) 294 295 ret = [] 295 def _lister(nd): 296 strNd = str(nd) 297 isClass = strNd.startswith("Class(") 298 isFunc = strNd.startswith("Function(") 299 kidlist = [] 300 txt = "" 301 try: 302 kids = nd.getChildren() 303 if isClass or isFunc: 304 txt = "%s %s" % (("class", "def")[isFunc], kids[isFunc]) 305 306 for kid in kids: 307 if isinstance(kid, compiler.ast.Node): 308 kidStuff = _lister(kid) 309 if kidStuff: 310 if isinstance(kidStuff, list): 311 kidlist += kidStuff 312 else: 313 kidlist.append(kidStuff) 314 if txt: 315 return {txt: kidlist} 316 else: 317 return kidlist 318 except: pass 319 320 needPosAdd = False 321 try: 322 prsTxt = compiler.parse(self.GetText()) 323 needPosAdd = True 324 except SyntaxError: 325 # The text is not compilable. 326 ret = self._bruteForceFuncList() 327 if needPosAdd: 328 nmKids = [] 329 for chNode in prsTxt: 330 chRet = _lister(chNode) 331 if chRet: 332 nmKids += _lister(chNode) 333 # OK, at this point we have a list of class/func names. Now we have to 334 # convert that to a dict where each element has a 'pos' property that 335 # contains the offset from top of the file, and a 'children' prop that contains 336 # any nested class/funcs. 337 self._classFuncPos = 0 338 ret = self._addPos(nmKids) 339 296 mtch = 1 297 pos = 0 298 txt = self.GetText() 299 while mtch: 300 mtch = pat.search(txt) 301 if mtch: 302 key, nm = mtch.groups() 303 pos += mtch.start(0) 304 ret.append((nm, pos, (key.strip() == "class"))) 305 keyOffset = len(key) 306 txt = txt[mtch.start(0) + keyOffset:] 307 pos += keyOffset 340
