[PyKDE] Two applications

Andreas Pakulat apaku at gmx.de
Mon May 8 15:20:15 BST 2006


On 08.05.06 14:58:58, Behnam Kamrani wrote:
> I'm quite a Pyqt newbie and have problem how to construct my code. My
> code has a main dialog box and its main looks like below. The user
> enters some data into the fields of this dialog box and then after
> pressing OK button, the code do some calculations and shows the
> results in a table. I have defined the table itself as a class in a
> separate file.
> 
> Here I have at leasta 2 problems:
> 
> 1) How should I display the table?

Oh boy, this does not look like you're a PyQt or Qt newbie, this looks
like a programmer newbie ;-) (No offense meant)

> 2) The table has some QComboTableItem. The user should select and
> press the OK button so that some new activities (like writing into
> files) starts. My second problem is how to creat an "OK button" in a
> table?

You don't, you create a subclass of QWidget, add a layout to it and then
add the table and a button to that layout.

You should start by reading the PyQt documentation and try to understand
the examples. Eventually also the Qt documentation (the overviews
especially) will tell you some things.

The problem in your code is that your dialog is the only thing "shown",
i.e. after you close it the application exits. This is not good of
course. If the dialog should really be the main widget it should have a
member variable that holds an instance of the table class and calls
show() on that one before the dialog is closed. 

But from your description you may be better off to create the table at
first and in it's construct execute the dialog and let the user do it's
input. After that you can go on initializing the table. In the main
script you would then create a table instance, make it the main widget
and call it's show method.

Andreas

-- 
Courage is your greatest present need.




More information about the PyQt mailing list