Paul, Wonderful!! Can you post a brief example? I am having trouble using it.
Thanks sooo much! Larry > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Paul McNett > Sent: Tuesday, September 29, 2009 7:14 PM > To: [email protected] > Subject: [dabo-dev] dabo Commit 5442 > > dabo Commit > Revision 5442 > Date: 2009-09-29 16:14:21 -0700 (Tue, 29 Sep 2009) > Author: Paul > Trac: http://trac.dabodev.com/changeset/5442 > > Changed: > U trunk/dabo/dEvents.py > U trunk/dabo/dReportWriter.py > U trunk/dabo/lib/reportWriter.py > U trunk/dabo/ui/uiwx/dReportProgress.py > > Log: > Added ReportCancel event. Determined that the problem with > cancelling the dReportProgress was the modeless/modal problem > on Gtk. Reworked dReportProgress to be a panel instead of a > form, so that the developer can put it whereever they want, > and to surmount the Gtk problem. > > Now, the cancel button works, and will stop writing the > report on the next iteration of the report cursor. > > > > Diff: > Modified: trunk/dabo/dEvents.py > =================================================================== > --- trunk/dabo/dEvents.py 2009-09-29 18:33:02 UTC (rev 5441) > +++ trunk/dabo/dEvents.py 2009-09-29 23:14:21 UTC (rev 5442) > @@ -889,6 +889,10 @@ > appliesToClass = classmethod(appliesToClass) > > > +class ReportCancel(ReportEvent): > + """Occurs when the user cancels the report.""" > + pass > + > class ReportBegin(ReportEvent): > """Occurs at the beginning of the report.""" > pass > > Modified: trunk/dabo/dReportWriter.py > =================================================================== > --- trunk/dabo/dReportWriter.py 2009-09-29 18:33:02 UTC > (rev 5441) > +++ trunk/dabo/dReportWriter.py 2009-09-29 23:14:21 UTC > (rev 5442) > @@ -22,36 +22,46 @@ > There is also a pure-python interface available. > """ > > + def _onReportCancel(self): > + self.super() > + self.raiseEvent(dabo.dEvents.ReportCancel) > + self._hideProgress() > + > def _onReportBegin(self): > self.super() > self.raiseEvent(dabo.dEvents.ReportBegin) > - if self.ShowProgress: > - self._createProgress() > + self._showProgress() > > def _onReportEnd(self): > self.super() > self.raiseEvent(dabo.dEvents.ReportEnd) > - if self.ShowProgress: > - self._hideProgress() > + self._hideProgress() > > def _onReportIteration(self): > - dabo.ui.yieldUI() > self.super() > self.raiseEvent(dabo.dEvents.ReportIteration) > - if self.ShowProgress: > - self._updateProgress() > + self._updateProgress() > > - def _createProgress(self): > - win = self._progressWindow = > dabo.ui.dReportProgress(self.Application.ActiveForm) > - win.updateProgress(0, len(self.Cursor)) > - win.Visible = True > + def _showProgress(self): > + win = self.ProgressControl > + if win: > + win.updateProgress(0, len(self.Cursor)) > + win.Visible = True > + win.Form.fitToSizer() > + dabo.ui.yieldUI() > > def _updateProgress(self): > - > self._progressWindow.updateProgress(self.RecordNumber+1, > len(self.Cursor)) > + win = self.ProgressControl > + if win: > + win.updateProgress(self.RecordNumber+1, > len(self.Cursor)) > + dabo.ui.yieldUI() > > def _hideProgress(self): > - self._progressWindow.close() > - dabo.ui.yieldUI() ## or else a segfault occurs > when the parent dialog is closed > + win = self.ProgressControl > + if win: > + win.Visible = False > + win.Form.fitToSizer() > + dabo.ui.yieldUI() > > def _getEncoding(self): > try: > @@ -79,15 +89,15 @@ > self._homeDirectory = val > > > - def _getShowProgress(self): > + def _getProgressControl(self): > try: > - v = self._showProgress > + v = self._progressControl > except AttributeError: > - v = self._showProgress = True > + v = self._progressControl = None > return v > > - def _setShowProgress(self, val): > - self._showProgress = bool(val) > + def _setProgressControl(self, val): > + self._progressControl = val > > > Encoding = property(_getEncoding, _setEncoding, None, > @@ -102,14 +112,15 @@ > self.ReportFormFile, HomeDirectory will be set > for you automatically. > Otherwise, it will get set to > self.Application.HomeDirectory.""")) > > - ShowProgress = property(_getShowProgress, > _setShowProgress, None, > - _("""Specified whether a default progress > window is shown at runtime. > + ProgressControl = property(_getProgressControl, > _setProgressControl, None, > + _("""Specifies the control to receive progress updates. > > - If True, a progress bar will be shown during > the processing of the report. > - Note that you can provide your own progress > window by binding to the > - dabo.dEvents.ReportIteration event and setting > this ShowProgress property > - to False.""")) > + The specified control will be updated with > every record processed. It must have > + a updateProgress(current_row, num_rows) method. > > + For the default control, use dabo.ui.dReportProgress. > + """)) > + > if __name__ == "__main__": > ## run a test: > rw = dReportWriter(Name="dReportWriter1", > OutputFile="./dRW-test.pdf") > > Modified: trunk/dabo/lib/reportWriter.py > =================================================================== > --- trunk/dabo/lib/reportWriter.py 2009-09-29 18:33:02 UTC > (rev 5441) > +++ trunk/dabo/lib/reportWriter.py 2009-09-29 23:14:21 UTC > (rev 5442) > @@ -972,6 +972,15 @@ > return > obj.setProp(prop, oldval, logUndo=False) > > + def cancel(self): > + """Cancel the report printout on the next > iteration of self.Cursor.""" > + self._cancel = True > + > + def _onReportCancel(self): > + if self.PrintStatus: > + print "Report cancelled." > + sys.stdout.flush() > + > def _onReportBegin(self): > if self.PrintStatus: > print "Report Begin." > @@ -1649,6 +1658,7 @@ > the PDF file will be left open so that > additional pages can be added > with another call, perhaps after creating a > different report form. > """ > + self._cancel = False > self._calcObjectHeights = {} > _form = self.ReportForm > if _form is None: > @@ -2006,6 +2016,9 @@ > # Print the dynamic bands (Detail, GroupHeader, > GroupFooter): > y = None > for cursor_idx, record in enumerate(self.Cursor): > + if self._cancel: > + self._onReportCancel() > + return > _lastRecord = self.Record > self.Record = record > > > Modified: trunk/dabo/ui/uiwx/dReportProgress.py > =================================================================== > --- trunk/dabo/ui/uiwx/dReportProgress.py 2009-09-29 > 18:33:02 UTC (rev 5441) > +++ trunk/dabo/ui/uiwx/dReportProgress.py 2009-09-29 > 23:14:21 UTC (rev 5442) > @@ -1,30 +1,45 @@ > +# -*- coding: utf-8 -*- > import dabo > -from dForm import dBorderlessForm > +if __name__ == "__main__": > + dabo.ui.loadUI("wx") > +from dabo.dLocalize import _ > +from dPanel import dPanel > from dGauge import dGauge > from dLabel import dLabel > from dButton import dButton > > -class dReportProgress(dBorderlessForm): > + > +class dReportProgress(dPanel): > def afterInit(self): > - self.gauge = dGauge(self) > - lblTitle = dLabel(self, Caption="Processing > report...", FontBold=True, FontSize=12) > + ms = self.Sizer = dabo.ui.dBorderSizer(self, > "v", DefaultBorder=5) > + self.gauge = dGauge(self, Size=(75,12)) > + lblTitle = dLabel(self, Caption="Processing > report...", FontBold=True) > butCancel = dButton(self, CancelButton=True, > Caption="Cancel", OnHit=self.onCancel) > - ms = self.Sizer = dabo.ui.dBorderSizer(self, > "v", DefaultBorder=10) > ms.append(lblTitle) > ms.append(self.gauge, "expand") > ms.append(butCancel, alignment="right") > - butCancel.setFocus() > self.fitToSizer() > + self.Visible = False > > - def initProperties(self): > - self.Centered = True > - > def updateProgress(self, val, range): > self.gauge.Range = range > self.gauge.Value = val > self.gauge.refresh() > - dabo.ui.yieldUI() > > def onCancel(self, evt): > - print "cancel" > + evt.stop() ## keep dialogs from automatically > being closed. > + if not self.Visible: > + return > + self.ReportWriter.cancel() > > + > + def _getReportWriter(self): > + self._reportWriter = getattr(self, > "_reportWriter", None) > + return self._reportWriter > + > + def _setReportWriter(self, val): > + self._reportWriter = val > + > + ReportWriter = property(_getReportWriter, > _setReportWriter, None, > + _("""Specifies the dReportWriter instance.""")) > + > > > > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev Searchable Archives: http://leafe.com/archives/search/dabo-dev This message: http://leafe.com/archives/byMID/!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAafA2fnYuPUOMNFpIYnBEQcKAAAAQAAAAzWUO2QnmdUKQ/[email protected]
