Author Topic: Pyqt Application Setup  (Read 4789 times)

geojeff

  • Newbie
  • *
  • Posts: 4
    • View Profile
Pyqt Application Setup
« on: March 18, 2005, 11:37:11 am »
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
Zaurus 5500
Sharp ROM 3.13
Python/PyQt

TimW

  • Sr. Member
  • ****
  • Posts: 296
    • View Profile
Pyqt Application Setup
« Reply #1 on: March 18, 2005, 12:00:51 pm »
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.

jh

  • Full Member
  • ***
  • Posts: 115
    • View Profile
    • http://
Pyqt Application Setup
« Reply #2 on: March 18, 2005, 01:23:39 pm »
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: [Select]
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: [Select]
a = QPEApplication([sys.argv[1:])
among other things, it just never worked right.  

jason
« Last Edit: March 18, 2005, 01:24:51 pm by jh »

geojeff

  • Newbie
  • *
  • Posts: 4
    • View Profile
Pyqt Application Setup
« Reply #3 on: March 18, 2005, 01:31:22 pm »
- 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!
Zaurus 5500
Sharp ROM 3.13
Python/PyQt