Home > Enterprise >  Tkinter modern dialogue box suddenly not working
Tkinter modern dialogue box suddenly not working

Time:11-16

I use the following code to show dialogue boxes:

from tkinter.ttk import *
from tkinter import messagebox
messagebox.showerror(title='xx', message='xxx')

And I use PyInstaller to compile into exe. Today I found out that the modern themed dialogue box is no longer there. I downloaded the exe binary built a month ago, the dialogue box are modern themed, however, the one I just built are no longer. The code relevant to the box are exactly the same, and I am running on exactly the same system. I do not understand where the issue could be.

Here is an example of modern and old:

Old: enter image description here

New: enter image description here

As you can see, the buttons are completely different.

Both binaries are built with Python 3.9.8 and latest development build of PyInstaller

CodePudding user response:

Solved it myself after discussing with PyInstaller maintainer. (See here: https://github.com/pyinstaller/pyinstaller/discussions/6366)

The problem is that in Python 3.9.8 they dropped a Windows dependency that enables the modern UI support. This was a change made from 3.9.7 to 3.9.8. To work around this, you have to specify your own manifest file and add the following content into it:

  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" language="*" processorArchitecture="*" version="6.0.0.0" publicKeyToken="6595b64144ccf1df"/>
      <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"/>
    </dependentAssembly>
  </dependency>

Update: This is fixed in latest PyInstaller development build: https://github.com/pyinstaller/pyinstaller/pull/6367

  • Related