OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Pyqt Application Setup
geojeff
post Mar 18 2005, 08:37 AM
Post #1





Group: Members
Posts: 4
Joined: 9-March 05
Member No.: 6,601



I've followed the helpful instructions here for using python (kopsis) and pyqt on the zaurus (5500), and have found by searching the forum postings how to use QPEApplication instead of QApplication (after about a month of development without a clue that it existed) and now my app is looking nice. It is for doing bird counts and includes a working GPS interface, using elements of the python code from gpsd and from pygps. One problem remains though: how to properly setup my app so that it can be restored after it looses focus, and how to give it a proper icon. I found postings that get close, it seems, and did the following:

1) put a script in /opt/QtPalmtop/bin called myapp that contains the line

"python /mnt/card/dev/myapp.py"

2) added the line

sys.argv[0] = "myapp"

just above the line

a = QPEApplication(sys.argv)

The startup script works, but, if my app looses focus when another app is run, clicking the terminal icon only brings up the terminal console where i fired the script.

So, I am asking for general help on the full steps needed to make a python/pyqt program act like a normal application, or at least to solve the focus problem. I don't know if it matters for this, but my rom is the sharp 3.13 version.

BTW, I really enjoy programming with pyqt, after years of Java dev with Swing, but having entered into a limbo on gui development since turning to python in the last couple of years. Nice to discover Qt and pyqt -- good docs and clean api.

Thanks,

Jeff Pittman
Go to the top of the page
 
+Quote Post
TimW
post Mar 18 2005, 09:00 AM
Post #2





Group: Members
Posts: 288
Joined: 8-December 03
From: London, UK
Member No.: 1,065



You need a desktop file in /opt/Qtopia/apps/Applications

The last part of the path corresponds to the tab which the app will appear on so you may want /opt/Qtopia/apps/Games intead, for example.

Have a look at the ones you alread y have in there. They are text based so just catting them at the console will give you some idea of what you need. The minimum is probably

[Desktop Entry]
Exec=myapp.py

You'll need to make myapp.py executable (chmod +x myapp.py) and add the standard

#!/usr/bin/env python

line at the top.

Add an icon line to the desktop file to use an icon other than the default "?" one.
Go to the top of the page
 
+Quote Post
jh
post Mar 18 2005, 10:23 AM
Post #3





Group: Members
Posts: 115
Joined: 20-November 03
Member No.: 968



I had some funny issues with keeping the focus, as well... I tried a few times, then bailed out (got lazy) and ended up doing:

CODE
a = QPEApplication(["pyplay.py"])


Also, my .desktop has Exec=pyplay.py and I have a link to pyplay.py in my path somewhere.

I tried
CODE
a = QPEApplication([sys.argv[1:])


among other things, it just never worked right.

jason
Go to the top of the page
 
+Quote Post
geojeff
post Mar 18 2005, 10:31 AM
Post #4





Group: Members
Posts: 4
Joined: 9-March 05
Member No.: 6,601



- added the .desktop file in /opt/QtPalmtop/apps/Applications (used a script in /opt/Qtopia/bin to call "python /mnt/card/dev/myapp.py")

- found the home for the icons under the pics dir of /opt/Qtopia and added a 32x32 png

- rebooted

And, Presto, I have my normally behaving app.

Thanks!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 25th December 2014 - 12:41 AM