bbuggy
bbuggy

Reputation: 25

Python.exe keeps running after closing Gtk.main() when both Gtk and win32ui modules are imported

I run python 2.7.13 on windows 7.
I am creating a window with Gtk (from pygobject 3.18.2).
I also use win32ui (from pywin32 221).

When I import both modules my program runs just fine untill I close it. The window is closing fine, but the python process keeps running and the cmd window that is used to run the script does not return to de cmd prompt.
I have to kill python to get back to the prompt

Here is a simple test script. This does not close proper on my system. If I comment out

#import win32ui

it will close proper

from gi.repository import Gtk
import win32ui

class Window(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self)
        self.connect("destroy", Gtk.main_quit)
        self.show_all()

Window()
Gtk.main()

Looks like a conflict between Gtk and win32ui.
I need win32gui and win32ui for extracting icons from pe files.
What can I do?

Upvotes: 2

Views: 140

Answers (1)

Tristan Gibson
Tristan Gibson

Reputation: 123

On previous versions of PyWin32: https://sourceforge.net/p/pywin32/bugs/609/ https://sourceforge.net/p/pywin32/bugs/636/

import atexit, os

def taskkill_this():
    # kill this process
    current_pid = os.getpid()
    os.system("taskkill /pid %s /f" % current_pid)

atexit.register(taskkill_this)

Appears to be one provided workaround.

Upon further inspection, it appears to be related to pywin32 and Gtk UI event processes clashing. I would recommend using one or the other rather than both if possible or use a taskkill hack like the one above.

I've also noticed that this has happened on Windows 7 workstations in all cases I have seen.

Upvotes: 3

Related Questions