Re: [PyKDE] Issue with QDialog and lifetime

2005-07-25 Thread Giovanni Bajo
Phil Thompson <[EMAIL PROTECTED]> wrote: >>> James proposed this solution: >>> >>> def slotWhatever(self): >>>dlg = MyModalDialog(self) >>>sip.transfer(dlg, 0) >>>if dlg.exec_loop() == QDialog.Accepted: >>>return dlg.data() >>>return None >>> >>> and then proposed to hardc

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-25 Thread Phil Thompson
On Thursday 07 July 2005 12:27 pm, Giovanni Bajo wrote: > Phil Thompson <[EMAIL PROTECTED]> wrote: > >> The problem is that the idiomatic way of using modal dialogs in C++ is > >> to create local variables, which gets destroyed when their scope > >> finishes (when > >> the function exits). Moreover

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-07 Thread Giovanni Bajo
Phil Thompson <[EMAIL PROTECTED]> wrote: > This would seem to be an untypical way of doing things - is anybody going > to shout that their 5 million line application relies on this technique? It looks like a *very* untypical way of doing things -- at least for modal dialogs. I believe 99.999% of

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-07 Thread Phil Thompson
> On Thursday 07 July 2005 15:01, Phil Thompson wrote: > >> The original proposal would cause problems in the following scenario... >> >> 1. One or more modal dialogs that are hidden when not used, rather than >> being re-created each time they are needed. >> >> 2. The dialogs are Python sub-classe

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-07 Thread Toby Dickenson
On Thursday 07 July 2005 15:01, Phil Thompson wrote: > The original proposal would cause problems in the following scenario... > > 1. One or more modal dialogs that are hidden when not used, rather than > being re-created each time they are needed. > > 2. The dialogs are Python sub-classes of QD

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-07 Thread Phil Thompson
> Phil Thompson <[EMAIL PROTECTED]> wrote: > >> 1. Either add an optional parameter to exec_loop() which does the >> transfer >> or have exec_loop_and_transfer() (or something less of a mouthful). At >> least that way it won't break existing code. > > I like this solution. Then I can do: > > class

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-07 Thread Giovanni Bajo
Phil Thompson <[EMAIL PROTECTED]> wrote: > 1. Either add an optional parameter to exec_loop() which does the transfer > or have exec_loop_and_transfer() (or something less of a mouthful). At > least that way it won't break existing code. I like this solution. Then I can do: class QDialog(QDialog

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-07 Thread Phil Thompson
> Phil Thompson <[EMAIL PROTECTED]> wrote: > >>> The problem is that the idiomatic way of using modal dialogs in C++ is >>> to >>> create local variables, which gets destroyed when their scope finishes >>> (when >>> the function exits). Moreover, the dialogs have to be children of > whatever >>> wi

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-07 Thread Giovanni Bajo
Phil Thompson <[EMAIL PROTECTED]> wrote: >> The problem is that the idiomatic way of using modal dialogs in C++ is to >> create local variables, which gets destroyed when their scope finishes >> (when >> the function exits). Moreover, the dialogs have to be children of whatever >> widgets they are

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-07 Thread Phil Thompson
> Phil Thompson <[EMAIL PROTECTED]> wrote: > >> Does anyone see a potential problem with exec_loop() transferring >> ownership of the dialog instance back to Python? > > Well, which C++ API would you intend to call to achieve this? We > still > need the QDialog to keep its p

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-06 Thread Giovanni Bajo
Phil Thompson <[EMAIL PROTECTED]> wrote: > Does anyone see a potential problem with exec_loop() transferring > ownership of the dialog instance back to Python? Well, which C++ API would you intend to call to achieve this? We still need the QDialog to keep its parent widget b

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-06 Thread Phil Thompson
On Wednesday 06 July 2005 4:32 pm, Giovanni Bajo wrote: > James Emerton <[EMAIL PROTECTED]> wrote: > >>> Does anyone see a potential problem with exec_loop() transferring > >>> ownership of the dialog instance back to Python? > >> > >> Well, which C++ API would you intend to call to achieve this? W

Re: [PyKDE] Issue with QDialog and lifetime

2005-07-06 Thread Giovanni Bajo
James Emerton <[EMAIL PROTECTED]> wrote: >>> Does anyone see a potential problem with exec_loop() transferring >>> ownership of the dialog instance back to Python? >> >> Well, which C++ API would you intend to call to achieve this? We still >> need the QDialog to keep its parent widget because it

Re: [PyKDE] Issue with QDialog and lifetime

2005-06-23 Thread James Emerton
On 6/23/05, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > > Does anyone see a potential problem with exec_loop() transferring > > ownership of the dialog instance back to Python? > > Well, which C++ API would you intend to call to achieve this? We still need > the > QDialog to keep its parent widge

Re: [PyKDE] Issue with QDialog and lifetime

2005-06-23 Thread Giovanni Bajo
James Emerton <[EMAIL PROTECTED]> wrote: > Sorry to be digging up such an old thread, but my mind keeps coming > back to this one. Yeah, me too... I still have not conceived an elegant solution for this problem. BTW, I also found out that this: dlg = MyDialog(self): try: dlg.exec_loop() fina

Re: [PyKDE] Issue with QDialog and lifetime

2005-06-22 Thread James Emerton
Sorry to be digging up such an old thread, but my mind keeps coming back to this one. Does anyone see a potential problem with exec_loop() transferring ownership of the dialog instance back to Python? James On 5/25/05, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > Hello, > > while the QObject obje

Re: [PyKDE] Issue with QDialog and lifetime

2005-05-26 Thread Giovanni Bajo
Toby Dickenson <[EMAIL PROTECTED]> wrote: >> Notice that WDestructiveClose does not collect the Python object (of >> course). So you can easily do something like: >> >> class MyDialog(QDialog2): >> # bla bla >> >> def accept(self): >> self.value = self.lineedit.text() >> >> and

Re: [PyKDE] Issue with QDialog and lifetime

2005-05-26 Thread Toby Dickenson
On Thursday 26 May 2005 13:16, Giovanni Bajo wrote: > Toby Dickenson <[EMAIL PROTECTED]> wrote: > > >> class QDialog2(QDialog): > >>def __init__(self, parent=0, name=0, modal=False, flags=0) > >>QDialog.__init__(self, parent, name, modal, flags | > >> Qt.WDestructiveClose) > > Actuall

Re: [PyKDE] Issue with QDialog and lifetime

2005-05-26 Thread Giovanni Bajo
Toby Dickenson <[EMAIL PROTECTED]> wrote: >> class QDialog2(QDialog): >>def __init__(self, parent=0, name=0, modal=False, flags=0) >>QDialog.__init__(self, parent, name, modal, flags | >> Qt.WDestructiveClose) Actually, for my project, I'm better off with: class QDialog2(QDialog):

Re: [PyKDE] Issue with QDialog and lifetime

2005-05-26 Thread Toby Dickenson
On Thursday 26 May 2005 11:24, Giovanni Bajo wrote: > class QDialog2(QDialog): >def __init__(self, parent=0, name=0, modal=False, flags=0) >QDialog.__init__(self, parent, name, modal, flags | > Qt.WDestructiveClose) That works, but Im not sure I would recommend it. It leads to a bigge

Re: [PyKDE] Issue with QDialog and lifetime

2005-05-26 Thread Giovanni Bajo
Toby Dickenson <[EMAIL PROTECTED]> wrote: > On Wednesday 25 May 2005 16:13, Giovanni Bajo wrote: > >> So, I don't see any easy way to take care of this automatically. One >> has to remember to manually destroy the dialog calling deleteLater > > Yes. My PyQt idiom for running a dialog is: > > dl

Re: [PyKDE] Issue with QDialog and lifetime

2005-05-26 Thread Toby Dickenson
On Wednesday 25 May 2005 16:13, Giovanni Bajo wrote: > So, I don't see any easy way to take care of this automatically. One has to > remember to manually destroy the dialog calling deleteLater Yes. My PyQt idiom for running a dialog is: dlg = WhateverDlg(parent) try: ok = dlg.ex

Re: [PyKDE] Issue with QDialog and lifetime

2005-05-25 Thread John Ridley
--- Giovanni Bajo <[EMAIL PROTECTED]> wrote: > Hello, > > while the QObject object model is pretty clear to me, and I also > understand > the way it was translated to Python, today I stumbled upon an issue > which I > hadn't realized before: > > class MyMainWindow(QMainWindow): > def about(s

[PyKDE] Issue with QDialog and lifetime

2005-05-25 Thread Giovanni Bajo
Hello, while the QObject object model is pretty clear to me, and I also understand the way it was translated to Python, today I stumbled upon an issue which I hadn't realized before: class MyMainWindow(QMainWindow): def about(self): dlg = MyAboutDlg(self) dlg.exec_loop() Th