def setUp(self): # We set up a test connection to an in-memory sqlite database, and then we # make a dBizobj against the test table, and then we create a dForm with some # dTextBox's to test the interaction. self.con = dabo.db.dConnection(DbType="SQLite", Database=":memory:") biz = self.biz = dabo.biz.dBizobj(self.con) uniqueName = getRandomUUID().replace("-", "")[-20:] self.temp_table_name = "unittest%s" % uniqueName self.temp_child_table_name = "ut_child%s" % uniqueName self.createSchema() biz.UserSQL = "select * from %s" % self.temp_table_name biz.KeyField = "pk" biz.DataSource = self.temp_table_name biz.requery() ## set up the ui elements: app = self.app = dApp(MainFormClass=None) app.setup() frm = self.frm = dabo.ui.dForm(Caption="test_dForm") frm.addObject(dabo.ui.dTextBox, DataSource=biz.DataSource, DataField="cField", RegID="cField") frm.addObject(dabo.ui.dTextBox, DataSource=biz.DataSource, DataField="nField", RegID="nField") frm.addObject(dabo.ui.dTextBox, DataSource=biz.DataSource, DataField="iField", RegID="iField") ## connect the biz to the frm: frm.addBizobj(biz) ## force the frm to get the first record: frm.first() frm.update(interval=0) ## need to force the update here because it is delayed by default, which doesn't work for scripted tests.
def main(): from dabo.dApp import dApp app = dApp(BasePrefKey="dabo.ui.dShellForm") app.MainFormClass = dShellForm app.setup() app.start()
def main(): from dabo.dApp import dApp app = dApp() app.MainFormClass = None app.setup() app.MainForm = HtmlAbout(None) app.MainForm.show() app.start()
def main(): # The splash screen looks great on Mac/Win, and crappy on Linux. useSplash = "linux" not in platform.platform().lower() mfc = "DaboDemo.cdxml" if not os.path.exists(os.path.join(os.getcwd(), mfc)): mfc = os.path.join(os.getcwd(), os.path.split(sys.argv[0])[0], mfc) app = dApp(showSplashScreen=useSplash, splashTimeout=3000, MainFormClass=mfc, BasePrefKey="demo.DaboDemo") app.setAppInfo("appName", "DaboDemo") app.start()
def main(): app = dApp(BasePrefKey="PrefEditor", MainFormClass="PrefEditor.cdxml") curdir = os.getcwd() # Get the current location's path fname = os.path.abspath(inspect.getfile(main)) pth = os.path.dirname(fname) # Switch to that path os.chdir(pth) app.start() # Return to the original location os.chdir(curdir)
def main(): files = sys.argv[1:] app = dApp(MainFormClass=EditorForm, BasePrefKey="ide.Editor") app.setAppInfo("appName", _("Dabo Editor")) app.setAppInfo("appShortName", _("DaboEditor")) app.setup() frm = app.MainForm app._persistentMRUs = {_("Open Recent") : frm.onMRUSelection} def _openForms(): frm.onFileNew(None) for file in files: frm.openFile(os.path.realpath(file)) frm.show() dabo.ui.callAfter(_openForms) app.start()
def main(): files = sys.argv[1:] app = dApp(MainFormClass=EditorForm, BasePrefKey="ide.Editor") app.setAppInfo("appName", _("Dabo Editor")) app.setAppInfo("appShortName", _("DaboEditor")) app.setup() frm = app.MainForm app._persistentMRUs = {_("Open Recent"): frm.onMRUSelection} def _openForms(): frm.onFileNew(None) for file in files: frm.openFile(os.path.realpath(file)) frm.show() dabo.ui.callAfter(_openForms) app.start()
def main(): files = sys.argv[1:] app = dApp(ignoreScriptDir=True) app.BasePrefKey = "CxnEditor" app.MainFormClass = None app.setup() if not files: # The form can either edit a new file, or the user can open the file # from the form o = EditorForm() o.newFile() o.show() else: for file in files: o = EditorForm() o.openFile(file) if o.connFile: o.show() else: o.close() app.start()
def _getSpacesPerTab(self): return self._spacesPerTab def _setSpacesPerTab(self, val): if self._constructed(): self._spacesPerTab = val else: self._properties["SpacesPerTab"] = val ConvertTabs = property(_getConvertTabs, _setConvertTabs, None, _("Do we convert tabs to spaces? Default=False (bool)")) SpacesPerTab = property(_getSpacesPerTab, _setSpacesPerTab, None, _("When converting tabs, the number of spaces to use per tab. Default=4 (int)")) if __name__ == "__main__": app = dApp(BasePrefKey="dabo.ide.wizards.AppWizard") app.setAppInfo("appName", "Dabo Application Wizard") app.setAppInfo("appShortName", "AppWizard") app.MainFormClass = None app.setup() wiz = AppWizard(None) # No need to start the app; when the wizard exits, so will the app.
def __init__(self): self.app = dApp() self.app.LogEvents = ["All"]
def main(): from dabo.dApp import dApp app = dApp() app.MainFormClass = TestForm app.setup() app.start()
sz = self.Sizer = dabo.ui.dSizer("H") sz.appendSpacer(4) sz.append(link) sz.append(txt, 1) dabo.ui.callAfter(self.update) dabo.ui.callAfter(self.layout) # Necessary so that this works in the Class Designer txt._designerMode = False def _changeHD(self, evt): dirname = dabo.ui.getDirectory(_("Select Home Directory"), self._target.HomeDirectory) if dirname: self._target.HomeDirectory = dirname self.update() def SetStatusText(self, val, fld=0): # Don't allow status text pass if __name__ == "__main__": class HDForm(dabo.ui.dForm): def beforeInit(self): self.StatusBarClass = HomeDirectoryStatusBar app = dApp(MainFormClass=HDForm) app.start()
if __name__ == "__main__": from dabo.dApp import dApp class MediaForm(dabo.ui.dForm): def afterInit(self): # Here's a sample movie URI; you can change this to something local on # your machine, or another URI. #uri = "/Users/ed/Downloads/roc.mov" uri = "http://c0097282.cdn.cloudfiles.rackspacecloud.com/how_to_fold_a_shirt.mpg" if self.Application.Platform == "Win": backend = wx.media.MEDIABACKEND_WMP10 else: backend = "" self.player = dMediaControl(self, Source=uri, Loop=False, OnMediaLoaded=self.onMediaLoaded, szBackend=backend) # Change this to fill the form show_native_size = True if show_native_size: self.Sizer.append(self.player) else: self.Sizer.append1x(self.player) def onMediaLoaded(self, evt): print "MediaLoaded" app = dApp(MainFormClass=MediaForm) app.start()
self.Width = 80 def onHit(self, evt): print "HIT!", self.Value, "Hit Type", evt.hitType def onValueChanged(self, evt): print "Value Changed", self.Value print "___" def onInteractiveChange(self, evt): print "Interactive Change", self.Value def onSpinUp(self, evt): print "Spin up event." def onSpinDown(self, evt): print "Spin down event." def onSpinner(self, evt): print "Spinner event." if __name__ == "__main__": from dabo.dApp import dApp class Test(dabo.ui.dForm): def OH(self, evt): print "HIT" def afterInitAll(self): self.spn = _dSpinner_test(self, Value=3, OnHit=self.OH) app = dApp(MainFormClass=Test) app.start()
def afterInit(self): ms = self.Sizer = dabo.ui.dSizer("v") ms.append(dabo.ui.dLabel(self, Caption="Invoice Report with Cancelable Progress Output"), "expand") self.progress = dabo.ui.dReportProgress(self) ms.append(self.progress) ms.append(dabo.ui.dButton(self, Caption="Preview", OnHit=self.onPreview)) self.fitToSizer() def onPreview(self, evt): self.SaveRestorePosition = False self.preview() def preview(self): rw = dReportWriter() rw.ReportFormFile = "invoice.rfxml" rw.OutputFile = "invoice.pdf" rw.UseTestCursor = True rw.bindEvent(dabo.dEvents.ReportEnd, self.onReportEnd) rw.ProgressControl = self.progress self.progress.ReportWriter = rw rw.write() def onReportEnd(self, evt): """Will be called only if the user didn't cancel; you could also bind to ReportCancel to set a flag, but this seemed cleaner.""" print "report end" reportUtils.previewPDF("invoice.pdf") dApp(MainFormClass=ReportingForm).start()
def testGetApplication(self): """Getting dObject.Application should return a known application""" test = dApp() result = self.dObject.Application self.assertEqual(test, result)
if style != self._currentDefaultStyle: self._currentDefaultStyle = style self.updateSelection(style) def updateSelection(self, style=None): if style is None: style = self.getCurrentStyle() cff, cfs, cfb, cfi, cfu, bc, fc = style self.tbFontFace.Value = cff self.tbFontSize.Value = ustr(cfs) self.tbbBold.Value = cfb self.tbbItalic.Value = cfi self.tbbUnderline.Value = cfu self.tbBackColor.BackColor = bc self.tbForeColor.BackColor = fc def getDummyText(self): return """Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc. """ if __name__ == "__main__": from dabo.dApp import dApp app = dApp(MainFormClass=RichTextTestForm) app.start()
def __init__(self): self.app = dApp() self.app.MainFormClass = None self.app.setup()
self.btnRedeal.Enabled = False self.updateRedealCaption() def updateScore(self): self.txtHandScore.Value = self.gameBoard.Score self.txtGameScore.Value = self.gameBoard.TotalScore self.layout() def getPrefControlXML(self): return """<?xml version="1.0" encoding="utf-8" standalone="no"?> <dPanel classID="408701584" BorderColor="(0, 0, 0)" sizerInfo="{}" Name="dPanel" Buffered="False" code-ID="dPanel-top" ForeColor="(0, 0, 0)" designerClass="path://montanaPrefs.cdxml" BorderWidth="0" BackColor="(221, 221, 221)" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" savedClass="True"> <dGridSizer classID="408701584-408700624" HGap="3" Rows="3" designerClass="LayoutGridSizer" VGap="3" MaxDimension="r" Columns="2"> <dLabel classID="408701584-408656304" BorderColor="(0, 0, 0)" FontBold="False" Name="dLabel" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Right', 'ColExpand': False, 'VAlign': 'Middle', 'Expand': False}" rowColPos="(0, 0)" Caption="Number of Redeals:" ForeColor="(0, 0, 0)" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dLabel> <dSpinner classID="408701584-408656560" BorderColor="(0, 0, 0)" FontBold="False" Name="dSpinner" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Left', 'ColExpand': True, 'VAlign': 'Top', 'Expand': False}" rowColPos="(0, 1)" FontUnderline="False" ForeColor="(0, 0, 0)" DataSource="self.Form.prf" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" DataField="redeals"></dSpinner> <dLabel classID="408701584-408773008" BorderColor="(0, 0, 0)" FontBold="False" Name="dLabel1" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Right', 'ColExpand': False, 'VAlign': 'Middle', 'Expand': False}" rowColPos="(1, 0)" Caption="Only flash empty spaces?" ForeColor="(0, 0, 0)" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dLabel> <dCheckBox classID="408701584-408811504" BorderColor="(0, 0, 0)" FontBold="False" DataField="flashOnlyAces" Name="dCheckBox" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Left', 'ColExpand': True, 'VAlign': 'Top', 'Expand': True}" rowColPos="(1, 1)" Caption="" ForeColor="(0, 0, 0)" DataSource="self.Form.prf" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dCheckBox> <dCheckBox classID="408701584-430021296" BorderColor="(0, 0, 0)" FontBold="False" DataField="smallDeck" Name="dCheckBox1" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Left', 'ColExpand': True, 'VAlign': 'Top', 'Expand': True}" rowColPos="(2, 1)" Caption="" ForeColor="(0, 0, 0)" DataSource="self.Form.prf" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dCheckBox> <dLabel classID="408701584-430460656" BorderColor="(0, 0, 0)" FontBold="False" Name="dLabel2" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Right', 'ColExpand': False, 'VAlign': 'Middle', 'Expand': False}" rowColPos="(2, 0)" Caption="Use small cards" ForeColor="(0, 0, 0)" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dLabel> </dGridSizer> </dPanel>""" if __name__ == "__main__": app = dApp(MainFormClass=MontanaForm) app.BasePrefKey = "demo.games.montana" app.setAppInfo("appName", "Montana") app.start()
gs.setRowExpand(True, currRow) gs.append(objectRef, "expand") gs.append( (25, 1) ) gs.setColExpand(True, 1) mainSizer.insert(0, gs, "expand", 1, border=20) # Add top and bottom margins mainSizer.insert( 0, (-1, 10), 0) mainSizer.append( (-1, 20), 0) self.Sizer.layout() self.itemsCreated = True super(PagEditStudents, self).createItems() if __name__ == "__main__": from FrmStudents import FrmStudents app = dApp(MainFormClass=None) app.setup() class TestForm(FrmStudents): def afterInit(self): pass frm = TestForm(Caption="Test Of PagEditStudents", Testing=True) test = PagEditStudents(frm) test.createItems() frm.Sizer.append1x(test) frm.show() app.start()
def onRedeal(self, evt): self.gameBoard.redeal() self.btnRedeal.Enabled = False self.updateRedealCaption() def updateScore(self): self.txtHandScore.Value = self.gameBoard.Score self.txtGameScore.Value = self.gameBoard.TotalScore self.layout() def getPrefControlXML(self): return """<?xml version="1.0" encoding="utf-8" standalone="no"?> <dPanel classID="408701584" BorderColor="(0, 0, 0)" sizerInfo="{}" Name="dPanel" Buffered="False" code-ID="dPanel-top" ForeColor="(0, 0, 0)" designerClass="path://montanaPrefs.cdxml" BorderWidth="0" BackColor="(221, 221, 221)" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" savedClass="True"> <dGridSizer classID="408701584-408700624" HGap="3" Rows="3" designerClass="LayoutGridSizer" VGap="3" MaxDimension="r" Columns="2"> <dLabel classID="408701584-408656304" BorderColor="(0, 0, 0)" FontBold="False" Name="dLabel" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Right', 'ColExpand': False, 'VAlign': 'Middle', 'Expand': False}" rowColPos="(0, 0)" Caption="Number of Redeals:" ForeColor="(0, 0, 0)" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dLabel> <dSpinner classID="408701584-408656560" BorderColor="(0, 0, 0)" FontBold="False" Name="dSpinner" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Left', 'ColExpand': True, 'VAlign': 'Top', 'Expand': False}" rowColPos="(0, 1)" FontUnderline="False" ForeColor="(0, 0, 0)" DataSource="self.Form.prf" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" DataField="redeals"></dSpinner> <dLabel classID="408701584-408773008" BorderColor="(0, 0, 0)" FontBold="False" Name="dLabel1" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Right', 'ColExpand': False, 'VAlign': 'Middle', 'Expand': False}" rowColPos="(1, 0)" Caption="Only flash empty spaces?" ForeColor="(0, 0, 0)" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dLabel> <dCheckBox classID="408701584-408811504" BorderColor="(0, 0, 0)" FontBold="False" DataField="flashOnlyAces" Name="dCheckBox" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Left', 'ColExpand': True, 'VAlign': 'Top', 'Expand': True}" rowColPos="(1, 1)" Caption="" ForeColor="(0, 0, 0)" DataSource="self.Form.prf" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dCheckBox> <dCheckBox classID="408701584-430021296" BorderColor="(0, 0, 0)" FontBold="False" DataField="smallDeck" Name="dCheckBox1" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Left', 'ColExpand': True, 'VAlign': 'Top', 'Expand': True}" rowColPos="(2, 1)" Caption="" ForeColor="(0, 0, 0)" DataSource="self.Form.prf" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dCheckBox> <dLabel classID="408701584-430460656" BorderColor="(0, 0, 0)" FontBold="False" Name="dLabel2" sizerInfo="{'RowSpan': 1, 'RowExpand': False, 'ColSpan': 1, 'Proportion': 0, 'HAlign': 'Right', 'ColExpand': False, 'VAlign': 'Middle', 'Expand': False}" rowColPos="(2, 0)" Caption="Use small cards" ForeColor="(0, 0, 0)" designerClass="controlMix" BorderWidth="0" BackColor="(221, 221, 221)" FontSize="13" BorderStyle="Default" ToolTipText="None" BorderLineStyle="Solid" FontItalic="False" FontUnderline="False"></dLabel> </dGridSizer> </dPanel>""" if __name__ == "__main__": app = dApp(MainFormClass=MontanaForm) app.BasePrefKey = "demo.games.montana" app.setAppInfo("appName", "Montana") app.start()
#!/usr/bin/env python # -*- coding: utf-8 -*- import dabo.ui from dabo.dApp import dApp dabo.ui.loadUI("wx") app = dApp(SourceURL="http://daboserver.com:7777") # IMPORTANT! Change app.MainFormClass value to the name # of the form class that you want to run when your # application starts up. app.MainFormClass = "people.cdxml" app.start()
def checkForUpdate(self, evt): style = self.getCurrentStyle() if style != self._currentDefaultStyle: self._currentDefaultStyle = style self.updateSelection(style) def updateSelection(self, style=None): if style is None: style = self.getCurrentStyle() cff, cfs, cfb, cfi, cfu, bc, fc = style self.tbFontFace.Value = cff self.tbFontSize.Value = ustr(cfs) self.tbbBold.Value = cfb self.tbbItalic.Value = cfi self.tbbUnderline.Value = cfu self.tbBackColor.BackColor = bc self.tbForeColor.BackColor = fc def getDummyText(self): return """Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc. """ if __name__ == "__main__": from dabo.dApp import dApp app = dApp(MainFormClass=RichTextTestForm) app.start()
class TestForm(dabo.ui.dForm): def afterInit(self): self.Sizer = dabo.ui.dSizer("v", DefaultBorder=10) lbl = dabo.ui.dLabel(self, Caption="Button in BoxSizer Below", FontSize=16) self.Sizer.append(lbl, halign="center") sz = dBorderSizer(self, "v") self.Sizer.append1x(sz) btn = dabo.ui.dButton(self, Caption="Click") sz.append1x(btn) pnl = dabo.ui.dPanel(self, BackColor="seagreen") self.Sizer.append1x(pnl, border=18) class _dBorderSizer_test(dBorderSizer): def __init__(self, bx=None, *args, **kwargs): super(_dBorderSizer_test, self).__init__(box=bx, orientation="h", *args, **kwargs) if __name__ == "__main__": from dabo.dApp import dApp app = dApp() app.MainFormClass = TestForm app.start()
def _getSpacesPerTab(self): return self._spacesPerTab def _setSpacesPerTab(self, val): if self._constructed(): self._spacesPerTab = val else: self._properties["SpacesPerTab"] = val ConvertTabs = property( _getConvertTabs, _setConvertTabs, None, _("Do we convert tabs to spaces? Default=False (bool)")) SpacesPerTab = property( _getSpacesPerTab, _setSpacesPerTab, None, _("When converting tabs, the number of spaces to use per tab. Default=4 (int)" )) if __name__ == "__main__": app = dApp(BasePrefKey="dabo.ide.wizards.AppWizard") app.setAppInfo("appName", "Dabo Application Wizard") app.setAppInfo("appShortName", "AppWizard") app.MainFormClass = None app.setup() wiz = AppWizard(None) # No need to start the app; when the wizard exits, so will the app.
def validateRecord(self): err = "" if len(self.Record.playername.strip()) == 0: err += "Please enter your name" return err def _getGameId(self): return self._gameId def _setGameId(self, val): self._gameId = val if val is not None: self.setWhereClause("""gamedefs.id=%s""" % val) else: self.setWhereClause("") def _getLimit(self): return self._limit def _setLimit(self, val): self._limit = val self.setLimitClause("%s" % val) GameId = property(_getGameId, _setGameId) Limit = property(_getLimit, _setLimit) if __name__ == "__main__": app = dApp(MainFormClass=MinesweeperForm) app.start()
DataField="HomeDirectory") sz = self.Sizer = dabo.ui.dSizer("H") sz.appendSpacer(4) sz.append(link) sz.append(txt, 1) dabo.ui.callAfter(self.update) dabo.ui.callAfter(self.layout) # Necessary so that this works in the Class Designer txt._designerMode = False def _changeHD(self, evt): dirname = dabo.ui.getDirectory(_("Select Home Directory"), self._target.HomeDirectory) if dirname: self._target.HomeDirectory = dirname self.update() def SetStatusText(self, val, fld=0): # Don't allow status text pass if __name__ == "__main__": class HDForm(dabo.ui.dForm): def beforeInit(self): self.StatusBarClass = HomeDirectoryStatusBar app = dApp(MainFormClass=HDForm) app.start()
biz = self.Bizobj if biz.NumberOfGames > 0: if not dabo.ui.areYouSure( message = _("Are you sure you want to reset your statistics?"), title = _("Reset Statistics"), defaultNo = False, cancelButton = False): return else: biz.resetStats() def _getBizobj(self): return self.PrimaryBizobj def _getScore(self): return self._score def _setScore(self, score): if self._score != score: self._score = score self.scoreLabel.Caption = ustr(score) Bizobj = property(_getBizobj, None, None, _("Reference to the form's bizobj")) Score = property(_getScore, _setScore, None, _("Current score of the game. (int)")) if __name__ == "__main__": dApp(MainFormClass=BubbletForm).start()
def setUp(self): app = self.app = dApp(MainFormClass=None) app.setup() frm = dabo.ui.dForm(Caption="test_dEditBox") self.edt = frm.addObject(dabo.ui.dEditBox)
err += "Please enter your name" return err def _getGameId(self): return self._gameId def _setGameId(self, val): self._gameId = val if val is not None: self.setWhereClause("""gamedefs.id=%s""" % val) else: self.setWhereClause("") def _getLimit(self): return self._limit def _setLimit(self, val): self._limit = val self.setLimitClause("%s" % val) GameId = property(_getGameId, _setGameId) Limit = property(_getLimit, _setLimit) if __name__ == "__main__": app = dApp(MainFormClass=MinesweeperForm) app.start()
print "Interactive Change", self.Value def onSpinUp(self, evt): print "Spin up event." def onSpinDown(self, evt): print "Spin down event." def onSpinner(self, evt): print "Spinner event." if __name__ == "__main__": from dabo.dApp import dApp class Test(dabo.ui.dForm): def OH(self, evt): print "HIT" def afterInitAll(self): self.spn = _dSpinner_test(self, Value=3, OnHit=self.OH) self.spn2 = dSpinner(self, Value=3, Max=10, Min=1, Top=75, Width=60) app = dApp(MainFormClass=Test) app.start()
def setUp(self): app = self.app = dApp(MainFormClass=None) app.setup() frm = dabo.ui.dForm(Caption="test_dTextBox") self.txt = frm.addObject(dabo.ui.dTextBox)
def _getDefaultShowInFuture(self): return getattr(self, "_defaultShowInFuture", True) def _setDefaultShowInFuture(self, val): self._defaultShowInFuture = bool(val) def _getMessage(self): return getattr(self, "_message", "") def _setMessage(self, val): self._message = val DefaultShowInFuture = property(_getDefaultShowInFuture, _setDefaultShowInFuture, None, _("Specifies whether the 'show in future' checkbox is checked by default.")) Message = property(_getMessage, _setMessage, None, _("Specifies the message to display.")) if __name__ == '__main__': from dabo.dApp import dApp app = dApp(MainFormClass=None) app.setup() dlg = DlgInfoMessage(None, Message="This is a test of the emergency broadcast system. If this were an actual " \ "emergency, you would have been given specific instructions. This is only a test.") dlg.show()
self, Caption="Invoice Report with Cancelable Progress Output"), "expand") self.progress = dabo.ui.dReportProgress(self) ms.append(self.progress) ms.append( dabo.ui.dButton(self, Caption="Preview", OnHit=self.onPreview)) self.Size = (400, 300) def onPreview(self, evt): self.preview() def preview(self): rw = dReportWriter() rw.ReportFormFile = "invoice.rfxml" rw.OutputFile = "invoice.pdf" rw.UseTestCursor = True rw.bindEvent(dabo.dEvents.ReportEnd, self.onReportEnd) rw.ProgressControl = self.progress self.progress.ProcessObject = rw rw.write() def onReportEnd(self, evt): """Will be called only if the user didn't cancel; you could also bind to ReportCancel to set a flag, but this seemed cleaner.""" print "report end" reportUtils.previewPDF("invoice.pdf") dApp(MainFormClass=ReportingForm).start()
class _dLabel_test(dLabel): def initProperties(self): self.FontBold = True self.Alignment = "Center" self.ForeColor = "Red" self.Width = 300 self.Caption = "My God, it's full of stars! " * 22 self.WordWrap = False if __name__ == "__main__": from dabo.dApp import dApp class LabelTestForm(dabo.ui.uiwx.dForm): def afterInit(self): self.Caption = "dLabel Test" pnl = dabo.ui.dPanel(self) self.Sizer.append1x(pnl) sz = pnl.Sizer = dabo.ui.dSizer("v") sz.appendSpacer(25) self.sampleLabel = dabo.ui.dLabel(pnl, Caption="This label has a very long Caption. " * 20, WordWrap=False) self.wrapControl = dabo.ui.dCheckBox(pnl, Caption="WordWrap", DataSource=self.sampleLabel, DataField="WordWrap") sz.append(self.wrapControl, halign="center", border=20) sz.append1x(self.sampleLabel, border=10) self.update() dabo.ui.callAfterInterval(200, self.layout) app = dApp(MainFormClass=LabelTestForm) app.start()
if biz.NumberOfGames > 0: if not dabo.ui.areYouSure(message=_( "Are you sure you want to reset your statistics?"), title=_("Reset Statistics"), defaultNo=False, cancelButton=False): return else: biz.resetStats() def _getBizobj(self): return self.PrimaryBizobj def _getScore(self): return self._score def _setScore(self, score): if self._score != score: self._score = score self.scoreLabel.Caption = ustr(score) Bizobj = property(_getBizobj, None, None, _("Reference to the form's bizobj")) Score = property(_getScore, _setScore, None, _("Current score of the game. (int)")) if __name__ == "__main__": dApp(MainFormClass=BubbletForm).start()
dir = evt.EventObject.Orientation[0].lower() if dir == "h": # Change the width of the image self.img.Width = (self.imgPanel.Width * val) else: self.img.Height = (self.imgPanel.Height * val) def onLoadImage(self, evt): f = dabo.ui.getFile("jpg", "png", "gif", "bmp", "tif", "ico", "*") if f: self.img.Picture = f def onResize(self, evt): self.needUpdate = True def onIdle(self, evt): if self.needUpdate: self.needUpdate = False wd = self.HSlider.Value * 0.01 * self.imgPanel.Width ht = self.VSlider.Value * 0.01 * self.imgPanel.Height self.img.Size = (wd, ht) app = dApp() app.MainFormClass = ImgForm app.start()