Changeset 2748
- Timestamp:
- 01/24/07 15:38:20 (2 years ago)
- Files:
-
- branches/carl2/AUTHORS (modified) (1 diff)
- branches/carl2/ChangeLog (modified) (2 diffs)
- branches/carl2/dabo/LICENSE.TXT (modified) (1 diff)
- branches/carl2/dabo/biz/dAutoBizobj.py (modified) (1 diff)
- branches/carl2/dabo/biz/dBizobj.py (modified) (3 diffs)
- branches/carl2/dabo/biz/test/test_dBizobj.py (modified) (1 diff)
- branches/carl2/dabo/db/dBackend.py (modified) (1 diff)
- branches/carl2/dabo/db/dbFirebird.py (modified) (1 diff)
- branches/carl2/dabo/db/dbPostgreSQL.py (modified) (6 diffs)
- branches/carl2/dabo/db/test/test_dCursorMixin.py (modified) (20 diffs)
- branches/carl2/dabo/lib/DesignerXmlConverter.py (modified) (1 diff)
- branches/carl2/dabo/lib/EasyDialogBuilder.py (modified) (8 diffs)
- branches/carl2/dabo/lib/datanav/__init__.py (modified) (2 diffs)
- branches/carl2/dabo/lib/datanav2 (copied) (copied from trunk/dabo/lib/datanav2)
- branches/carl2/dabo/lib/datanav2/Bizobj.py (copied) (copied from trunk/dabo/lib/datanav2/Bizobj.py)
- branches/carl2/dabo/lib/datanav2/Form.py (copied) (copied from trunk/dabo/lib/datanav2/Form.py)
- branches/carl2/dabo/lib/datanav2/Grid.py (copied) (copied from trunk/dabo/lib/datanav2/Grid.py)
- branches/carl2/dabo/lib/datanav2/Page.py (copied) (copied from trunk/dabo/lib/datanav2/Page.py)
- branches/carl2/dabo/lib/datanav2/PageFrame.py (copied) (copied from trunk/dabo/lib/datanav2/PageFrame.py)
- branches/carl2/dabo/lib/datanav2/__init__.py (copied) (copied from trunk/dabo/lib/datanav2/__init__.py)
- branches/carl2/dabo/ui/uiwx/dDialog.py (modified) (1 diff)
- branches/carl2/dabo/ui/uiwx/dEditor.py (modified) (1 diff)
- branches/carl2/dabo/ui/uiwx/dFormMain.py (modified) (1 diff)
- branches/carl2/dabo/ui/uiwx/dFormMixin.py (modified) (2 diffs)
- branches/carl2/dabo/ui/uiwx/dGrid.py (modified) (4 diffs)
- branches/carl2/dabo/ui/uiwx/dMenu.py (modified) (2 diffs)
- branches/carl2/dabo/ui/uiwx/dPageFrameMixin.py (modified) (1 diff)
- branches/carl2/dabo/ui/uiwx/dRadioList.py (modified) (1 diff)
- branches/carl2/dabo/ui/uiwx/dShell.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/carl2/AUTHORS
r2713 r2748 14 14 Nate Lowrie 15 15 Uwe Grauer 16 Simen Haugen 16 17 17 18 branches/carl2/ChangeLog
r2684 r2748 2 2 3 3 =============================================================================== 4 Dabo 0.7.2 (2007-01-1 5) (Revision 2683):4 Dabo 0.7.2 (2007-01-18) (Revision 2716): 5 5 6 6 Additions, all minor, backported to stable only to keep compatibility with the … … 13 13 + Fixed the stable branch to work with wxPython 2.7 and 2.8, which was a fairly 14 14 large backport of relevant changes from the development trunk. 15 + Fixed a form activation problem that would happen in some cases on Windows, 16 particularly with the Class Designer. 15 17 + Fixed incremental search in dGrid, which was broken by earlier unicode fixes. 16 18 + dBizobj.onSaveNew() user hook never being called. Fixed. branches/carl2/dabo/LICENSE.TXT
r2205 r2748 1 1 Dabo: 3-tier desktop application runtime framework 2 Copyright (c) 2004-200 6Ed Leafe, Paul McNett, et. al.2 Copyright (c) 2004-2007 Ed Leafe, Paul McNett, et. al. 3 3 4 4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: branches/carl2/dabo/biz/dAutoBizobj.py
r2412 r2748 169 169 f.write("%s;\n" % (query)) 170 170 171 f.close 171 f.close() 172 172 173 173 class dAutoBizobj(dBizobj): branches/carl2/dabo/biz/dBizobj.py
r2713 r2748 258 258 useTransact = startTransaction or topLevel 259 259 cursor = self._CurrentCursor 260 old_pk = cursor.getPK()260 current_row = self.RowNumber 261 261 262 262 if useTransact: … … 288 288 cursor.commitTransaction() 289 289 290 if old_pk is not None: 291 self._moveToPK(old_pk) 290 self.RowNumber = current_row 292 291 293 292 … … 878 877 def isAnyChanged(self, _topLevel=True): 879 878 """Returns True if any record in the current record set has been changed.""" 880 879 try: 880 cc = self._CurrentCursor 881 except: 882 cc = None 883 if cc is None: 884 # No cursor, no changes. 885 return False 881 886 if _topLevel: 882 887 # Only check the _CurrentCursor: branches/carl2/dabo/biz/test/test_dBizobj.py
r2713 r2748 297 297 bizMain.new() 298 298 self.assertEqual(bizMain.RowCount, 4) 299 self.assertEqual(bizMain.RowNumber, 3) 299 300 bizMain.saveAll() 300 301 self.assertEqual(bizMain.RowCount, 4) 302 self.assertEqual(bizMain.RowNumber, 3) 301 303 bizMain.requery() 302 304 self.assertEqual(bizMain.RowCount, 4) 305 self.assertEqual(bizMain.RowNumber, 3) 303 306 304 307 branches/carl2/dabo/db/dBackend.py
r2712 r2748 209 209 self._autoCommit = val 210 210 else: 211 # Without an autocommit method, assume 212 # no autocommit. 211 # Without an autocommit method, assume no autocommit. 213 212 self._autoCommit = False 213 if val: 214 raise ValueError, "Can't set AutoCommit to True for this backend." 214 215 215 216 branches/carl2/dabo/db/dbFirebird.py
r2713 r2748 95 95 whereClause = '' 96 96 else: 97 whereClause = "where rdb$relation_name not like 'RDB$%' "97 whereClause = "where rdb$relation_name not starting with 'RDB$' " 98 98 99 99 tempCursor = self._connection.cursor() branches/carl2/dabo/db/dbPostgreSQL.py
r2672 r2748 13 13 self.dbModuleName = "psycopg" 14 14 self.useTransactions = True # this does not appear to be required 15 self.conn_user = '' 15 16 16 17 … … 18 19 import psycopg2 as dbapi 19 20 #from pyPgSQL import PgSQL as dbapi 20 21 self.conn_user = connectInfo.User 21 22 #- jfcs 11/01/04 port needs to be a string 22 23 port = str(connectInfo.Port) … … 53 54 tempCursor = self._connection.cursor() 54 55 # jfcs 11/01/04 assumed public schema 55 tempCursor.execute("select tablename from pg_tables where schemaname = 'public'") 56 #tempCursor.execute("select tablename from pg_tables where schemaname = 'public'") 57 # jfcs 01/22/07 added below to support schema 58 # thanks to Phillip J. Allen who provided a Select state that filtered for the user name 59 if includeSystemTables: 60 sqltablestr = (("SELECT schemaname || '.' || tablename AS tablename FROM pg_tables WHERE has_table_privilege('%s', schemaname || '.' || tablename, 'SELECT')") % self.conn_user) 61 62 else: 63 sqltablestr = (("SELECT schemaname || '.' || tablename AS tablename FROM pg_tables WHERE (schemaname not like 'pg_%s' and schemaname not like 'information%s') and has_table_privilege('%s', schemaname || '.' || tablename, 'SELECT')") % ('%','%',self.conn_user)) 64 65 tempCursor.execute(sqltablestr) 56 66 rs = tempCursor.fetchall() 67 68 57 69 tables = [] 58 70 for record in rs: … … 76 88 # make sure you uncomment the other code out 77 89 90 # jfcs 01/22/07 actually I'm not sure Dabo is still able to support 7.1 - 7.4 91 # should you attempt to Dabo with 7.4 or below please let us know. 92 78 93 #tempCursor.execute("select c.column_name as fielname, c.data_type as fieldtyp, \ 79 94 #i.indisprimary AS is_pkey \ … … 85 100 #rs=tempCursor.fetchall() 86 101 87 # jfcs 11/01/04 Below sucks but works with 7.3.x and 7.4.x (don't know anything 88 # about 8.0.x) 102 89 103 # Ok get the 'field name', 'field type' 90 tempCursor.execute("""select c.oid,a.attname, t.typname 91 from pg_class c inner join pg_attribute a 92 on a.attrelid = c.oid inner join pg_type t on a.atttypid = t.oid 93 where c.relname = '%s' and a.attnum > 0 """ % tableName) 104 #tempCursor.execute("""select c.oid,a.attname, t.typname 105 #from pg_class c inner join pg_attribute a 106 #on a.attrelid = c.oid inner join pg_type t on a.atttypid = t.oid 107 #where c.relname = '%s' and a.attnum > 0 """ % tableName) 108 # JFCS 01/22/07 Added support for schema 109 tempCursor.execute("""select c.oid,a.attname, t.typname, b.schemaname from pg_class c 110 inner join pg_attribute a on a.attrelid = c.oid 111 inner join pg_type t on a.atttypid = t.oid 112 inner join pg_tables b on b.tablename=c.relname 113 where (b.schemaname || '.'|| c.relname) = '%s' and a.attnum > 0 """ % tableName) 94 114 rs = tempCursor.fetchall() 95 115 myoid=rs[0][0] … … 125 145 elif "numeric" in fldType: 126 146 fldType = "N" 147 elif "double" in fldType: 148 fldType = "F" 149 elif "real" in fldType: 150 fldType = "F" 151 elif "float" in fldType: 152 fldType = "F" 127 153 elif "datetime" in fldType: 128 154 fldType = "T" branches/carl2/dabo/db/test/test_dCursorMixin.py
r2713 r2748 25 25 26 26 class Test_dCursorMixin(object): 27 def setUp(self ):27 def setUp(self, _doRequery=True): 28 28 cur = self.cur 29 29 self.createSchema() … … 31 31 cur.KeyField = "pk" 32 32 cur.Table = self.temp_table_name 33 cur.requery() 33 if _doRequery: 34 cur.requery() 34 35 35 36 def tearDown(self): … … 40 41 cur = self.cur 41 42 43 def getAdditionalWhere(self): 44 return "" 42 45 43 46 ## - Begin property unit tests - … … 45 48 cur = self.cur 46 49 self.assertEqual(cur.AutoCommit, False) 47 cur.AutoCommit = True 48 self.assertEqual(cur.AutoCommit, True) 50 try: 51 cur.AutoCommit = True 52 self.assertEqual(cur.AutoCommit, True) 53 except ValueError: 54 # Okay; this db didn't allow the setting of AutoCommit. 55 self.assertEqual(cur.AutoCommit, False) 49 56 50 57 def test_AutoSQL(self): … … 74 81 self.assertTrue(ds[0] == ("pk", "I", True, self.temp_table_name, "pk", None) 75 82 or ds[0] == ("pk", "G", True, self.temp_table_name, "pk", None)) 76 self.assertEqual(ds[1], ("c Field", "C", False, self.temp_table_name, "cField", None))77 self.assertTrue(ds[2] == ("i Field", "I", False, self.temp_table_name, "iField", None)78 or ds[2] == ("i Field", "G", False, self.temp_table_name, "iField", None))79 self.assertEqual(ds[3], ("n Field", "N", False, self.temp_table_name, "nField", None))83 self.assertEqual(ds[1], ("cfield", "C", False, self.temp_table_name, "cfield", None)) 84 self.assertTrue(ds[2] == ("ifield", "I", False, self.temp_table_name, "ifield", None) 85 or ds[2] == ("ifield", "G", False, self.temp_table_name, "ifield", None)) 86 self.assertEqual(ds[3], ("nfield", "N", False, self.temp_table_name, "nfield", None)) 80 87 81 88 def test_Encoding(self): … … 91 98 cur = self.cur 92 99 self.assertEqual(cur.FieldDescription[0][0], "pk") 93 self.assertEqual(cur.FieldDescription[1][0], "c Field")94 self.assertEqual(cur.FieldDescription[2][0], "i Field")95 self.assertEqual(cur.FieldDescription[3][0], "n Field")100 self.assertEqual(cur.FieldDescription[1][0], "cfield") 101 self.assertEqual(cur.FieldDescription[2][0], "ifield") 102 self.assertEqual(cur.FieldDescription[3][0], "nfield") 96 103 97 104 def test_IsAdding(self): … … 107 114 def test_LastSQL(self): 108 115 cur = self.cur 109 self.assertEqual(cur.LastSQL, cur.UserSQL) 116 current_sql = cur.UserSQL 117 cur.UserSQL = "select blah from temp" 118 self.assertEqual(cur.UserSQL, "select blah from temp") 119 self.assertEqual(cur.LastSQL, current_sql) 110 120 111 121 def test_KeyField(self): … … 115 125 def test_Record(self): 116 126 cur = self.cur 117 self.assertEqual(cur.Record.c Field, "Paul Keith McNett")118 cur.Record.c Field = "Denise McNett"119 self.assertEqual(cur.Record.c Field, "Denise McNett")120 self.assertEqual(cur._mementos[cur.Record.pk]["c Field"], "Paul Keith McNett")121 cur.Record.c Field = "Alison Anton"122 self.assertEqual(cur.Record.c Field, "Alison Anton")123 self.assertEqual(cur._mementos[cur.Record.pk]["c Field"], "Paul Keith McNett")124 cur.setFieldVal("i Field", 80)125 self.assertEqual(cur.Record.i Field, 80)126 self.assertTrue(isinstance(cur.Record.i Field, (int, long)))127 self.assertEqual(cur._mementos[self.cur.Record.pk]["i Field"], 23)127 self.assertEqual(cur.Record.cfield.rstrip(), "Paul Keith McNett") 128 cur.Record.cfield = "Denise McNett" 129 self.assertEqual(cur.Record.cfield, "Denise McNett") 130 self.assertEqual(cur._mementos[cur.Record.pk]["cfield"].rstrip(), "Paul Keith McNett") 131 cur.Record.cfield = "Alison Anton" 132 self.assertEqual(cur.Record.cfield, "Alison Anton") 133 self.assertEqual(cur._mementos[cur.Record.pk]["cfield"].rstrip(), "Paul Keith McNett") 134 cur.setFieldVal("ifield", 80) 135 self.assertEqual(cur.Record.ifield, 80) 136 self.assertTrue(isinstance(cur.Record.ifield, (int, long))) 137 self.assertEqual(cur._mementos[self.cur.Record.pk]["ifield"], 23) 128 138 129 139 # Querying or setting a field that doesn't exist should raise … … 162 172 def test_UserSQL(self): 163 173 cur = self.cur 164 testSQL = "select * from %s where nField = 23.23" % self.temp_table_name 174 testSQL = "select * from %s where nfield = 23.23" % self.temp_table_name 175 addWhere = self.getAdditionalWhere() 176 if addWhere: 177 testSQL += " AND %s" % addWhere 165 178 cur.UserSQL = testSQL 166 179 cur.requery() … … 169 182 self.assertEqual(cur.RowCount, 1) 170 183 self.assertEqual(cur.RowNumber, 0) 171 self.assertEqual(cur.Record.c Field, "Paul Keith McNett")184 self.assertEqual(cur.Record.cfield.rstrip(), "Paul Keith McNett") 172 185 173 186 ## - End property unit tests - … … 180 193 self.assertEqual(cur._newRecords, {}) 181 194 182 priorVal = cur.Record.c Field195 priorVal = cur.Record.cfield 183 196 # Make a change that is the same as the prior value: 184 cur.Record.c Field = priorVal185 self.assertEqual(priorVal, cur.Record.c Field)197 cur.Record.cfield = priorVal 198 self.assertEqual(priorVal, cur.Record.cfield) 186 199 self.assertEqual(cur._mementos, {}) 187 200 self.assertEqual(cur._newRecords, {}) 188 201 189 202 # Make a change that is different: 190 cur.Record.c Field = "New test value"191 self.assertEqual(cur._mementos, {cur.Record.pk: {"c Field": priorVal}})203 cur.Record.cfield = "New test value" 204 self.assertEqual(cur._mementos, {cur.Record.pk: {"cfield": priorVal}}) 192 205 self.assertEqual(cur.isChanged(), True) 193 206 self.assertEqual(cur.isChanged(allRows=False), True) 194 207 195 208 # Change it back: 196 cur.Record.c Field = priorVal209 cur.Record.cfield = priorVal 197 210 self.assertEqual(cur._mementos, {}) 198 211 self.assertEqual(cur.isChanged(), False) … … 200 213 201 214 # Make a change that is different and cancel: 202 cur.Record.c Field = "New test value"215 cur.Record.cfield = "New test value" 203 216 cur.cancel() 204 217 self.assertEqual(cur._mementos, {}) … … 219 232 self.assertEqual(cur.isChanged(allRows=False), True) 220 233 self.assertEqual(cur.Record.pk, "-1-dabotmp") 221 self.assertEqual(cur.Record.c Field, "")222 self.assertEqual(cur.Record.i Field, 0)223 self.assertEqual(cur.Record.n Field, 0)234 self.assertEqual(cur.Record.cfield, "") 235 self.assertEqual(cur.Record.ifield, 0) 236 self.assertEqual(cur.Record.nfield, 0) 224 237 cur.save() 225 238 cur.requery() … … 232 245 233 246 # The new fields should be NULL, since we didn't explicitly set them: 234 self.assertEqual(cur.Record.c Field, None)235 self.assertEqual(cur.Record.i Field, None)236 self.assertEqual(cur.Record.n Field, None)247 self.assertEqual(cur.Record.cfield, None) 248 self.assertEqual(cur.Record.ifield, None) 249 self.assertEqual(cur.Record.nfield, None) 237 250 238 251 … … 248 261 tableName = self.temp_table_name 249 262 cur.executescript(""" 250 create table %s (pk INTEGER PRIMARY KEY AUTOINCREMENT, c Field CHAR, iField INT, nField DECIMAL (8,2));251 insert into %s (c Field, iField, nField) values ("Paul Keith McNett", 23, 23.23);252 insert into %s (c Field, iField, nField) values ("Edward Leafe", 42, 42.42);253 insert into %s (c Field, iField, nField) values ("Carl Karsten", 10223, 23032.76);263 create table %s (pk INTEGER PRIMARY KEY AUTOINCREMENT, cfield CHAR, ifield INT, nfield DECIMAL (8,2)); 264 insert into %s (cfield, ifield, nfield) values ("Paul Keith McNett", 23, 23.23); 265 insert into %s (cfield, ifield, nfield) values ("Edward Leafe", 42, 42.42); 266 insert into %s (cfield, ifield, nfield) values ("Carl Karsten", 10223, 23032.76); 254 267 """ % (tableName, tableName, tableName, tableName, )) 255 268 … … 271 284 cur = self.cur 272 285 cur.execute(""" 273 create table %s (pk INTEGER PRIMARY KEY AUTO_INCREMENT, c Field CHAR (32), iField INT, nField DECIMAL (8,2))286 create table %s (pk INTEGER PRIMARY KEY AUTO_INCREMENT, cfield CHAR (32), ifield INT, nfield DECIMAL (8,2)) 274 287 """ % self.temp_table_name) 275 288 cur.execute(""" 276 insert into %s (c Field, iField, nField) values ("Paul Keith McNett", 23, 23.23)289 insert into %s (cfield, ifield, nfield) values ("Paul Keith McNett", 23, 23.23) 277 290 """ % self.temp_table_name) 278 291 cur.execute(""" 279 insert into %s (c Field, iField, nField) values ("Edward Leafe", 42, 42.42)292 insert into %s (cfield, ifield, nfield) values ("Edward Leafe", 42, 42.42) 280 293 """ % self.temp_table_name) 281 294 cur.execute(""" 282 insert into %s (c Field, iField, nField) values ("Carl Karsten", 10223, 23032.76)295 insert into %s (cfield, ifield, nfield) values ("Carl Karsten", 10223, 23032.76) 283 296 """ % self.temp_table_name) 284 297 … … 293 306 password="Y57W8EN6CB06KBCCDCX01D6B", Database="dabo_unittest", 294 307 Host="dabodev.com") 295 self.cur = con.getDaboCursor()308 cur = self.cur = con.getDaboCursor() 296 309 self.temp_table_name = "dabo_unittest_tbl" 297 310 self.jobid = self.get_jobid() 298 super(Test_dCursorMixin_firebird, self).setUp() 311 super(Test_dCursorMixin_firebird, self).setUp(_doRequery=False) 312 cur.UserSQL = "select * from %s where jobid = %s" % (self.temp_table_name, self.jobid) 313 cur.requery() 299 314 300 315 def get_jobid(self): … … 310 325 super(Test_dCursorMixin_firebird, self).tearDown() 311 326 327 def getAdditionalWhere(self): 328 return "jobid = %f" % self.jobid 329 312 330 def createSchema(self): 313 331 cur = self.cur … … 316 334 cur.execute("commit") 317 335 cur.execute(""" 318 insert into %s (jobid, c Field, iField, nField) values (%f, 'Paul Keith McNett', 23, 23.23)336 insert into %s (jobid, cfield, ifield, nfield) values (%f, 'Paul Keith McNett', 23, 23.23) 319 337 """ % (tableName, self.jobid)) 320 338 cur.execute(""" 321 insert into %s (jobid, c Field, iField, nField) values (%f, 'Edward Leafe', 42, 42.42)339 insert into %s (jobid, cfield, ifield, nfield) values (%f, 'Edward Leafe', 42, 42.42) 322 340 """ % (tableName, self.jobid)) 323 341 cur.execute(""" 324 insert into %s (jobid, c Field, iField, nField) values (%f, 'Carl Karsten', 10223, 23032.76)342 insert into %s (jobid, cfield, ifield, nfield) values (%f, 'Carl Karsten', 10223, 23032.76) 325 343 """ % (tableName, self.jobid)) 326 344 cur.execute("commit") … … 328 346 def test_AutoSQL(self): 329 347 cur = self.cur 330 self.assertEqual(cur.AutoSQL, " select first 1000 skip 0 *\n from %s"348 self.assertEqual(cur.AutoSQL, "SELECT \n first 1000\n*\n from %s\n\n\n" 331 349 % self.temp_table_name) 350 332 351 333 352 if __name__ == "__main__": branches/carl2/dabo/lib/DesignerXmlConverter.py
r2618 r2748 145 145 for prop, propDef in propDefs.items(): 146 146 val = propDef["defaultValue"] 147 if not val: 148 continue 147 149 if propDef["defaultType"] == "string": 148 150 val = "\"" + val + "\"" branches/carl2/dabo/lib/EasyDialogBuilder.py
r2713 r2748 36 36 page["imgKey"]=str(pageFrame.PageCount) 37 37 pageFrame.addImage(page["image"], imgKey=page["imgKey"]) 38 elif not page.get("caption"): 39 caption = "Page%i" % (pageFrame.PageCount,) 38 40 39 41 pageFrame.appendPage(pgCls=page.get("page"), caption=page.get("caption"), imgKey=page.get("imgKey")) … … 41 43 return pageFrame 42 44 43 def makeControlBox(self, parent, caption, controlFields, border=5, spacing=5 ):44 """makeControlBox(parent, controlFields, border=5, spacing=5 ) -> dabo.ui.dBorderSizer45 def makeControlBox(self, parent, caption, controlFields, border=5, spacing=5, grid=True): 46 """makeControlBox(parent, controlFields, border=5, spacing=5, grid=True) -> dabo.ui.dBorderSizer 45 47 46 48 parent -> dabo object that is the parent of the controls, normally a panel or form 49 grid -> Boolean. When true all objects are put into a grid sizer for even controlfield alignment. 50 When false, all objects are put into boxSizers so the control fields line up with the end 51 of their labels. 47 52 controlFields -> Tuple of tuples in form of: 48 53 ((control, RegID, label Title, Properties),.....) … … 63 68 box.DefaultBorderAll = True 64 69 65 for obj in controlFields: 66 if len(obj)==4 and isinstance(obj[3], types.DictionaryType): 67 Properties = obj[3] 68 else: 69 Properties = {} 70 bs = self.makeControlField(parent, obj[0], obj[1], obj[2], Properties) 71 72 if obj[0] is dabo.ui.dEditBox: 73 box.append(bs, "expand", 1) 74 else: 75 box.append(bs, "expand") 70 box.append1x(self.makeControlSizer(parent, controlFields, grid=grid)) 76 71 77 72 return box 78 73 79 def makeControlSizer(self, parent, controlFields, border=5, spacing=5 ):80 """makeControlSizer(parent, controlFields, border=5, spacing=5 ) -> dabo.ui.dSizer74 def makeControlSizer(self, parent, controlFields, border=5, spacing=5, grid=True): 75 """makeControlSizer(parent, controlFields, border=5, spacing=5, grid=True) -> dabo.ui.dSizer 81 76 82 77 parent -> dabo object that is the parent of the controls, normally a panel or form 78 grid -> Boolean. When true all objects are put into a grid sizer for even controlfield alignment. 79 When false, all objects are put into boxSizers so the control fields line up with the end 80 of their labels. 83 81 controlFields -> Tuple of tuples in form of: 84 82 ((control, RegID, label Title, Properties),.....) … … 92 90 "format" = string will cause the control to only allow the user to select that file type 93 91 """ 94 vs = dabo.ui.dSizer("vertical") 95 vs.DefaultSpacing = spacing 96 vs.DefaultBorder = border 97 vs.DefaultBorderAll = True 92 if grid: 93 Sizer = dabo.ui.dGridSizer(MaxCols=3) 94 Sizer.setColExpand(True, 1) 95 else: 96 Sizer = dabo.ui.dSizer("vertical") 97 98 Sizer.DefaultSpacing = spacing 99 Sizer.DefaultBorder = border 100 Sizer.DefaultBorderAll = True 98 101 99 102 for obj in controlFields: … … 102 105 else: 103 106 Properties = {} 104 bs = self.makeControlField(parent, obj[0], obj[1], obj[2], Properties) 105 106 if obj[0] is dabo.ui.dEditBox: 107 vs.append(bs, "expand", 1) 108 else: 109 vs.append(bs, "expand") 110 111 return vs 112 113 def makeControlField(self, parent, control, regId, labelTitle, Properties): 114 """makeControlField(parent, control, regId, labelTitle, Properties) -> dabo.ui.dSizer 107 108 controls = self.makeControlField(parent, obj[0], obj[1], obj[2], Properties) 109 110 if grid: 111 lbl = Sizer.append(controls[0], halign="right") 112 if len(controls) > 2: 113 Sizer.append(controls[1], "expand") 114 Sizer.append(controls[2]) 115 else: 116 szItem = Sizer.append(controls[1], "expand", colSpan=2) 117 118 if obj[0] is dabo.ui.dEditBox: 119 Sizer.setRowExpand(True, Sizer.getGridPos(szItem)[0]) 120 Sizer.setItemProp(lbl, "valign", "top") 121 else: 122 bs = dabo.ui.dSizer("h") 123 bs.append(controls[0], halign="right") 124 bs.append(controls[1], "expand",1) 125 126 if len(controls) > 2: 127 bs.append(controls[2]) 128 129 if obj[0] is dabo.ui.dEditBox: 130 Sizer.append(bs, "expand", 1) 131 else: 132 Sizer.append(bs, "expand") 133 134 return Sizer 135 136 def makeControlField(self, parent, control, regId, labelTitle, Properties, Sizer=None): 137 """makeControlField(parent, control, regId, labelTitle, Properties) -> List of Dabo Controls 115 138 116 139 parent -> dabo object that is parent, normally a panel or form … … 119 142 labelTitle -> string that is the title of the label next to the control 120 143 Properties -> dictionary of any properties that are supposed to go with the control 121 """ 122 bs = dabo.ui.dSizer("horizontal") 144 Sizer -> Optional Sizer object. Used so we can insert objects directly into Grid Sizers 145 """ 146 147 if not Sizer: 148 Sizer = dabo.ui.dSizer("horizontal") 149 150 controlList = [] 123 151 124 152 if control == "File": … … 135 163 del Properties["directory"] 136 164 137 138 bs.append(dabo.ui.dLabel(parent, RegID="%s_label" % (regId,), Caption="%s:" % (labelTitle,)), "normal")165 labelTitle += ":" 166 139 167 target = dabo.ui.dTextBox(parent, RegID=regId, ReadOnly=True, properties=Properties) 140 bs.append(target, "normal", 1) 141 bs.appendSpacer(5) 142 bs.append(fileButton(parent, format, "%s_button" % (regId,), directory, target), "normal") 168 controlList.append(target) 169 controlList.append(fileButton(parent, format, "%s_button" % (regId,), directory, target)) 143 170 else: 144 171 if issubclass(control, (dabo.ui.dCheckBox, dabo.ui.dButton)): … … 148 175 controlCaption = "" 149 176 labelTitle += ":" 150 bs.append(dabo.ui.dLabel(parent, RegID="%s_label" % (regId,), Caption=labelTitle), "normal") 151 152 if control is dabo.ui.dEditBox: 153 layout = "expand" 154 else: 155 layout = "normal" 156 157 bs.append(control(parent, RegID=regId, Caption=controlCaption, properties=Properties), layout, 1) 158 159 return bs 177 178 controlList.append(control(parent, RegID=regId, Caption=controlCaption, properties=Properties)) 179 180 controlList.insert(0, dabo.ui.dLabel(parent, RegID="%s_label" % (regId,), Caption=labelTitle)) 181 return controlList 160 182 161 183 def makeButtonBar(self, buttonData, orientation="horizontal"): branches/carl2/dabo/lib/datanav/__init__.py
r2412 r2748 1 ## Note: as of today (1/22/2005), the dDataNav subframework is only 2 ## compatible with wxPython, and still calls some wx functions directly, 3 ## mostly DC related. 4 1 import warnings 2 from dabo.dLocalize import _ 5 3 from Form import Form 6 4 from Grid import Grid … … 10 8 from Bizobj import Bizobj 11 9 12 #Form = Form 13 #Grid = Grid 14 #Page, SelectPage, EditPage, BrowsePage = Page, SelectPage, EditPage, BrowsePage 10 warnings.warn(_("This version of the datanav framework is deprecated; please " 11 "run the current AppWizard to regenerate your application using the datanav2 " 12 "framework."), DeprecationWarning, 1) branches/carl2/dabo/ui/uiwx/dDialog.py
r2524 r2748 35 35 # Hook method, so that we add the buttons last 36 36 self._addControls() 37 38 # Needed starting with wx 2.7, for the first control to have the focus: 39 self.setFocus() 37 40 38 41 branches/carl2/dabo/ui/uiwx/dEditor.py
r2619 r2748 1285 1285 self.SetSelection(-1, -1) 1286 1286 self.EnsureCaretVisible() 1287 1288 1289 def ensureLineVisible(self, line): 1290 self.EnsureVisible(line) 1291 self.LineNumber = line 1292 self.EnsureCaretVisible() 1287 1293 1288 1294 branches/carl2/dabo/ui/uiwx/dFormMain.py
r2482 r2748 13 13 fm.dFormMixin.__init__(self, preClass, parent, properties, *args, **kwargs) 14 14 15 self.Size = (640, 480)16 self.Position = (-1, -1)15 # self.Size = (640, 480) 16 # self.Position = (-1, -1) 17 17 18 18 if wx.Platform != '__WXMAC__': 19 19 self.CreateStatusBar() 20 20 21 22 def _afterInit(self):23 super(dFormMainBase, self)._afterInit()24 25 # This is to accomodate the Dabo icon, which has a white background.26 # We should set the white as transparent and set a mask, though.27 self.BackColor = "White"28 29 # Set up the Dabo icon30 self.bitmap = self.drawBitmap("dabo_lettering_250x100", x=10, y=0)31 plat = self.Application.Platform.lower()32 off = 15033 if plat == "win":34 off = 18035 elif plat == "gtk":36 off = 16037 self.bitmap.DynamicYpos = lambda: self.Height - off38 self.autoClearDrawings = True39 self.bindEvent(dEvents.Resize, self.__onResize)40 41 42 def __onResize(self, evt):43 self.update()44 45 46 21 def _beforeClose(self, evt=None): 47 22 forms2close = [frm for frm in self.Application.uiForms branches/carl2/dabo/ui/uiwx/dFormMixin.py
r2713 r2748 18 18 19 19 # Windows sends two Activate events, and one of them is too early. 20 # Skip the first one 21 self._skipActivate = (self.Application.Platform == "Win") 20 # Skip the first one. Update: apparently on wx27 and above the 21 # double-activation is no longer an issue. 22 self._skipActivate = (wx.VERSION < (2,7) and self.Application.Platform == "Win") 22 23 23 24 # Extract the connection name, if any … … 146 147 if not restoredSP: 147 148 if self.SaveRestorePosition: 148 self.restoreSizeAndPosition()149 dabo.ui.callAfter(self.restoreSizeAndPosition) 149 150 150 151 self.raiseEvent(dEvents.Activate, evt) branches/carl2/dabo/ui/uiwx/dGrid.py
r2713 r2748 452 452 self.listRendererClass = wx.grid.GridCellStringRenderer 453 453 self.stringEditorClass = wx.grid.GridCellTextEditor 454 self.wrapStringEditorClass = wx.grid.GridCellAutoWrapStringEditor 454 455 self.boolEditorClass = wx.grid.GridCellBoolEditor 455 456 self.intEditorClass = wx.grid.GridCellNumberEditor … … 1297 1298 if val: 1298 1299 self.defaultRenderers["str"] = self.defaultRenderers["string"] = self.wrapStringRendererClass 1300 self.defaultEditors["str"] = self.defaultEditors["string"] = self.wrapStringEditorClass 1299 1301 else: 1300 1302 self.defaultRenderers["str"] = self.defaultRenderers["string"] = self.stringRendererClass 1303 self.defaultEditors["str"] = self.defaultEditors["string"] = self.stringEditorClass 1301 1304 self._refreshGrid() 1302 1305 else: … … 4286 4289 self.addColumn(col) 4287 4290 4288 col.CustomRenderers[1] = col.stringRendererClass4289 col.CustomEditors[1] = col.stringEditorClass4291 # col.CustomRenderers[1] = col.stringRendererClass 4292 # col.CustomEditors[1] = col.stringEditorClass 4290 4293 col.HeaderFontBold = False 4291 4294 4292 4295 col = dColumn(self, Name="Person", Order=20, DataField="name", 4293 4296 DataType="string", Width=200, Caption="Celebrity Name", 4294 Sortable=True, Searchable=True, Editable=True, Expand= True)4297 Sortable=True, Searchable=True, Editable=True, Expand=False) 4295 4298 self.addColumn(col) 4296 4299 … … 4306 4309 col = dColumn(self, Name="Color", Order=40, DataField="color", 4307 4310 DataType="string", Width=40, Caption="Favorite Color", 4308 Sortable=True, Searchable=True, Editable=True, Expand= True)4311 Sortable=True, Searchable=True, Editable=True, Expand=False) 4309 4312 self.addColumn(col) 4310 4313 branches/carl2/dabo/ui/uiwx/dMenu.py
r2686 r2748 238 238 239 239 If release is True (the default), the item is deleted as well. If release 240 is False, a reference to the object will be returned, and the caller240 is False, a reference to the object will be returned, and the caller 241 241 is responsible for deleting it. 242 242 """ … … 245 245 if self._daboChildren.has_key(id_): 246 246 del self._daboChildren[id_] 247 self.RemoveItem(item) 247 248 if wx.VERSION >= (2,7): 249 # Needed to keep dPemMixin mixed-in in wxPython 2.8 250 val = wx.Menu.RemoveItem(self, item) 251 item.this.own(val.this.own()) 252 val.this.disown() 253 else: 254 self.RemoveItem(item) 255 248 256 if release: 249 if wx.VERSION[0] == 2 and wx.VERSION[1] >= 7: 250 # segfault when destroying menu items for wx2.7. I've reported it and 251 # it will probably be fixed soon. For now, don't destroy it but return 252 # None to the caller. 253 item = None 254 else: 255 item.Destroy() 257 item.Destroy() 258 item = None 256 259 return item 257 260 branches/carl2/dabo/ui/uiwx/dPageFrameMixin.py
r2583 r2748 335 335 def _getSelectedPage(self): 336 336 try: 337 ret = self.GetPage(self.GetSelection()) 337 sel = self.GetSelection() 338 if sel < 0: 339 &n
