def createBody(self): self.Form._convertTabs = False self.Sizer.appendSpacer(5) lbl = dLabel(self, Caption=_("Enter the name of your app:")) self.txtAppName = dabo.ui.dTextBox(self) hs = dabo.ui.dSizer("h") hs.append(lbl) hs.appendSpacer(5) hs.append1x(self.txtAppName) self.Sizer.append(hs, "x") self.Sizer.appendSpacer(10) txt = """Enter the directory where you wish to place your new application. It will be placed in a folder in that directory with the application name chosen above. You can always move the directory later.""" lbl = dLabel(self, Caption=txt) self.Sizer.append(lbl) hs = dabo.ui.dSizer("h") self.txtDir = dabo.ui.dTextBox(self) ##pkm: Commented this out as it looks awful on Windows. ##self.txtDir.FontSize=10 self.txtDir.Value = "" hs.append(self.txtDir, 1) hs.appendSpacer(4) self.cmdPick = dabo.ui.dButton(self, Caption="...", Width=30, Height=self.txtDir.Height) self.cmdPick.bindEvent(dEvents.Hit, self.onPick) hs.append(self.cmdPick, 0) self.Sizer.append1x(hs) self.chkPKUI = dabo.ui.dCheckBox(self, Caption=_("Include PK fields in the UI")) self.Sizer.append(self.chkPKUI) self.chkUnknown = dabo.ui.dCheckBox(self, Caption=_("Include Unknown datatype fields")) self.Sizer.append(self.chkUnknown) self.chkSortFieldsAlpha = dabo.ui.dCheckBox(self, Caption=_("Sort Fields Alphabetically")) self.Sizer.append(self.chkSortFieldsAlpha) self.Sizer.appendSpacer(2) ln = dabo.ui.dLine(self, Width=200) self.Sizer.append(ln, halign="left") lbl = dabo.ui.dLabel(self, Caption=_("Tabs are the default for indentation.")) lbl.FontSize -= 1 self.Sizer.append(lbl) chkConvertTabs = dabo.ui.dCheckBox(self, RegID="chkConvertTabs", Caption=_("Check this if you insist on using spaces."), DataSource=self.Form, DataField="ConvertTabs", SaveRestoreValue=True) chkConvertTabs.FontSize -= 1 self.Sizer.append(chkConvertTabs, valign="bottom")
def testAll(self): """ Create a dForm and populate it with example dWidgets. """ self.app.setup() frame = self.app.MainForm frame.Size = (340, 120) frame.Caption = "Test of all the dControls" frame.debug = True frame.LogEvents = ["All"] panel = frame.addObject(ui.dPanel, "panelTest") panel.LogEvents = ["All"] labelWidth = 150 for objClass in (ui.dCheckBox,): label = ui.dLabel(panel) label.Width = labelWidth obj = objClass(panel) obj.bindEvent(dEvents.Hit, self.objHit) label.Caption = "%s:" % objClass.__name__ obj.debug = True obj.LogEvents = ["All"] self.app.start()
def afterInit(self): hs = self.Sizer = dSizer("h") but_props = { "FontBold": True, "ShowInBrowser": False, "OnHit": self.onHit_but, "VisitedUnderline": False, "LinkUnderline": False, "VisitedColor": "black", "HoverUnderline": False, "LinkColor": "black" } left_but = dHyperLink(self, Name="butLeft", Caption=" < ", **but_props) right_but = dHyperLink(self, Name="butRight", Caption=" > ", **but_props) lbl = dLabel(self, Name="lblMonthYear", FontBold=True) hs.appendSpacer(20) hs.append(left_but) hs.appendSpacer(10) hs.append(lbl, alignment="middle") hs.appendSpacer(10) hs.append(right_but) hs.appendSpacer(20)
def testAll(self): """ Create a dForm and populate it with example dWidgets. """ self.app.setup() frame = self.app.MainForm frame.Size = (340, 120) frame.Caption = "Test of all the dControls" frame.debug = True frame.LogEvents = ["All"] panel = frame.addObject(ui.dPanel, "panelTest") panel.LogEvents = ["All"] labelWidth = 150 for objClass in (ui.dCheckBox, ): label = ui.dLabel(panel) label.Width = labelWidth obj = objClass(panel) obj.bindEvent(dEvents.Hit, self.objHit) label.Caption = "%s:" % objClass.__name__ obj.debug = True obj.LogEvents = ["All"] self.app.start()
def testAll(self): """Create a dForm and populate it with example dWidgets.""" frame = ui.dForm(Name="formTestAll") frame.Caption = "Test of all the dControls" frame.LogEvents = logEvents panel = frame.addObject(ui.dScrollPanel, "panelTest") panel.SetScrollbars(10,10,50,50) labelWidth = 150 vs = ui.dSizer("vertical") # Get all the python modules in this directory into a list: modules = [modname.split(".")[0] for modname in os.listdir(".") if modname[-3:] == ".py"] for modname in sorted(modules): print "==> ", modname # if the module has a test class, instantiate it: if modname == "__init__": # importing __init__ will pollute the dabo.ui namespace and cause # isinstance() problems. continue try: mod = __import__(modname) except ImportError, e: print "ImportError:", e continue objname = "_%s_test" % modname if objname in mod.__dict__: print "Trying to instantiate %s..." % objname try: obj = mod.__dict__[objname](panel) except StandardError, e: print "+++++++++++++++++++++++++++++++++++++++" print "+++ Instantiating %s caused:" % objname print traceback.print_exception(*sys.exc_info()) print "+++++++++++++++++++++++++++++++++++++++" continue if objname == "_dToolBar_test": frame.ToolBar = obj break bs = ui.dSizer("horizontal") label = ui.dLabel(panel, Alignment="Right", AutoResize=False, Width=labelWidth) label.Caption = "%s:" % modname bs.append(label) if isinstance(obj, ui.dEditBox): layout = "expand" else: layout = "normal" bs.append(obj, layout) if isinstance(obj, ui.dEditBox): vs.append(bs, "expand") else: vs.append(bs, "expand")
def afterInit(self): con = self.Form.Connection gs = self.Sizer = dGridSizer(MaxCols=7) self.bizStatic = biz.BizStatic(con) self.bizDaily = biz.BizDaily(con) header = calendar.weekheader(3).split() for x in header: gs.append(dLabel(self, Caption=x), alignment="center") for y in range(self._week_range): for x in range(7): gs.append(PnlDay(self, Pos=(x,y)), "expand") gs.setColExpand(True, x) gs.setRowExpand(True, y+1) self.setFocusToToday()
def afterInit(self): con = self.Form.Connection gs = self.Sizer = dGridSizer(MaxCols=7) self.bizStatic = biz.BizStatic(con) self.bizDaily = biz.BizDaily(con) header = calendar.weekheader(3).split() for x in header: gs.append(dLabel(self, Caption=x), alignment="center") for y in range(self._week_range): for x in range(7): gs.append(PnlDay(self, Pos=(x, y)), "expand") gs.setColExpand(True, x) gs.setRowExpand(True, y + 1) self.setFocusToToday()
def afterInit(self): hs = self.Sizer = dSizer("h") but_props = {"FontBold": True, "ShowInBrowser": False, "OnHit": self.onHit_but, "VisitedUnderline": False, "LinkUnderline": False, "VisitedColor": "black", "HoverUnderline": False, "LinkColor": "black"} left_but = dHyperLink(self, Name="butLeft", Caption=" < ", **but_props) right_but = dHyperLink(self, Name="butRight", Caption=" > ", **but_props) lbl = dLabel(self, Name="lblMonthYear", FontBold=True) hs.appendSpacer(20) hs.append(left_but) hs.appendSpacer(10) hs.append(lbl, alignment="middle") hs.appendSpacer(10) hs.append(right_but) hs.appendSpacer(20)
def createBody(self): self.tableSelections = {} txt = _("""The connection to the database was successful. The following tables were found for that database. Please check all tables you want included in your application.""") lbl = dLabel(self, Caption=txt) clb = dabo.ui.dCheckList(self, Name="clbTableSelection") self.Sizer.append(lbl) self.Sizer.append1x(clb) hsz = dabo.ui.dSizer("h") btn = dabo.ui.dButton(self, Caption=_("Select All")) btn.bindEvent(dEvents.Hit, self.onSelectAll) hsz.append(btn, border=5) btn = dabo.ui.dButton(self, Caption=_("Invert Selection")) btn.bindEvent(dEvents.Hit, self.onInvertSelect) hsz.append(btn, border=5) btn = dabo.ui.dButton(self, Caption=_("Select None")) btn.bindEvent(dEvents.Hit, self.onSelectNone) hsz.append(btn, border=5) self.Sizer.append(hsz, halign="center")
def testAll(self): """Create a dForm and populate it with example dWidgets.""" frame = ui.dForm(Name="formTestAll") frame.Caption = "Test of all the dControls" frame.LogEvents = logEvents panel = frame.addObject(ui.dScrollPanel, "panelTest") panel.SetScrollbars(10, 10, 50, 50) labelWidth = 150 vs = ui.dSizer("vertical") # Get all the python modules in this directory into a list: modules = [ modname.split(".")[0] for modname in os.listdir(".") if modname[-3:] == ".py" ] for modname in sorted(modules): print "==> ", modname # if the module has a test class, instantiate it: if modname == "__init__": # importing __init__ will pollute the dabo.ui namespace and cause # isinstance() problems. continue try: mod = __import__(modname) except ImportError, e: print "ImportError:", e continue objname = "_%s_test" % modname if objname in mod.__dict__: print "Trying to instantiate %s..." % objname try: obj = mod.__dict__[objname](panel) except StandardError, e: print "+++++++++++++++++++++++++++++++++++++++" print "+++ Instantiating %s caused:" % objname print traceback.print_exception(*sys.exc_info()) print "+++++++++++++++++++++++++++++++++++++++" continue if objname == "_dToolBar_test": frame.ToolBar = obj break bs = ui.dSizer("horizontal") label = ui.dLabel(panel, Alignment="Right", AutoResize=False, Width=labelWidth) label.Caption = "%s:" % modname bs.append(label) if isinstance(obj, ui.dEditBox): layout = "expand" else: layout = "normal" bs.append(obj, layout) if isinstance(obj, ui.dEditBox): vs.append(bs, "expand") else: vs.append(bs, "expand")
def createControls(self): self.Caption = _("Connection Editor") self.bg = dui.dPanel(self, BackColor="LightSteelBlue") gbsz = dui.dGridSizer(VGap=12, HGap=5, MaxCols=2) # Add the fields # Connection Dropdown cap = dui.dLabel(self.bg, Caption=_("Connection")) ctl = dui.dDropdownList(self.bg, Choices=list(self.connDict.keys()), RegID="connectionSelector", OnHit=self.onConnectionChange) btn = dui.dButton(self.bg, Caption=_("Edit Name"), RegID="cxnEdit", OnHit=self.onCxnEdit) hsz = dui.dSizer("h") hsz.append(ctl) hsz.appendSpacer(10) hsz.append(btn) btn = dui.dButton(self.bg, Caption=_("Delete This Connection"), RegID="cxnDelete", DynamicEnabled=self.hasMultipleConnections, OnHit=self.onCxnDelete) hsz.appendSpacer(10) hsz.append(btn) gbsz.append(cap, halign="right", valign="middle") gbsz.append(hsz, valign="middle") # Backend Type cap = dui.dLabel(self.bg, Caption=_("Database Type")) ctl = dui.dDropdownList(self.bg, RegID="DbType", Choices=["MySQL", "Firebird", "PostgreSQL", "MsSQL", "SQLite"], DataSource="form", DataField="dbtype", OnHit=self.onDbTypeChanged) gbsz.append(cap, halign="right") gbsz.append(ctl) self.dbTypeSelector = ctl # Host cap = dui.dLabel(self.bg, Caption=_("Host")) ctl = dui.dTextBox(self.bg, DataSource="form", DataField="host") gbsz.append(cap, halign="right") gbsz.append(ctl, "expand") self.hostText = ctl # Port cap = dui.dLabel(self.bg, Caption=_("Port")) ctl = dui.dTextBox(self.bg, DataSource="form", DataField="port") gbsz.append(cap, halign="right") gbsz.append(ctl, "expand") self.portText = ctl # Database cap = dui.dLabel(self.bg, Caption=_("Database")) ctl = dui.dTextBox(self.bg, DataSource="form", DataField="database") hsz = dui.dSizer("h") self.btnDbSelect = dui.dButton(self.bg, Caption=" ... ", RegID="btnDbSelect", Visible=False, OnHit=self.onDbSelect) hsz.append1x(ctl) hsz.appendSpacer(2) hsz.append(self.btnDbSelect, 0, "x") gbsz.append(cap, halign="right") gbsz.append(hsz, "expand") self.dbText = ctl # Username cap = dui.dLabel(self.bg, Caption=_("User Name")) ctl = dui.dTextBox(self.bg, DataSource="form", DataField="user") gbsz.append(cap, halign="right") gbsz.append(ctl, "expand") self.userText = ctl # Password cap = dui.dLabel(self.bg, Caption=_("Password")) ctl = dui.dTextBox(self.bg, PasswordEntry=True, DataSource="form", DataField="password") gbsz.append(cap, halign="right") gbsz.append(ctl, "expand") self.pwText = ctl # Open Button btnSizer1 = dui.dSizer("h") btnSizer2 = dui.dSizer("h") btnTest = dui.dButton(self.bg, RegID="btnTest", Caption=_("Test..."), OnHit=self.onTest) btnSave = dui.dButton(self.bg, RegID="btnSave", Caption=_("Save"), OnHit=self.onSave) btnNewConn = dui.dButton(self.bg, RegID="btnNewConn", Caption=_("New Connection"), OnHit=self.onNewConn) btnNewFile = dui.dButton(self.bg, RegID="btnNewFile", Caption=_("New File"), OnHit=self.onNewFile) btnOpen = dui.dButton(self.bg, RegID="btnOpen", Caption=_("Open File..."), OnHit=self.onOpen) btnSizer1.append(btnTest, 0, border=3) btnSizer1.append(btnSave, 0, border=3) btnSizer2.append(btnNewConn, 0, border=3) btnSizer2.append(btnNewFile, 0, border=3) btnSizer2.append(btnOpen, 0, border=3) gbsz.setColExpand(True, 1) self.gridSizer = gbsz sz = self.bg.Sizer = dui.dSizer("v") sz.append(gbsz, 0, "expand", halign="center", border=20) sz.append(btnSizer1, 0, halign="center") sz.append(btnSizer2, 0, halign="center") # Only create the 'Set Crypto Key' button if PyCrypto is installed try: from Crypto.Cipher import DES3 as _TEST_DES3 self._showKeyButton = True del _TEST_DES3 except ImportError: self._showKeyButton = False if self._showKeyButton: self.cryptoKeyButton = dui.dButton(self.bg, Caption=_("Set Crypto Key"), OnHit=self.onSetCrypto) btnSizer1.append(self.cryptoKeyButton, 0, halign="center", border=3) self.Sizer = dui.dSizer("h") self.Sizer.append(self.bg, 1, "expand", halign="center") self.Layout()
def createBody(self): self.embeddedDbTypes = ("SQLite", ) self.embeddedFields = ("DbType", "Database", "Name") self.serverFields = self.embeddedFields + ("Host", "User", "Password", "Port") sz = self.Sizer lbl = dLabel( self, Caption=_("Enter the parameters here, and then click 'Next'.")) sz.append(lbl) lbl = dLabel(self, Caption=_("Profile:")) self.dbDefaults = {} self.dbDefaults["MySQL"] = { "DbType": "MySQL", "Host": "dabodev.com", "Database": "webtest", "User": "******", "Password": "******", "Port": "3306", "Name": "MySQL-default" } self.dbDefaults["Firebird"] = { "DbType": "Firebird", "Host": "dabodev.com", "Database": "webtest", "User": "******", "Password": "******", "Port": "3050", "Name": "Firebird-default" } self.dbDefaults["PostgreSQL"] = { "DbType": "PostgreSQL", "Host": "dabodev.com", "Database": "webtest", "User": "******", "Password": "******", "Port": "5432", "Name": "PostgreSQL-default" } self.dbDefaults["MsSQL"] = { "DbType": "MsSQL", "Host": "", "Database": "", "User": "", "Password": "", "Port": "1433", "Name": "MsSQL-default" } self.dbDefaults["SQLite"] = { "DbType": "SQLite", "Database": "webtest.sqlite", "Name": "SQLite-default" } # Save the supported dbTypes into a list self.supportedDbTypes = self.dbDefaults.keys() # List of all fields to create for the user to select self.fieldNames = ("DbType", "Name", "Host", "Database", "User", "Password", "Port") # Now go through the profiles that the user may have saved in the # user settings file: app = self.Application userProfiles = app.getUserSettingKeys("dbDefaults") dbDefaultKeys = self.dbDefaults.keys() dbDefaultMap = {} for key in dbDefaultKeys: dbDefaultMap[key.lower()] = key ## Default to MySQL first: defaultProfileName = "MySQL" defaultUserProfileName = None for profile in userProfiles: userDict = {} for field in (self.fieldNames): name = "dbDefaults.%s.%s" % (profile, field) val = app.getUserSetting(name) if val is None: val = "" userDict[field] = val if profile in dbDefaultMap.keys(): profile = dbDefaultMap[profile] self.dbDefaults[profile] = userDict # Override the default with the last user profile: defaultUserProfileName = profile # Set up the dropdown list based on the keys in the dbDefaults dict. self.ddProfile = dabo.ui.dDropdownList(self, Name="ddProfile") self.ddProfile.ValueMode = "string" self.ddProfile.Choices = self.dbDefaults.keys() if defaultUserProfileName is not None: self.ddProfile.Value = defaultUserProfileName else: self.ddProfile.Value = defaultProfileName self.ddProfile.bindEvent(dEvents.ValueChanged, self.onProfileChoice) cmd = dabo.ui.dButton(self, Caption=_("New Profile..."), Name="cmdNewProfile") cmd.bindEvent(dEvents.Hit, self.onNewProfile) gs = dabo.ui.dGridSizer() gs.MaxCols = 2 gs.append(lbl) hs = dabo.ui.dSizer("h") hs.append(self.ddProfile, 1) hs.appendSpacer(8) hs.append(cmd, 0) gs.append(hs, "x") gs.appendSpacer(20, colSpan=2) gs.setColExpand(True, 1) for field in self.fieldNames: lbl = dLabel(self, Name=("lbl%s" % field), Width=75, Caption=("%s:" % field)) if field == "DbType": obj = dabo.ui.dDropdownList(self, Name=("ctl%s" % field), Choices=self.supportedDbTypes, ValueMode="string") else: pw = (field.lower() == "password") obj = dabo.ui.dTextBox(self, PasswordEntry=pw, Name=("ctl%s" % field), SelectOnEntry=True) obj.bindEvent(dEvents.ValueChanged, self.onParmValueChanged) gs.append(lbl) # Add a file search button. It will be hidden for all # non-file-based backends. if field == "Database": self.btnSrch = dabo.ui.dButton(self, Caption="...") self.btnSrch.Width = (self.btnSrch.Height * 2) self.btnSrch.bindEvent(dEvents.Hit, self.onDbSearch) hs = self.szDB = dabo.ui.dSizer("H") hs.append1x(obj) hs.append(self.btnSrch, border=10, borderSides="left") gs.append(hs, "x") else: gs.append(obj, "x") sz.append(gs, 1, "x") self.onProfileChoice()
def __init__(self, parent, Caption=_("Create Application")): super(PageGo, self).__init__(parent=parent, Caption=Caption) txt = _("""Press 'Finish' to create your application, or 'Back' to edit any information.""") lbl = dLabel(self, Caption=txt) self.Sizer.append1x(lbl)
def createBody(self): self.Form._convertTabs = False self.Sizer.appendSpacer(5) lbl = dLabel(self, Caption=_("Enter the name of your app:")) self.txtAppName = dabo.ui.dTextBox(self) hs = dabo.ui.dSizer("h") hs.append(lbl) hs.appendSpacer(5) hs.append1x(self.txtAppName) self.Sizer.append(hs, "x") self.Sizer.appendSpacer(10) txt = """Enter the directory where you wish to place your new application. It will be placed in a folder in that directory with the application name chosen above. You can always move the directory later.""" lbl = dLabel(self, Caption=txt) self.Sizer.append(lbl) hs = dabo.ui.dSizer("h") self.txtDir = dabo.ui.dTextBox(self) ##pkm: Commented this out as it looks awful on Windows. ##self.txtDir.FontSize=10 self.txtDir.Value = "" hs.append(self.txtDir, 1) hs.appendSpacer(4) self.cmdPick = dabo.ui.dButton(self, Caption="...", Width=30, Height=self.txtDir.Height) self.cmdPick.bindEvent(dEvents.Hit, self.onPick) hs.append(self.cmdPick, 0) self.Sizer.append1x(hs) self.chkPKUI = dabo.ui.dCheckBox( self, Caption=_("Include PK fields in the UI")) self.Sizer.append(self.chkPKUI) self.chkUnknown = dabo.ui.dCheckBox( self, Caption=_("Include Unknown datatype fields")) self.Sizer.append(self.chkUnknown) self.chkSortFieldsAlpha = dabo.ui.dCheckBox( self, Caption=_("Sort Fields Alphabetically")) self.Sizer.append(self.chkSortFieldsAlpha) self.Sizer.appendSpacer(2) ln = dabo.ui.dLine(self, Width=200) self.Sizer.append(ln, halign="left") lbl = dabo.ui.dLabel( self, Caption=_("Tabs are the default for indentation.")) lbl.FontSize -= 1 self.Sizer.append(lbl) chkConvertTabs = dabo.ui.dCheckBox( self, RegID="chkConvertTabs", Caption=_("Check this if you insist on using spaces."), DataSource=self.Form, DataField="ConvertTabs", SaveRestoreValue=True) chkConvertTabs.FontSize -= 1 self.Sizer.append(chkConvertTabs, valign="bottom")
def createBody(self): self.embeddedDbTypes = ("SQLite", ) self.embeddedFields = ("DbType", "Database", "Name") self.serverFields = self.embeddedFields + ("Host", "User", "Password", "Port") sz = self.Sizer lbl = dLabel(self, Caption=_("Enter the parameters here, and then click 'Next'.")) sz.append(lbl) lbl = dLabel(self, Caption=_("Profile:")) self.dbDefaults = {} self.dbDefaults["MySQL"] = { "DbType" : "MySQL", "Host" : "dabodev.com", "Database" : "webtest", "User" : "webuser", "Password" : "foxrocks", "Port" : "3306", "Name" : "MySQL-default" } self.dbDefaults["Firebird"] = { "DbType" : "Firebird", "Host" : "dabodev.com", "Database" : "webtest", "User" : "webuser", "Password" : "foxrox", "Port" : "3050", "Name" : "Firebird-default" } self.dbDefaults["PostgreSQL"] = { "DbType" : "PostgreSQL", "Host" : "dabodev.com", "Database" : "webtest", "User" : "webuser", "Password" : "foxrox", "Port" : "5432", "Name" : "PostgreSQL-default" } self.dbDefaults["MsSQL"] = { "DbType" : "MsSQL", "Host" : "", "Database" : "", "User" : "", "Password" : "", "Port" : "1433", "Name" : "MsSQL-default" } self.dbDefaults["SQLite"] = { "DbType" : "SQLite", "Database" : "webtest.sqlite", "Name" : "SQLite-default" } # Save the supported dbTypes into a list self.supportedDbTypes = self.dbDefaults.keys() # List of all fields to create for the user to select self.fieldNames = ("DbType", "Name", "Host", "Database", "User", "Password", "Port") # Now go through the profiles that the user may have saved in the # user settings file: app = self.Application userProfiles = app.getUserSettingKeys("dbDefaults") dbDefaultKeys = self.dbDefaults.keys() dbDefaultMap = {} for key in dbDefaultKeys: dbDefaultMap[key.lower()] = key ## Default to MySQL first: defaultProfileName = "MySQL" defaultUserProfileName = None for profile in userProfiles: userDict = {} for field in (self.fieldNames): name = "dbDefaults.%s.%s" % (profile, field) val = app.getUserSetting(name) if val is None: val = "" userDict[field] = val if profile in dbDefaultMap.keys(): profile = dbDefaultMap[profile] self.dbDefaults[profile] = userDict # Override the default with the last user profile: defaultUserProfileName=profile # Set up the dropdown list based on the keys in the dbDefaults dict. self.ddProfile = dabo.ui.dDropdownList(self, Name="ddProfile") self.ddProfile.ValueMode = "string" self.ddProfile.Choices = self.dbDefaults.keys() if defaultUserProfileName is not None: self.ddProfile.Value = defaultUserProfileName else: self.ddProfile.Value = defaultProfileName self.ddProfile.bindEvent(dEvents.ValueChanged, self.onProfileChoice) cmd = dabo.ui.dButton(self, Caption=_("New Profile..."), Name="cmdNewProfile") cmd.bindEvent(dEvents.Hit, self.onNewProfile) gs = dabo.ui.dGridSizer() gs.MaxCols = 2 gs.append(lbl) hs = dabo.ui.dSizer("h") hs.append(self.ddProfile, 1) hs.appendSpacer(8) hs.append(cmd, 0) gs.append(hs, "x") gs.appendSpacer(20, colSpan=2) gs.setColExpand(True, 1) for field in self.fieldNames: lbl = dLabel(self, Name=("lbl%s" % field), Width=75, Caption=("%s:" % field) ) if field == "DbType": obj = dabo.ui.dDropdownList(self, Name=("ctl%s" % field), Choices=self.supportedDbTypes, ValueMode="string") else: pw = (field.lower() == "password") obj = dabo.ui.dTextBox(self, PasswordEntry=pw, Name=("ctl%s" % field), SelectOnEntry=True ) obj.bindEvent(dEvents.ValueChanged, self.onParmValueChanged) gs.append(lbl) # Add a file search button. It will be hidden for all # non-file-based backends. if field == "Database": self.btnSrch = dabo.ui.dButton(self, Caption="...") self.btnSrch.Width = (self.btnSrch.Height * 2) self.btnSrch.bindEvent(dEvents.Hit, self.onDbSearch) hs = self.szDB = dabo.ui.dSizer("H") hs.append1x(obj) hs.append(self.btnSrch, border=10, borderSides="left") gs.append(hs, "x") else: gs.append(obj, "x") sz.append(gs, 1, "x") self.onProfileChoice()
def createControls(self): self.Caption = _("Connection Editor") self.bg = dui.dPanel(self, BackColor="LightSteelBlue") gbsz = dui.dGridSizer(VGap=12, HGap=5, MaxCols=2) # Add the fields # Connection Dropdown cap = dui.dLabel(self.bg, Caption=_("Connection")) ctl = dui.dDropdownList(self.bg, Choices=self.connDict.keys(), RegID="connectionSelector", OnHit=self.onConnectionChange) btn = dui.dButton(self.bg, Caption=_("Edit Name"), RegID="cxnEdit", OnHit=self.onCxnEdit) hsz = dui.dSizer("h") hsz.append(ctl) hsz.appendSpacer(10) hsz.append(btn) btn = dui.dButton(self.bg, Caption=_("Delete This Connection"), RegID="cxnDelete", DynamicEnabled=self.hasMultipleConnections, OnHit=self.onCxnDelete) hsz.appendSpacer(10) hsz.append(btn) gbsz.append(cap, halign="right", valign="middle") gbsz.append(hsz, valign="middle") # Backend Type cap = dui.dLabel(self.bg, Caption=_("Database Type")) ctl = dui.dDropdownList(self.bg, RegID="DbType", Choices=["MySQL", "Firebird", "PostgreSQL", "MsSQL", "SQLite"], DataSource="form", DataField="dbtype", OnHit=self.onDbTypeChanged) gbsz.append(cap, halign="right") gbsz.append(ctl) self.dbTypeSelector = ctl # Host cap = dui.dLabel(self.bg, Caption=_("Host")) ctl = dui.dTextBox(self.bg, DataSource="form", DataField="host") gbsz.append(cap, halign="right") gbsz.append(ctl, "expand") self.hostText = ctl # Port cap = dui.dLabel(self.bg, Caption=_("Port")) ctl = dui.dTextBox(self.bg, DataSource="form", DataField="port") gbsz.append(cap, halign="right") gbsz.append(ctl, "expand") self.portText = ctl # Database cap = dui.dLabel(self.bg, Caption=_("Database")) ctl = dui.dTextBox(self.bg, DataSource="form", DataField="database") hsz = dui.dSizer("h") self.btnDbSelect = dui.dButton(self.bg, Caption=" ... ", RegID="btnDbSelect", Visible=False, OnHit=self.onDbSelect) hsz.append1x(ctl) hsz.appendSpacer(2) hsz.append(self.btnDbSelect, 0, "x") gbsz.append(cap, halign="right") gbsz.append(hsz, "expand") self.dbText = ctl # Username cap = dui.dLabel(self.bg, Caption=_("User Name")) ctl = dui.dTextBox(self.bg, DataSource="form", DataField="user") gbsz.append(cap, halign="right") gbsz.append(ctl, "expand") self.userText = ctl # Password cap = dui.dLabel(self.bg, Caption=_("Password")) ctl = dui.dTextBox(self.bg, PasswordEntry=True, DataSource="form", DataField="password") gbsz.append(cap, halign="right") gbsz.append(ctl, "expand") self.pwText = ctl # Open Button btnSizer1 = dui.dSizer("h") btnSizer2 = dui.dSizer("h") btnTest = dui.dButton(self.bg, RegID="btnTest", Caption=_("Test..."), OnHit=self.onTest) btnSave = dui.dButton(self.bg, RegID="btnSave", Caption=_("Save"), OnHit=self.onSave) btnNewConn = dui.dButton(self.bg, RegID="btnNewConn", Caption=_("New Connection"), OnHit=self.onNewConn) btnNewFile = dui.dButton(self.bg, RegID="btnNewFile", Caption=_("New File"), OnHit=self.onNewFile) btnOpen = dui.dButton(self.bg, RegID="btnOpen", Caption=_("Open File..."), OnHit=self.onOpen) btnSizer1.append(btnTest, 0, border=3) btnSizer1.append(btnSave, 0, border=3) btnSizer2.append(btnNewConn, 0, border=3) btnSizer2.append(btnNewFile, 0, border=3) btnSizer2.append(btnOpen, 0, border=3) gbsz.setColExpand(True, 1) self.gridSizer = gbsz sz = self.bg.Sizer = dui.dSizer("v") sz.append(gbsz, 0, "expand", halign="center", border=20) sz.append(btnSizer1, 0, halign="center") sz.append(btnSizer2, 0, halign="center") # Only create the 'Set Crypto Key' button if PyCrypto is installed try: from Crypto.Cipher import DES3 as _TEST_DES3 self._showKeyButton = True del _TEST_DES3 except ImportError: self._showKeyButton = False if self._showKeyButton: self.cryptoKeyButton = dui.dButton(self.bg, Caption=_("Set Crypto Key"), OnHit=self.onSetCrypto) btnSizer1.append(self.cryptoKeyButton, 0, halign="center", border=3) self.Sizer = dui.dSizer("h") self.Sizer.append(self.bg, 1, "expand", halign="center") self.Layout()