tkSimpleDialog.Dialog.ok calls Cancel
rantingrick at gmail.com
Mon Apr 4 17:23:02 EDT 2011
On Apr 4, 2:06 pm, Matt H <mghe... at gmail.com> wrote:
> I am subclassing tkSimpleDialog.Dialog as a (sqlite) database front-
> end. This parent dialog opens a number of child dialogs to propagate
> sub-tables (like sub-forms in OOo). These subforms write their input
> into the database (INSERT...)
> The parent dialog then either commits or rolls-back transactions based
> on whether the user clicks ok or cancel. This ensures that if
> something is written to the db in a subform, that it doesn't stay in
> the database if the user chooses cancel (the rollback transaction code
> is in cancel).
> I have everything working except for the fact that python
> tkSimpleDialog.ok calls tkSimpleDialog.cancel to clean up, which means
> all of my transactions get cancelled (even if the user clicks ok). Is
> there a way to do this without re-implementing or copying the
> tkSimpleDialog.Dialog ok and cancel methods entirely?
> In other words, how do I make OK not execute cancel?
The ok and cancel methods are just a few lines of code for crying out
loud. And besides, you must have inherited from this class anyway to
create your custom dialog. If copy paste is not working for you then i
would suggest building a better light bulb. Tesla did it (and one-
upped that old fart and cheat Edison) so why can't you?
PS: And besides, the tkSimpleDialog class was ill conceived from day
one. Search the archives for my discussions on the pitfalls of this
code and my suggestions for curing (some) the many problems contained
PPS: Not to say that a modal dialog that self closes is a design flaw
More information about the Python-list