Changeset 2650

Show
Ignore:
Timestamp:
01/10/07 21:44:36 (2 years ago)
Author:
paul
Message:

Merged all recent trunk changes into my branch, a preliminary step for
testing my branch before merging into trunk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/paul_sandbox/dabo/__init__.py

    r2340 r2650  
    118118        sys.exit(msg) 
    119119 
     120# dApp will change the following values upon its __init__: 
     121dAppRef = None 
     122 
    120123# Instantiate the logger object, which will send messages to user-overridable 
    121124# locations. Do this before any other imports. 
     
    131134from settings import * 
    132135 
    133 # dApp will change the following values upon its __init__: 
    134 dAppRef = None 
    135  
    136136from __version__ import version 
    137137import dColors 
     
    145145from dPref import dPref 
    146146 
     147# Make sure dabo.db, dabo.biz, and dabo.ui are imported: 
     148import dabo.db 
     149import dabo.biz 
     150import dabo.ui 
  • branches/paul_sandbox/dabo/dApp.py

    r2559 r2650  
    587587            self.uiApp.onEditPreferences(evt) 
    588588    # 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
    591591    def onMenuOpenMRU(self, menu): 
    592592        self.uiApp.onMenuOpenMRU(menu) 
  • branches/paul_sandbox/dabo/dEvents.py

    r2542 r2650  
    33from dabo.dObject import dObject 
    44import dabo.ui as ui 
    5 import dabo.biz.dBizobj as dBizobj 
    65from dabo.dLocalize import _ 
    76 
  • branches/paul_sandbox/dabo/db/dCursorMixin.py

    r2649 r2650  
     1# dabo/db/dCursorMixin 
     2 
    13import types 
    24import datetime 
     
    195197                            # change self.Encoding and log the message 
    196198                            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}
    199201                            break 
    200202                else: 
     
    20032005                 
    20042006                def __getattr__(self, att): 
    2005                     err = False 
    20062007                    return self.cursor.getFieldVal(att) 
    20072008             
  • branches/paul_sandbox/dabo/db/dbFirebird.py

    r2323 r2650  
    1212        self.fieldPat = re.compile("([A-Za-z_][A-Za-z0-9-_]+)\.([A-Za-z_][A-Za-z0-9-_]+)") 
    1313        import kinterbasdb 
    14         kinterbasdb.init(type_conv=200) 
     14        if not kinterbasdb.initialized: 
     15            kinterbasdb.init(type_conv=200) 
    1516        self.dbapi = kinterbasdb 
    1617 
  • branches/paul_sandbox/dabo/db/dbMsSQL.py

    r2612 r2650  
    2727        password = connectInfo.revealPW() 
    2828        database = connectInfo.Database 
     29         
     30        # hack to make this work.  I am sure there is a better way. 
     31        self.database = database 
    2932                 
    3033        self._connection = pymssql.connect(host=host, user=user,password=password, database=database) 
     
    6164        tempCursor = self._connection.cursor() 
    6265        # 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} ) 
    6476        rs = tempCursor.fetchall() 
    65         tables = [] 
    66         for record in rs: 
    67             tables.append(record[0]) 
     77        tables = [x[0] for x in rs] 
    6878        return tuple(tables) 
    6979 
     
    7181    def getTableRecordCount(self, tableName): 
    7282        tempCursor = self._connection.cursor() 
    73         tempCursor.execute("select count(*) as ncount from %s" % tableName) 
     83        tempCursor.execute("select count(*) as ncount from '%(tablename)'" % tableName) 
    7484        return tempCursor.fetchall()[0][0] 
    7585 
     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 
    76146 
    77147    def getFields(self, tableName): 
     148        """ Returns the list of fields of the passed table 
     149            field: ( fieldname, dabo data type, key ) 
     150            """ 
    78151        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 
    120178        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)) 
    146187        return tuple(fields) 
    147          
    148188 
    149189    #def getUpdateTablePrefix(self, tbl): 
  • branches/paul_sandbox/dabo/icons/__init__.py

    r1632 r2650  
    11import sys 
    22import os 
     3import glob 
    34 
    45defaultExtension = "png" 
     
    3334                break    
    3435    return ret 
     36 
     37 
     38def 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  
    549549        # Standard class template 
    550550        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
    553553        self.Sizer = None 
    554554%(indCode)s 
     
    556556""" 
    557557        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
    560560%s       
    561561 
  • branches/paul_sandbox/dabo/lib/datanav/Form.py

    r2612 r2650  
    146146         
    147147        if self.FormType != 'Edit': 
    148             self.appendToolBarButton("First", "leftArrows", bindfunc=self.onFirst,  
     148            self.appendToolBarButton("First", "leftArrows", OnHit=self.onFirst,  
    149149                    tip=_("First"), help=_("Go to the first record")) 
    150             self.appendToolBarButton("Prior", "leftArrow", bindfunc=self.onPrior,  
     150            self.appendToolBarButton("Prior", "leftArrow", OnHit=self.onPrior,  
    151151                    tip=_("Prior"), help=_("Go to the prior record")) 
    152             self.appendToolBarButton("Requery", "requery", bindfunc=self.onRequery,  
     152            self.appendToolBarButton("Requery", "requery", OnHit=self.onRequery,  
    153153                    tip=_("Requery"), help=_("Requery dataset")) 
    154             self.appendToolBarButton("Next", "rightArrow", bindfunc=self.onNext,  
     154            self.appendToolBarButton("Next", "rightArrow", OnHit=self.onNext,  
    155155                    tip=_("Next"), help=_("Go to the next record")) 
    156             self.appendToolBarButton("Last", "rightArrows", bindfunc=self.onLast,  
     156            self.appendToolBarButton("Last", "rightArrows", OnHit=self.onLast,  
    157157                    tip=_("Last"), help=_("Go to the last record")) 
    158158            tb.appendSeparator() 
    159159 
    160160        if self.FormType == 'Normal': 
    161             self.appendToolBarButton("New", "blank", bindfunc=self.onNew,  
     161            self.appendToolBarButton("New", "blank", OnHit=self.onNew,  
    162162                    tip=_("New"), help=_("Add a new record")) 
    163             self.appendToolBarButton("Delete", "delete", bindfunc=self.onDelete,  
     163            self.appendToolBarButton("Delete", "delete", OnHit=self.onDelete,  
    164164                    tip=_("Delete"), help=_("Delete this record")) 
    165165            tb.appendSeparator() 
    166166 
    167167        if self.FormType != 'PickList': 
    168             self.appendToolBarButton("Save", "save", bindfunc=self.onSave,  
     168            self.appendToolBarButton("Save", "save", OnHit=self.onSave,  
    169169                    tip=_("Save"), help=_("Save changes")) 
    170             self.appendToolBarButton("Cancel", "revert", bindfunc=self.onCancel,  
     170            self.appendToolBarButton("Cancel", "revert", OnHit=self.onCancel,  
    171171                    tip=_("Cancel"), help=_("Cancel changes")) 
    172172            tb.appendSeparator() 
    173173 
    174174        if self.FormType != "Edit": 
    175             self.appendToolBarButton("SQL", "zoomNormal", bindfunc=self.onShowSQL,  
     175            self.appendToolBarButton("SQL", "zoomNormal", OnHit=self.onShowSQL,  
    176176                    tip=_("Show SQL"), help=_("Show the last executed SQL statement")) 
    177177 
    178178        if self.FormType == "Normal": 
    179179            self.appendToolBarButton(_("Quick Report"), "print", 
    180                     bindfunc=self.onQuickReport, tip=_("Quick Report"), 
     180                    OnHit=self.onQuickReport, tip=_("Quick Report"), 
    181181                    help=_("Run a Quick Report on the current dataset")) 
    182182 
     
    187187 
    188188        menu.append(_("Set Selection &Criteria")+"\tAlt+1",  
    189                 bindfunc=self.onSetSelectionCriteria, bmp="checkMark", 
     189                OnHit=self.onSetSelectionCriteria, bmp="checkMark", 
    190190                help=_("Set the selection criteria for the recordset.")) 
    191191 
    192192        menu.append(_("&Browse Records")+"\tAlt+2",  
    193                 bindfunc=self.onBrowseRecords, bmp="browse", 
     193                OnHit=self.onBrowseRecords, bmp="browse", 
    194194                help=_("Browse the records in the current recordset.")) 
    195195 
     
    208208                            index+1) 
    209209 
    210                 menu.append(title, bindfunc=self.onEditCurrentRecord, bmp="edit", 
     210                menu.append(title, OnHit=self.onEditCurrentRecord, bmp="edit", 
    211211                        help=_("Edit the fields of the currently selected record."), 
    212212                        Tag=self.pageFrame.Pages[index].DataSource) 
     
    214214 
    215215        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", 
    217217                    help=_("Get a new recordset from the backend."), menutype="check")       
    218218     
    219219        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", 
    221221                    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", 
    223223                    help=_("Cancel any changes made to the records.")) 
    224224            menu.appendSeparator() 
     
    232232 
    233233            menu.append(_("Select &First Record")+"\t%s+UP" % altKey,  
    234                     bindfunc=self.onFirst, bmp="leftArrows",  
     234                    OnHit=self.onFirst, bmp="leftArrows",  
    235235                    help=_("Go to the first record in the set."))  
    236236            menu.append(_("Select &Prior Record")+"\t%s+LEFT" % altKey,  
    237                     bindfunc=self.onPrior,bmp="leftArrow",  
     237                    OnHit=self.onPrior,bmp="leftArrow",  
    238238                    help=_("Go to the prior record in the set."))    
    239239            menu.append(_("Select Ne&xt Record")+"\t%s+RIGHT" % altKey,  
    240                     bindfunc=self.onNext, bmp="rightArrow",  
     240                    OnHit=self.onNext, bmp="rightArrow",  
    241241                    help=_("Go to the next record in the set.")) 
    242242            menu.append(_("Select &Last Record")+"\t%s+DOWN" % altKey,  
    243                     bindfunc=self.onLast, bmp="rightArrows",  
     243                    OnHit=self.onLast, bmp="rightArrows",  
    244244                    help=_("Go to the last record in the set.")) 
    245245            menu.appendSeparator() 
    246246         
    247247        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", 
    249249                    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", 
    251251                    help=_("Delete the current record from the dataset.")) 
    252252            menu.appendSeparator() 
    253253 
    254254        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") 
    256256 
    257257        if self.FormType == "Normal": 
    258             menu.append(_("Quick &Report"), bindfunc=self.onQuickReport, bmp="print", 
     258            menu.append(_("Quick &Report"), OnHit=self.onQuickReport, bmp="print", 
    259259                    DynamicEnabled=self.enableQuickReport) 
    260260 
  • branches/paul_sandbox/dabo/lib/datanav/Grid.py

    r2539 r2650  
    164164        try: 
    165165            if self.Form.FormType == 'PickList': 
    166                 menu.append(_("&Pick"), bindfunc=self.pickRecord, bmp="edit", 
     166                menu.append(_("&Pick"), OnHit=self.pickRecord, bmp="edit", 
    167167                        help=_("Pick this record")) 
    168168            else: 
    169                 menu.append(_("&New"), bindfunc=self.newRecord, bmp="blank", 
     169                menu.append(_("&New"), OnHit=self.newRecord, bmp="blank", 
    170170                        help=_("Add a new record")) 
    171                 menu.append("&Edit", bindfunc=self.editRecord, bmp="edit", 
     171                menu.append("&Edit", OnHit=self.editRecord, bmp="edit", 
    172172                        help=_("Edit this record")) 
    173                 menu.append("&Delete", bindfunc=self.deleteRecord, bmp="delete", 
     173                menu.append("&Delete", OnHit=self.deleteRecord, bmp="delete", 
    174174                        help=_("Delete this record")) 
    175175            return menu 
  • branches/paul_sandbox/dabo/lib/datanav/Page.py

    r2623 r2650  
    143143        mn = dabo.ui.dMenu() 
    144144        if self.sortFields: 
    145             mn.append(_("Show sort order"), bindfunc=self.handleSortOrder) 
     145            mn.append(_("Show sort order"), OnHit=self.handleSortOrder) 
    146146        if self.sortFields.has_key(self.sortDS): 
    147147            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) 
    152152        self.PopupMenu(mn, obj.formCoordinates(evt.EventData["mousePosition"]) ) 
    153153        mn.release() 
  • branches/paul_sandbox/dabo/lib/propertyHelperMixin.py

    r2572 r2650  
    44 
    55class PropertyHelperMixin(object): 
    6     """ Helper functions for getting information on class properties. 
    7     """ 
     6    """ Helper functions for getting information on class properties.""" 
    87 
    98    def _expandPropStringValue(self, value, propList): 
     
    6160                del kwdict[arg] 
    6261        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 
    6378     
    6479     
     
    223238                        raise ValueError, "Could not set property '%s' to value: %s" % (prop, val) 
    224239         
    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         
    226251    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).""" 
    229253        try: 
    230254            propLists = cls._propLists 
     
    261285 
    262286    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.""" 
    265288        # cls can be either a class or self 
    266289        classRef = cls 
     
    311334    getPropertyInfo = classmethod(getPropertyInfo) 
    312335     
     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  
    384384        ed["hasModifiers"] = wxEvt.HasModifiers() 
    385385        try: 
    386             if wx.Platform == "__WXMAC__"
     386            if wx.Platform in ("__WXMAC__", "__WXGTK__")
    387387                ed["keyChar"] = chr(wxEvt.GetKeyCode()) 
    388388            else:    
     
    644644        return None 
    645645    try: 
    646         prnt = self.Application.ActiveForm 
     646        prnt = dabo.dAppRef.ActiveForm 
    647647    except: 
    648648        prnt = None 
     
    839839 
    840840 
    841 def createForm(srcFile, show=False): 
     841def createForm(srcFile, show=False, *args, **kwargs): 
    842842    """Pass in a .cdxml file from the Designer, and this will 
    843843    instantiate a form from that spec. Returns a reference 
     
    847847    conv = DesignerXmlConverter() 
    848848    cls = conv.classFromXml(srcFile) 
    849     frm = cls(
     849    frm = cls(*args, **kwargs
    850850    if show: 
    851851        frm.show() 
     
    866866    """ 
    867867    def addMenu(mb, menuDict, form, previewFunc): 
     868        if form is None: 
     869            form = dabo.dAppRef.ActiveForm 
    868870        menu = dabo.ui.dMenu(mb) 
    869871        atts = menuDict["attributes"] 
     
    885887                cap = itmatts["Caption"] 
    886888                hk = itmatts["HotKey"] 
     889                pic = itmatts["Picture"] 
    887890                if hk: 
    888891                    cap += "\t%s" % hk 
     
    890893                binding = previewFunc 
    891894                fnc = "" 
    892                 useFunc = ("Function" in itmatts) and (itmatts["Function"]) 
     895                useFunc = ("Action" in itmatts) and (itmatts["Action"]) 
    893896                if useFunc: 
    894                     fnc = itmatts["Function"] 
     897                    fnc = itmatts["Action"] 
    895898                if (binding is None) and fnc: 
    896899                    binding = eval(fnc) 
    897900                help = itmatts["HelpText"] 
    898                 menuItem = menu.append(cap, bindfunc=binding, help=help)    
    899                 menuItem._bindingText = fnc 
     901                menuItem = menu.append(cap, OnHit=binding, help=help, 
     902                       picture=pic)     
    900903     
    901904    mnd = dabo.lib.xmltodict.xmltodict(srcFile) 
  • branches/paul_sandbox/dabo/ui/uiwx/dBaseMenuBar.py

    r2517 r2650  
    3131 
    3232        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,  
    3434                    help=_("Open up a command window for debugging") ) 
    3535         
    3636        prmpt = _("Close Windo&w") + "\tCtrl+W" 
    37         self.append(prmpt, bindfunc=app.onWinClose, bmp="close", 
     37        self.append(prmpt, OnHit=app.onWinClose, bmp="close", 
    3838                help=_("Close the current window") ) 
    3939 
     
    4343#       if wx.Platform == '__WXWIN__': 
    4444#           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,  
    4646                bmp="exit", help=_("Exit the application") ) 
    4747 
     
    5454        self.Caption = _("&Edit") 
    5555 
    56         self.append(_("&Undo") + "\tCtrl+Z", bindfunc=app.onEditUndo, bmp="undo", 
     56        self.append(_("&Undo") + "\tCtrl+Z", OnHit=app.onEditUndo, bmp="undo", 
    5757                help=_("Undo last action") ) 
    5858 
    59         self.append(_("&Redo") + "\tCtrl+R", bindfunc=app.onEditRedo, bmp="redo", 
     59        self.append(_("&Redo") + "\tCtrl+R", OnHit=app.onEditRedo, bmp="redo", 
    6060                help=_("Undo last undo") ) 
    6161 
    6262        self.appendSeparator() 
    6363 
    64         self.append(_("Cu&t") + "\tCtrl+X", bindfunc=app.onEditCut, bmp="cut", 
     64        self.append(_("Cu&t") + "\tCtrl+X", OnHit=app.onEditCut, bmp="cut", 
    6565                help=_("Cut selected text") ) 
    6666 
    67         self.append(_("&Copy") + "\tCtrl+C", bindfunc=app.onEditCopy, bmp="copy", 
     67        self.append(_("&Copy") + "\tCtrl+C", OnHit=app.onEditCopy, bmp="copy", 
    6868                help=_("Copy selected text") ) 
    6969 
    70         self.append(_("&Paste") + "\tCtrl+V", bindfunc=app.onEditPaste, bmp="paste", 
     70        self.append(_("&Paste") + "\tCtrl+V", OnHit=app.onEditPaste, bmp="paste", 
    7171                help=_("Paste text from clipboard") ) 
    7272 
    73         self.append(_("Select &All") + "\tCtrl+A", bindfunc=app.onEditSelectAll, 
     73        self.append(_("Select &All") + "\tCtrl+A", OnHit=app.onEditSelectAll, 
    7474                help=_("Select all text") ) 
    7575 
     
    7878        # By default, the Find and Replace functions use a single dialog. The 
    7979        # 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,  
    8181                bmp="find", help=_("Find text in the active window") ) 
    8282 
    83 #       self.append(_("Find") + "\tShift+Ctrl+F", bindfunc=app.onEditFindAlone,  
     83#       self.append(_("Find") + "\tShift+Ctrl+F", OnHit=app.onEditFindAlone,  
    8484#               bmp="find", help=_("Find text in the active window") ) 
    8585 
    86         self.append(_("Find A&gain") + "\tCtrl+G", bindfunc=app.onEditFindAgain, bmp="", 
     86        self.append(_("Find A&gain") + "\tCtrl+G", OnHit=app.onEditFindAgain, bmp="", 
    8787                help=_("Repeat the last search") ) 
    8888 
    8989        self.appendSeparator() 
    9090 
    91         itm = self.append(_("&Preferences"), bindfunc=app.onEditPreferences, bmp="configure", 
     91        itm = self.append(_("&Preferences"), OnHit=app.onEditPreferences, bmp="configure", 
    9292                help=_("Set user preferences") ) 
    9393        # Put the prefs item in the App Menu on Mac 
     
    103103         
    104104        itm = self.append(_("Show/Hide Sizer &Lines")+"\tCtrl+L",    
    105                 bindfunc=app.onShowSizerLines, menutype="check", 
     105                OnHit=app.onShowSizerLines, menutype="check", 
    106106                help=_("Cool sizer visualizing feature; check it out!")) 
    107107 
     
    114114 
    115115        itm = self.append(_("&About"), id=wx.ID_ABOUT,  
    116                 bindfunc=app.onHelpAbout, bmp="apply", 
     116                OnHit=app.onHelpAbout, bmp="apply", 
    117117                help=_("About this application") ) 
    118118        # Put the about menu in the App Menu on Mac 
  • branches/paul_sandbox/dabo/ui/uiwx/dDateTextBox.py

    r2240 r2650  
    169169        menu = dabo.ui.dMenu() 
    170170        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) 
    172172            format["id"] = itm.GetId() 
    173173        self.showContextMenu(menu) 
  • branches/paul_sandbox/dabo/ui/uiwx/dEditor.py

    r2612 r2650  
    292292        with their starting positions in the text. 
    293293        """ 
     294        pat = re.compile(r"^([ \t]*(?:def )|(?:class ))([^\(]+)\(", re.M) 
    294295        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</