473,226 Members | 1,346 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,226 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 1436

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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.