[Panel-devel] PyQt - Check boxes - Qt Designer

Matt matt-lists at comnet.net.nz
Tue Jul 26 22:12:16 CEST 2005


Hello again,

I have hit another snag, and was wondering if you would be able to help me 
again.  If not, let me know, and I'll take the hint.

I'm trying to launch my application from within another python script.  I have 
a .py file called test_gui.py, which subclasses the actual pyqt application.  
It looks like:


#!/usr/bin/python

from qt import *
from lwp_config import *
import sys

if __name__ == "__main__":
    app = QApplication(sys.argv)
    f = lwp_config()
    test = 0
    f.general_units_metric.setChecked(test)
    f.show()
    app.setMainWidget(f)
    app.exec_loop()

However, I want to launch it from within another python application, and I 
thought I could just use the import statement, and treat the application as 
an object, I use this code:

    from qt import *
    from lwp_config import *
    import sys
    app = QApplication(['test'])
    f = lwp_config()
    test = 0
    f.general_units_metric.setChecked(test)
    f.show()
    app.setMainWidget(f)
    app.exec_loop()

I've put ['test'] in the QApplication statement, because it requires an 
argument, which appears needs to be a list.  HOwever, when I do this I get an 
error:

QApplication: There should be max one application object

Are you able to give me any hints on how to launch the application by treating 
it as an object from another script?

Any help would be appreciated.

Regards

Matt

On Tue, 26 Jul 2005 00:01, Ahmed Aït Mouss wrote:
> Hi,
>
> You can use subclassing. Create your dialog in QtDesigner and name it,
> say MyDialogBase. Then generate the .py file and subclass from it
> MyDialog and add any code you want to MyDialog.
>
> On 7/25/05, Matt <matt-lists at comnet.net.nz> wrote:
> > Hello,
> >
> > I know this is probably off-topic, but this seemed like a good place to
> > ask - knowledgeable qt people.  I'm trying to impliment a PyQt based
> > configuration gui for liquid weather ++, and I've got some of (at least
> > what seem to me) the more complex stuff done - like searching and
> > displaying location codes from within the gui, but I'm stuck on a very
> > basic point.
> >
> > How can I dynamically specify whether a checkbox is on or off when the
> > configuration dialog is first called.  Obviously I want the status of
> > checkboxes and radiobuttons to reflect the current configuration state.
> >
> > I can see that this would be done by passing arguments to the dialog
> > when it's called, and I can see that you would use the setChecked()
> > method to set it.  However, the problem is how to specify what goes in
> > the () bit in Qt Designer.  All I can see in the "Properties" area in Qt
> > Designer for specifying whether a checkbox is checked, is a true/false
> > option.  Is there any way to specify something else from with Qt
> > Designer?  I could hand code it in once I've compiled the .py file from
> > the .ui file, but this will get clobbered every time I want to change
> > the .ui file.  I'd rather avoid that.
> >
> > Anyone able to help?
> >
> > Matt
> >
> > _______________________________________________
> > Panel-devel mailing list
> > Panel-devel at kde.org
> > https://mail.kde.org/mailman/listinfo/panel-devel
>
> _______________________________________________
> Panel-devel mailing list
> Panel-devel at kde.org
> https://mail.kde.org/mailman/listinfo/panel-devel

-- 
Regards

Matt


More information about the Panel-devel mailing list