473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

shoving a [pygame] up your [gtk]!

My project:
I'm working on a game, where in the ui, it takes the pygame window, and
shoves it into a gtk2 socket widget. (gtk2 widgets are generated with
glade, with the exception of the socket widget, which is manualy added
into a window)

My problem:
Since adding the gtk half, it is realy slow. I can make one or the
other update realy fast, or I can make it so the pygame window/widget
gets a fluctuation in framerate between realy good, then realy bad,
repeat.
I've narrowed down my problem a bit to my events loop.

Here's a simplified version of the events loop:

while True:
gtk.main_iteration(block=False)
game_board.clock.tick(75)
game_board.frame()

game_board is a class defining pygame/opengl code that produces the
pygame window, and a simple game engine (its actualy a place holder
untill I can make it run full speed. think of something with the
sophistication of the pygame chimp example, or a opengl hello world).
The same unmodified engine (pure pygame/opengl, no gtk2) works fine.

game_board.frame() performs some game logic tasks, and updates the
pygame display. It also handles some keyboard inputs, but only grabs
the latest one on the pygame stack.
So here's the problem sumary, as far as I can gather:
What I think is happening is that gtk.main_iteration(block=False) works
through every event in the queue untill there aren't any, THEN the
pygame event loop briefly fires, checks one or two events from the
pygame queue, and the loop repeats.
(An intresting varriation to the loop above only allowed
gtk.main_iteration to run when the pygame framerate is above 60... this
resulted in the two taking turns monopolising cpu, heh)

Here's what I think I want to do:
I'm looking for something to the equivalent of processing the one gtk
event (and remove it from it's stack), and then call
game_board.frame(), and have the loop repeate, possibly with some load
balancing to allow multiple gtk events to process if the framerate is
high. However, this is where I've hit a wall.

So here we go.

If I'm correct in my assumptions, how can I break down gtk.main even
further?

If I'm wrong, advice steering me in the right direction, or a shot in
the head--- both would be appreciated :)

Jul 6 '06 #1
0 1440

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andrea Griffini | last post by:
Just a quick shoot... can I produce a "closed source" program using "core" python, pygame (and eventually psyco), packaging it by using py2exe and a custom installer ? A clear yes/no answer is...
12
by: Marian Aldenhövel | last post by:
Hi, I am trying to make pygame play music on windows. This simple program: import pygame,time pygame.init() print "Mixer settings", pygame.mixer.get_init() print "Mixer channels",...
3
by: Tim Knauf | last post by:
Hi everyone, I'm glad to have found this list. I've written a small script for my own use which, amongst other things, captures mouse click information from a window containing an image. I used...
3
by: devendra_k | last post by:
I want to intigrate the PyGame module with my Python exe, means i DONT want to generate .PYD files separtely rather than that want to put PyGame "c" src with Python workspace of VC project...
2
by: Brent W. Hughes | last post by:
I'm just starting to learn pygame. I write what I think is just about the simplest program that should display a window and then quit. #----------------------------------------------- import sys...
1
by: kjm | last post by:
Hi everyone, I have recently acquired a Logitech Rumble pad to use as an input device. I have been having trouble getting the event que to respond that a button or hat arrow has been pressed. ...
1
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image...
0
by: Julian Snitow | last post by:
Here is a more visual example of the technique presented in Logan Koester's article, "Live Coding in Python" (http://www.logankoester.com/mt/2006/07/live_coding_with_python_1.html). It's very...
11
by: dynamo | last post by:
Hi guys i have come again with more problems.This time it has to do with pygame.The following code does not give any error messages but it does not do what it is supposed to do either.the code is a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.