Reply
Thread Tools
Posts: 15 | Thanked: 10 times | Joined on Apr 2010
#1
I've made a small demo app with pygtk and cairo at www.erikhk.net/tmp/cairotest.py , press anywhere on the screen and one of the corners of the triangle should move to the point where you pressed. This is really slow though, is it because of gtk, python, cairo or crappy coding?

I tried a pygame app aswell, which is also really slow, much much slower than on the computer; www.erikhk.net/tmp/fysik.py , try dragging a line on the screen and watch the ball get thrown.

Do you get the same results?
 
Khertan's Avatar
Posts: 1,012 | Thanked: 817 times | Joined on Jul 2007 @ France
#2
Hum ... are you kidding ?

Your code will be slow everywhere ... ! try to read some pygame tutorial ...

PyGame isn't slow when used properly. Look at solarwolf, or Vectormine ... it s write in pygame but run well on n900.

gobject.timeout_add(1,self.tick) <- this kind of things is really slow on my computer too !
 
juise-'s Avatar
Posts: 186 | Thanked: 192 times | Joined on Jan 2010 @ Finland
#3
Originally Posted by ErikHK View Post
www.erikhk.net/tmp/cairotest.py
Code:
    gobject.timeout_add(1,self.tick)
I didn't look through your code properly or try it, but it seems that above line will make your code to try to do the whole drawing thing 1000 times in a second. It's highly unlikely that this is what you wanted.

Edit: was pointed out above already.

Generally, when using GUI libraries, you'll only want to invalidate areas that have actually changed.
 
Posts: 15 | Thanked: 10 times | Joined on Apr 2010
#4
well, crappy code then. But it's weird that I don't notice the slowness at all on the computer, at least not on the pygame thing, I suspected though that the gtk thing should be slow on the computer as well.
 
Posts: 15 | Thanked: 10 times | Joined on Apr 2010
#5
juise: sorry, didn't see your reply. I had that timeout value at something like 50 at first, but just tried to make it as low as possible to see if that was the problem. Could the pygtk/cairo thing be really fast if coded properly btw? Pygame can be really fast if I understand you correctly..?
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#6
Originally Posted by ErikHK View Post
well, crappy code then. But it's weird that I don't notice the slowness at all on the computer, at least not on the pygame thing, I suspected though that the gtk thing should be slow on the computer as well.
3GHz CPU and 2GByte of RAM will in many cases make things look ok even if you foul up your code. To then try them on a device like the N900 is actually a good way to see if you've done any stupid mistakes.
 

The Following 2 Users Say Thank You to Joorin For This Useful Post:
Posts: 1,208 | Thanked: 1,028 times | Joined on Oct 2007
#7
Originally Posted by ErikHK View Post
juise: sorry, didn't see your reply. I had that timeout value at something like 50 at first, but just tried to make it as low as possible to see if that was the problem. Could the pygtk/cairo thing be really fast if coded properly btw? Pygame can be really fast if I understand you correctly..?
In pygame case you are probably seeing that the ball moves 10 times faster with your computer that with N900. It's because the computer is 10 times faster. Simulation doesn't take in account the actual (real) time between simulation ticks and there isn't any limit for ticks/second.
 
Posts: 15 | Thanked: 10 times | Joined on Apr 2010
#8
Originally Posted by mikkov View Post
In pygame case you are probably seeing that the ball moves 10 times faster with your computer that with N900. It's because the computer is 10 times faster. Simulation doesn't take in account the actual (real) time between simulation ticks and there isn't any limit for ticks/second.
I actually thought that I had some time limit thing implemented, but now that I've implemented pygame.time.Clock() and use clock.tick(60) I notice a real difference

But I still wonder about the example with cairo and pygtk, could that become smooth in the N900, or do you have to use C or something?
 
Posts: 15 | Thanked: 10 times | Joined on Apr 2010
#9
I have updated the pygame example, and now it seems to be rather fast:
http://www.erikhk.net/tmp/fysik.py
 
Posts: 29 | Thanked: 17 times | Joined on Oct 2009
#10
Quick note: When you use GTK or Cairo from python you are not actually using them "in python". You are calling their C code from python. So the gtk/cairo operations themselves (with the exception of a small amount of binding overhead) are about the same speed as if your app was in C. The python code you write though will run at python speed, which is rather slow
 
Reply

Thread Tools

 
Forum Jump


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