I have a python script that generates a window with some buttons made with tkinter. When I convert to executable and send to potential users that does not have python installed, their window has a different style than mine. I’ using tkinter.ttk and they see it what looks like a much older style, maybe tk, and not ttk.
Versions: Windows 11. Python 3.12. Pyinstaller 6.7.0.
Libraries:
import os
import re
import tempfile
import openpyxl
import math as m
import webbrowser
import numpy as np
import pandas as pd
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.filedialog
from PIL import ImageTk, Image
from collections import Counter
import matplotlib.pyplot as plt
import win32com.client as win32
from dxfwrite import DXFEngine as dxf
import openpyxl.styles as opyxlstyles
from scipy.ndimage import gaussian_filter1d
try: # Close the splash screen
import pyi_splash # type: ignore
pyi_splash.close()
except:
pass # Otherwise do nothing
Command:
pyinstaller –splash=Splash.png –icon=Icon.ico –hidden-import=pyi_splash –hidden-import=tkinter.filedialog –hidden-import=tkinter.ttk –add-data=”Files/*;Files“ main.py
Sorry for the basic question, is my first time turning a .py to a .exe.
Thank you!
Since the style is different, I assume is a problem with imports. So I tried to put the –hidden-imports=tkinter.ttk. It fixed a previous problem that I was having with tkinter.filedialog (that I solved with the –hidden-import=tkinter.filedialog), but the style on different PCs still differs from mine.
Is it better not to use “from … import …” ? Just “import …”? Makes it easier for pyinstaller detect it?
Every import with a dot should be included as a hidden import?
Like from scipy.ndimage import gaussian_filter1d, should I put:
–hidden-imports=scipy.ndimage.gaussian_filter1 ??
Paulo Drummond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.