maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Some Python and Qt questions (https://talk.maemo.org/showthread.php?t=53156)

giannoug 2010-05-20 11:12

Some Python and Qt questions
 
The easiest way to make applications for the N900 is Python and Qt. I'm pretty fluent in Python and programming in general but I think PyQt for Maemo lacks something really important, tutorials and guides.

I have some questions that couldn't be answered with Wiki and Forum searching. I'm planning to make a Wiki page with all the information for a starter, from Qt designer to deb packaging with the information this thread gathers.

Let's assume we are using Qt designer and a simple text editor.

What size should be set to the form? (I've seen 800x400 and 800x425)

How to make the compoments fill the form?

How can you use pyuic4 to output a file that you can include in your main python program?

How can you center (horizontal and vertical) elements?

Feel free to ask your own questions. More will be added, I can't remember all the problem I faced now :o
Thanks for all the answers!

gri 2010-05-20 11:49

Re: Some Python and Qt questions
 
Use the layouts and you don't have to care about placements, screen sizes etc.
Have seen a lot projects where people are setting control positions by hand! Please never do this! :)
Take a look at QVBoxLayout, QHBoxLayout etc. - they all can be used and tested in Qt Designer.

All your questions could be answered when someone makes a "How to use the Qt Designer with layout" wiki entry if it doesn't already exist.

clasificado 2010-05-20 12:07

Re: Some Python and Qt questions
 
Take in account that PyQt is considered a thin layer on top of QT, so if you want pyqt tutorials youll get a mix of technical questions about how to improve that layer, and not the application developing thng.

for example, points 1, 2 and 4 matters to QT and no PyQt directly, because are concepts, and belong to QT

Dont consider this as a rule, its just a guide

giannoug 2010-05-20 12:41

Re: Some Python and Qt questions
 
Quote:

Originally Posted by clasificado (Post 667524)
Take in account that PyQt is considered a thin layer on top of QT, so if you want pyqt tutorials youll get a mix of technical questions about how to improve that layer, and not the application developing thng.

for example, points 1, 2 and 4 matters to QT and no PyQt directly, because are concepts, and belong to QT

Dont consider this as a rule, its just a guide

True, but in order to design the UI you need Qt specific tools etc ;)

Thanks for the comments guys, I found some information and answers to some of my questions. I'm going to make a Wiki page soon.

Nyrath 2010-05-20 18:27

Re: Some Python and Qt questions
 
Quote:

Originally Posted by giannoug (Post 667433)
How can you use pyuic4 to output a file that you can include in your main python program?

From the command line, you have to invoke pyuic4 using the form:
pyuic4 uiFile -o pythonFile

For example, say in directory c:\myProjects\textEditor you had a Qt Designer file called myEdit.ui and you were developing in a Windows environment. You'd invoke the Windows Command Prompt, and type in the following:

Code:

cd c:\myProjects\textEditor
pyuic4 myEdit.ui -o myEditUI.py

You could then use myEditUI.py in your PyQt project. I use the name *UI.py out of habit because that was in the documentation, but you can use any name you want.

I sometimes use a little python program to automate this, if I have lots of *.ui files. Create the following python script
Code:

import os, sys, glob
   
fileList = glob.glob('*.ui')
for fileName in fileList:
    theCommand = "pyuic4 %s -o %sUI.py" % (fileName, fileName[:-3])
    os.system(theCommand)

and save it as BatchPyuic4.py
Copy it into the folder with your *.ui files. From the command line, type
Code:

cd c:\myProjects\textEditor
python BatchPyuic4.py

It will find all your *.ui files, run pyuic4 on them, and save them as *.ui.py


All times are GMT. The time now is 06:29.

vBulletin® Version 3.8.8