PyQt question

Janos Blazi jblazi at hotmail.com
Mon Sep 17 23:33:29 CEST 2001


I am playing with PyQt on Win2K. I have translated the following small
program from the Qt tutorial into Python:

#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qvbox.h>

int main( int argc, char **argv )
{
    QApplication a( argc, argv );

    QVBox box;
    box.resize( 200, 120 );

    QPushButton quit( "Quit", &box );
    quit.setFont( QFont( "Times", 18, QFont::Bold ) );

    QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) );

    a.setMainWidget( &box );
    box.show();

    return a.exec();
}

and the translation is

#
# hello1.py
#
import sys
from qt import *

app=QApplication(sys.argv)

box=QVBox()
box.resize(200,100)
quit=QPushButton("Quit", box)
#quit.setFont(QFont("Times", 18, QFont.Bold))
quit.connect(quit,SIGNAL('pressed()'),app,SLOT('quit()'))
app.setMainWidget(box)
box.show()
app.exec_loop()

Now the problem is that they say in the tutorial:
"The button no longer fills the entire widget. Instead, it gets a "natural"
size. This is because there is now a new top-level widget, which uses layout
management to set a good size and position for the button."

But when I start the program the button is as wide as the entire widget and
even resizing it does not help. Can anybody tell me, why?

J.B.







-----=  Posted via Newsfeeds.Com, Uncensored Usenet News  =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
 Check out our new Unlimited Server. No Download or Time Limits!
-----==  Over 80,000 Newsgroups - 19 Different Servers!  ==-----



More information about the Python-list mailing list