Anygui on Zaurus
"Stephen Wilbourne" <[email protected]> Mon, 11 Aug 2003 17:09:56 +1000
| Newsgroups | gmane.comp.python.anygui.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am building a python application using sqlite and anygui on a Sharp Zaurus SL-5500. As you are probably aware, the Zaurus uses Qtopia (Qt/Embedded) for its gui. I have needed to make a few 'tweaks' to the anygui backend file 'qtgui.py' in order to make things work, or work better, on the Zaurus. Listed below are all the changes I have made. Perhaps you can find a way to optionally include them in the qtgui.py file, or perhaps in a separate backend file.
Please be aware that this is my first attempt at python programming, so you may find my changes clumsy. They do seem to work however!
Keep up the good work. I am very impressed with Anygui. It has enabled me to start programming on the Zaurus - I found the Qtopia documentation somewhat overwhelming and very difficult to work out where to begin.
I also tried loading python, sqlite and anygui on a W2000 box. I copied across my work-in-progress application and the sqlite database file. It worked first time. I was simply amazed.
Here's what I have tweaked:
1. To make the application run as a window that puts an icon on the taskbar, and that you can return to by selecting the icon:
- at the top of the program, add:
from qtpe import QPEApplication
- throughout the program, change all references to 'QApplication' to 'QPEApplication'
- at the end of the program, immediately before the line 'qApp.exec_loop()' add:
if self._windows:
self.showMainWidget(self._windows[0]._qt_comp)
I was unable to get multiple windows to behave correctly. If you moved to another application and returned, you always got the first window. To overcome this I have written everything in one window, and use 'visible' and 'refresh' to change the view.
2. In a listbox, I needed the signal to only be sent when the line was actually selected, not when it was highlighted. Otherwise you could not use the Zaurus arrow keys to move down to an item and press the centre key to select. The downside to this is that if you use the stylus, you need to double-press to make the selection.
I changed this line:
qApp.connect(self._qt_comp, SIGNAL('highlighted(int)'),\
to:
qApp.connect(self._qt_comp, SIGNAL('selected(int)'),\
3. In a text field, the enter key event was not sent if the hardware 'OK' button was used, or the centre key in the arrows, and also not if the return 'key' was used in the 'jumpx' virtual keyboard (which I use in preference to the 'qwerty' virtual keyboard.)
I discovered that Qtopia has a 'returnedPressed' signal and that this is sent by all the return key options. To use this I commented out these lines:
if int(event.key()) == 0x1004: #Qt Return Key Code
send(self, 'enterkey')
and added this into the 'def _ensure_events(self):' under 'TextBase':
qApp.connect(self._qt_comp, SIGNAL('returnPressed()'),\
self._qt_return_key_handler)
I also added:
def _qt_return_key_handler(self):
send(self, 'enterkey')
4. In a text area, I wanted word-wrap to work, so I added this at the end of the 'def _ensure_selection(self):' under 'TextArea':
self._qt_comp.setWordWrap(1)
Regards,
Stephen Wilbourne
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01