I'm working on a python project where I have a pygame window, but I'd also like to have a PyGTK window next to it at the same time with information about objects inside the pygame window. However, when I start the PyGTK window the pygame window freezes until the PyGTK one is closed, even if I do all the PyGTK stuff in a thread.
Important pieces of code from my project:
import thread
import pygtk
import gtk
class SelectList:
    def __init__(self, parent):
        self.parent = parent
        self.initWindow()
        self.main()
    def main(self):
        gtk.main()
    def initWindow(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", self.destroy)
        self.window.set_title("Selection info")
        self.window.set_position(gtk.WIN_POS_CENTER)
        # junk that I didn't bother including in this example
        # ...
        self.window.show_all()
    #This is only connected to the main window
    #When this is called it iterates through every toplevel window and closes it
    def destroy(self, widget, data=None):
        for i in gtk.window_list_toplevels():
            i.destroy()
        gtk.main_quit()
def openList(instance):
    SelectList(instance)
class Maker:
    def __init__(self):
        # more stuff that I won't include
        pass
    def logic(self, newkeys):
        if K_l in newkeys:
            thread.start_new_thread(openList, (self, ))
    def main(self):
        while True:
            # pygame stuff, including sending all new key presses to logic method
            pass
                I don't know enough about gtk or threading in python to really help but perhaps you could use this as a work around pyGame within a pyGTK application
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With