User:Henkka
m (Reverted edits by 85.196.183.162 (Talk) to last revision by sixwheeledbeast) |
m (Reverted edits by 89.229.151.58 (Talk) to last revision by sixwheeledbeast) |
||
(One intermediate revision not shown) |
Latest revision as of 09:08, 13 November 2020
--- Orginal http://talk.maemo.org/showthread.php?t=43663 Fatalsaint tutorial 2 http://talk.maemo.org/showpost.php?p=515218&postcount=59 Mikec calculator http://talk.maemo.org/showpost.php?p=516874&postcount=69 attila about pyqt install http://talk.maemo.org/showpost.php?p=515107&postcount=45 Fatalsaint more http://talk.maemo.org/showpost.php?p=514988&postcount=29 fatalsaint about IDE http://talk.maemo.org/showpost.php?p=516911&postcount=75
Contents |
[edit] Qt Designer/Python for Windows XP in 30 Mins
This is guide for noobs who would like to get started in Qt development using Python on Windows XP. The great news about using Python is there is no need to install the Maemo SDK. Python runs on Windows, MAC and Linux as is, and it's just a matter of copying your Python Scripts to your N900 and run.
[edit] Install the Tools
- Get Python 2.6 from Python.org http://python.org/download/releases/2.6.4/
This will install the Python interpreter and associated tools. Access from your start menu:
- Get the Binary Packages for PyQt from Riverbank computing http://www.riverbankcomputing.co.uk/software/pyqt/download
Select the Python 2.6 version which is the latest version compatible with Python on the N900. This will install a number of tools, but in particular the ones we are interested in for this Tutorial.
- PyQt 4.7 The Python Qt bindings (note 4.7 is not the Qt Release version).
- Qt4 Designer , the GUI editor and layout manager for Qt GUIs.
- PyUIC4 , Converts your Qt Designer files to PyQt.
When you have this package installed you will have an entry in your start menu like this
Let's do a quick hello world that uses the above tools and links it all together.
[edit] Create UI with Qt Designer
On Your Desktop machine
- Qt Designer from your start Menu.
- Create a Main Window Form and set its size to 800x400
- Add a Label Widget, set the font to a 24 point, resize as needed.
- Double click on the Label Widget to change its name to Hello World ! Use Control R to see how it will look.
- Add buttons text and other widgets as you want by drag and drop from the widget menu.
- Now save your form. File->Save As helloworld.ui
[edit] Generate your Python code
Open a command window from your start menu->accessories (also winkey+r type cmd) and cd into the directory where you stored the ui file, and type in the following.
pyuic4 -x helloworld.ui -o helloworld.py
the -x generates additional code to allow you to test the ui element the -o tells it where to store the python "executable".
You now have a full python Qt4 GUI application ready to rock!!
Just double Click your helloworld.py file in the file manager and presto you have your first PtQt app up and running.
[edit] Deploy to your N900
Make sure you have installed Python and PyQt on your n900. Easiest way of doing this is to install the PyQt examples and documentation package from the application manager. This will pull in all the dependencies that you will need. Don't forget you will need to enable extras development repository.
To get full file system access follow guide Here. ( this method uses WinSCP to do a secure copy to N900)
After setting up your N900 and Windows run WinSCp and enter your ip address and root login details.
To query your N900's ip address run in terminal (sudo gainroot command comes with package rootsh):
$ sudo gainroot # ifconfig | grep inet
You will get a GUI to SCP like this. make sure that you drop files to the /opt directory on your N900
[[Image: ]]
- Drag and drop files from your desktop to your N900.
- Copy your helloworld.py file to your N900 /home/opt directory
Once your helloworld.py file is on your opt directory on your n900 you can execute it from the Xterm: (run as user)
$ python helloworld.py
[[Image:]]
If your helloworld does not have the look and feel of Fremantle make sure that you have installed latest PyQt from the application manager (Thanks Atilla)
[edit] Connecting UI to your Application
OK now that you have done your first prog, you will want to create an app that actually does something with the UI. Jump to Fatalsaints post in this thread for your next tutorial
http://talk.maemo.org/showpost.php?p=515218&postcount=59
[edit] Integrating into a Main Program
The above technique will allow you to prototype quickly and let you play with the QT Designer. However you should not edit the python file generated by pyuic4 (why not?). To build a real application you want to create a Main.py programme that has your gui generated file included. First generate the file without the -x option in windows command window.
pyuic4 helloworld.ui -o helloworld.py
Now we create a Main.py program that calls the generated file.
Sample Main.py (may not work depending what you called your form)
==============Main.py================================== #!/usr/bin/env python import sys #Now we include our helloworld.py generated from pyuic4. from helloworld import * # We instantiate a QApplication passing the arguments of the script to it: app = QtGui.QApplication(sys.argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() # Now we can start it. sys.exit(app.exec_()) ===================================================
Now just run the main.py from your n900
python main.py
Using PySide
Pyside is not quit ready for Windows yet (confusing what is this?)
Bringing it all together into a Graphical IDE
Now you have your helloworld working it's time to dive into a full-blown IDE(Integrated development environment) (Wiki) and do a serious example.
First we need to install an IDE that will pull all of our tools together. Eric4 works really well with Qt Designer. Install from here
http://eric-ide.python-projects.org/
Using eric4 build your own browser in an Hour!! Heres the tutorial
http://eric-ide.python-projects.org/tutorials/MiniBrowser/index.html
Additional Resources
some other tutorials I found helpful
http://www.rkblog.rk.edu.pl/w/p/introduction-pyqt4/
http://lateral.netmanagers.com.ar/stories/BBS47.html
And the Qt4 Design manual http://doc.trolltech.com/4.0/designe...component.html
The Maemo Python Wiki Pages
- This page was last modified on 13 November 2020, at 09:08.
- This page has been accessed 10,649 times.