Reply
Thread Tools
Posts: 13 | Thanked: 20 times | Joined on Jun 2010
#11
Use Qt Datatypes

I've had some unicode-relate issues when moving strings between python datatypes and Qt datatypes. Somehow, the unicode stuff would get lost. So, it's likely easiest (At least when you're new to python and Qt) to use QString and QStringList than their pure python counterparts.

If you're not bringing in data from anywhere else, this isn't that big of a deal, but if you're interacting with data from any other source, unicode is a pretty likely scenario these days.

Use Makefiles
I've been developing on both Windows and Linux. I use cygwin on Windows and have my development space mounted via samba/cifs. I use make in cygwin to perform various tasks for me.

Here's the Makefile that I use in my project directory to re-build the ui whenever I need, and tar up my directory and copy it to my n900 when need be.

Note, you need to install the gnu-tar package to reliably untar .tar files. I had a lot of issues doing so until I installed it.

Code:
all:
	echo "Say nothing, Act casual."
	
ui:
	pyuic4 src/ui/src/some_window.ui > src/ui/some_window.py
	
clean:
	find . -type f -name "*.pyc" -print -exec rm -f {} \;

dev: clean
	tar -cvf ~/src.tar src

build: clean
	tar -cvf ~/src.tar src
	scp ~/src.tar developer@n900:/opt/workspace/.
	ssh developer@n900 "rm -rf /opt/workspace/src/"
	ssh developer@n900 "cd /opt/workspace && /opt/maemo/usr/bin/gnu/tar -xvf ./src.tar && rm ./src.tar"
	rm ~/src.tar
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#12
Just to note that, in my experience, locales fail to work with PyQt - QTextCodec.codecForLocale() does not return the correct codec, which also means QString's toLocal8Bit() and fromLocal8Bit() fail.

The python locale stuff works fine, but then you have the joy of converting between QString and python strings (which works perfectly when it does it implicitly, but an explicit conversion seems to go via ASCII unless you specifically tell it to use utf-8 instead).
 
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#13
How come not the following?

Code:
all:
	echo "Say nothing, Act casual."
	
src/ui/some_window.py: src/ui/src/some_window.ui 
	pyuic4 $< > $@

~/src.tar: clean src/ui/some_window.py
	tar -cvf $@ src

ui: src/ui/some_window.py

dev: ~/src.tar

build: ~/src.tar
	scp $< developer@n900:/opt/workspace/.
	ssh developer@n900 "rm -rf /opt/workspace/src/"
	ssh developer@n900 "cd /opt/workspace && /opt/maemo/usr/bin/gnu/tar -xvf ./src.tar && rm ./src.tar"
	
clean:
	find . -type f -name "*.pyc" -print -exec rm -f {} \;

dist-clean: clean
	rm -f src/ui/some_window.py
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 
Posts: 376 | Thanked: 511 times | Joined on Aug 2009 @ Greece
#14
Originally Posted by mikec View Post
might be worth listing all of the apps that are PyQt in the repos. That way you can just look at the actual real live examples here is my starter for 10.

ncalc
nclock
maesynth
maelophone
healthcheck

Lots of python gtk apps which dont get counted
WifiEye and MaeGirls are PyQt apps.

Also, I suggest that you create a wiki page with this information and have this thread for discussion on that. This way everyone will be able to contribute and will be easier to find and read.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#15
I'm not sure why all the hate on threading. I use threads in both pyPianobar and pyRadio with no issues. In both, the actual radio playing or communication with Pandora is in a separate thread so that making urllib or xml calls (or in the case of pyPianobar, running an IO loop to pianobar an external app) do not lockup the UI.

As far as threading safe signal/slots .. I have no problems with my threads sending signals to the main UI method to let it know when to do something.

I personally have had no problems with threads.

That pallet() trick looks nice though, I was current manually reading the current theme's file and pulling out the color code to change my buttons . I'll have to look into pallet().
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#16
Originally Posted by v13 View Post
Also, I suggest that you create a wiki page with this information and have this thread for discussion on that. This way everyone will be able to contribute and will be easier to find and read.
http://wiki.maemo.org/PyQt_Tips_and_Tricks
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 

The Following 5 Users Say Thank You to epage For This Useful Post:
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#17
Originally Posted by epage View Post
http://wiki.maemo.org/PyQt_Tips_and_Tricks
Couple of suggestions. Use this for the lambda trick:

Code:
def notifyMe(foo)
  print foo

f = QPushButton("Click me!")
x = lambda: notifyMe("they call him tim")
self.connect(f, SIGNAL("clicked()"), x)
You don't need the "b" button with a d.close() in the example as it's unrelated to the trick, and may as well show them the "f" button constructor.

Also, attila77 as part of the PyQt4 porting also ported PyQt4 Demo's and documentation packages for examples, which includes the QT example programs ported to Python. I would add that package to the list of example stuff at the bottom.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 

The Following 2 Users Say Thank You to fatalsaint For This Useful Post:
Posts: 13 | Thanked: 20 times | Joined on Jun 2010
#18
Originally Posted by epage View Post
How come not the following?
...snipped...
Because I'm make noob, mostly. At my previous job, I'd modified a lot of their makefiles into more useful ones, but that was over 2 years ago and I just don't work with them anymore (I'm really a SA, the developers at the previous job had no clue how to package their sw in a meaningful way, which made it really difficult to SA the boxes)
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#19
Hang on... these are two things here. Events/signals/slots across multiple threads very much exist in Qt (you do need to know what you're doing, though, and whether you're using a module/class/function that (probably due to performance reasons) requires additional synchronisation - this is very visibly displayed in the Qt docs of each class). GIL issues and blocking Python calls are a completely separate issue - threads are a special story under Python even without Qt.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 

The Following User Says Thank You to attila77 For This Useful Post:
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#20
Originally Posted by attila77 View Post
Hang on... these are two things here. Events/signals/slots across multiple threads very much exist in Qt (you do need to know what you're doing, though, and whether you're using a module/class/function that (probably due to performance reasons) requires additional synchronisation - this is very visibly displayed in the Qt docs of each class). GIL issues and blocking Python calls are a completely separate issue - threads are a special story under Python even without Qt.
Is this true with both QThread and threading.Thread? If so then my documentation I found is out of date and why I'm glad we have this thread.
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 10:08.