On Sunday 22 February 2009 10:43:03 am Peter Seckler wrote:
> John, did you use dMaskedTextBox with a real database date field?
>
> Anyway, I tested some more:
I believe I did. But of course it was US dates. If memory serves I tested
most features. I have small program that I was using - I blew away the
Postgres DB but it looks simple to recreate. Notice I
used "dabo.settings.dateFormat" and I wonder if that was required for dates.
import dabo
dabo.ui.loadUI('wx')
dabo.settings.dateFormat = "%m/%d/%y"
class MainForm(dabo.ui.dForm):
def afterInit(self):
self.Sizer=vs=dabo.ui.dSizer('v')
vs.appendSpacer(5)
addressGrid =
dabo.ui.dGrid(self,RegID="addrgridID",AlternateRowColoring
=True,ColumnCount=5,SelectionMode = "Row",Editable = True,MovableColumns =
False)
addressGrid.DataSource = "public.testmask"
addressGrid.Columns[0].Caption ="text"
addressGrid.Columns[0].DataField = "textctrl"
#addressGrid.Columns[0].Width = 125
addressGrid.Columns[1].Caption ="decimal"
addressGrid.Columns[1].DataField = "decctrl"
#addressGrid.Columns[1].Width = 300
addressGrid.Columns[2].Caption ="date"
addressGrid.Columns[2].DataField = "datectrl"
#addressGrid.Columns[2].Width = 300
addressGrid.Columns[3].Caption ="int"
addressGrid.Columns[3].DataField = "intctrl"
addressGrid.Columns[4].Caption ="plain"
addressGrid.Columns[4].DataField = "plainctrl"
vs.append(addressGrid,0,'x')
vs.appendSpacer(10)
hs=dabo.ui.dSizer('h')
hs.append(dabo.ui.dLabel(self,Caption='decimal'))
self.maskctrl =
dabo.ui.dMaskedTextBox(self,Width=200,RegID='masktextID',Mask='######.##',
InputCodes='F-r',DataSource="public.testmask",DataField="decctrl")
#self.maskctrl.bindEvent(dabo.dEvents.LostFocus,self.mylostfocus)
#self.maskctrl.useFixedWidthFont=False
#self.maskctrl.mask='USZIP'
#self.maskctrl.validBackgroundColour='green'
#self.maskctrl.invalidBackgroundColour ='red'
#self.maskctrl.mask='######.##'
#self.maskctrl.formatcodes='_-'
#self.maskctrl.validRegex='[ ]*[1-9]*.[1-9]*'
#self.maskctrl.Width=200
#self.maskctrl.InputCodes='V'
#self.maskctrl.SetFieldParameters(0,formatcodes='FR')
##._fields[0]._formatcodes='FR'
#self.maskctrl.Fields = { 0:formatcodes='_r'}
# use .SetValue and .Paste to control retrieving the data from the
database.
hs.append1x(self.maskctrl)
vs.append(hs)
vs.appendSpacer(10)
hs=dabo.ui.dSizer('h')
hs.append(dabo.ui.dLabel(self,Caption='Zip + 4'))
self.formatctrl =
dabo.ui.dMaskedTextBox(self,Width=200,RegID='formattextID',Format='zipplus4-us',Mask='######.##',
InputCodes='_->',DataSource="public.testmask",DataField="textctrl")
hs.append(self.formatctrl)
vs.append(hs)
hs=dabo.ui.dSizer('h')
hs.append(dabo.ui.dLabel(self,Caption='Date'))
self.datectrl =
dabo.ui.dMaskedTextBox(self,Width=200,RegID='datetextID',Format='date-us-yy',
DataSource="public.testmask",DataField="datectrl")
hs.append(self.datectrl)
vs.append(hs)
hs=dabo.ui.dSizer('h')
hs.append(dabo.ui.dLabel(self,Caption='Int'))
self.datectrl =
dabo.ui.dMaskedTextBox(self,Width=200,RegID='inttextID',Mask='######',
ValidRegex="[ ]*[1|2]
[1-9]*",DataSource="public.testmask",DataField="intctrl")
hs.append(self.datectrl)
vs.append(hs)
hs=dabo.ui.dSizer('h')
hs.append(dabo.ui.dLabel(self,Caption='Save as Plain'))
self.datectrl =
dabo.ui.dMaskedTextBox(self,Width=200,RegID='plaintextID',Mask='######',UsePlainValue=True,
ValidRegex="[ ]*[1|2]
[1-9]*",DataSource="public.testmask",DataField="plainctrl")
hs.append(self.datectrl)
vs.append(hs)
hs=dabo.ui.dSizer('h')
hs.append(dabo.ui.dButton(self,Caption='saveDAta',OnHit=self.savedata))
hs.appendSpacer(10)
hs.append(dabo.ui.dButton(self,Caption='newDAta',OnHit=self.newRecord))
vs.append(hs)
#vs.append(dabo.ui.dTextBox(self, Width= 200,RegID='textboxID'))
def savedata(self,evt):
self.save()
def mylostfocus(self,evt):
return
def afterInitAll(self):
self.requery()
def newRecord(self,evt):
self.new()
def createBizobjs(self):
self.Application.addConnectFile("BonanzaConnection.cnxml")
# This call will actually create the connection if it hasn't already
# been made. If it has, it returns the existing connection, so that
# multiple connections aren't used up.
self.conn = self.Application.getConnectionByName("BConn")
self.super()
class PublictestmaskBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "public.testmask"
self.KeyField = "pkid"
self.addFrom("public.testmask")
self.addField("pkid")
self.addField("textctrl")
self.addField("intctrl")
self.addField("decctrl")
self.addField("datectrl")
self.addField("plainctrl")
#self.DefaultValues={"datectrl":"01-01-01"}
def validateRecord(self):
"""Returning anything other than an empty string from
this method will prevent the data from being saved.
"""
ret = ""
# Add your business rules here.
return ret
publictestmaskBizobj = PublictestmaskBizobj(self.conn)
self.addBizobj(publictestmaskBizobj)
if __name__ == "__main__":
app = dabo.dApp()
app.Icon="jflogosmall.ico"
app.BasePrefKey = "Real-Accounting"
app.setAppInfo("appName", "Bonanza Accounting")
app.setAppInfo("Icon", "jflogosmall.ico")
app.MainFormClass = MainForm
app.start()
--
John Fabiani
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]