Python Forum
[Tkinter] Double GUI
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Double GUI
#2
UPDATE:
After some experimenting, I've found out more. It seems restarting the Explorer process (the script still runs if it is merely terminated but not started back up again) in Windows interferes with scripts. Here's an updated business end of the script:
def delete_thumbs(self):
        pth = AppData + 'Local\\Microsoft\\Windows\\Explorer\\'
        sb = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced'
        acc = winreg.KEY_ALL_ACCESS
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, sb, access=acc)
        val = winreg.QueryValueEx(key, 'IconsOnly')
        if val[0] == 0:
            winreg.SetValueEx(key, 'IconsOnly', 0, winreg.REG_DWORD, 1)
        subprocess.run('Taskkill /IM Explorer.exe /F')
        subprocess.run('C:\\Windows\\Explorer.exe')
        for s in self.scan_directory(pth):
            print('Loop')
            if s.startswith('thumb'):
                try:
                    os.remove(pth + s)
                except OSError:
                    print('LOCKED')
        print('SUCCESS!')
        if val[0] == 0:
            winreg.SetValueEx(key, 'IconsOnly', 0, winreg.REG_DWORD, 0)
            subprocess.run('Taskkill /IM Explorer.exe /F')
            subprocess.run('C:\\Windows\\Explorer.exe')
When I restart the Explorer process, the script pauses. Note that this is in an SublimeText REPL session (SublimeREPL). I have not tried running the script via the file because it's harder to debug. I will though. After Explorer has restarted, the GUI hangs (have to force Windows to close it) and when I close the interactive REPL session, Explorer restarts again. Oddness. So, does anyone know anything about Python on Windows and having Explorer tied to the script being executed? Why does restarting Explorer terminate the script? Fix or workaround? Finally, it may be tied to SublimeREPL, I don't know. I will experiement and post back if running the script via double-clicking the file changes anything.
Reply


Messages In This Thread
Double GUI - by malonn - Sep-13-2020, 02:31 PM
RE: Double GUI - by malonn - Sep-13-2020, 06:05 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020