How to make pyinstaller import the ttk theme?

前端 未结 2 1292
梦谈多话
梦谈多话 2021-01-17 00:43

I have a project done and it is in the following

import tkinter as tk
from tkinter import ttk
import tkinter.messagebox as tmb
from ttkthemes import ThemedSt         


        
相关标签:
2条回答
  • 2021-01-17 01:04

    Because ttkthemes seems to do some funnys with directorys, you can get it to work by modifying the spec file.

    generate a specfile for your application from pyinstaller, and add the following (changing path to site-packages, as required)

    In the a= Analysis(..... change datas=[],to:

    data= [('venv\\Lib\\site-packages\\ttkthemes', 'ttkthemes')],

    and add ttkthemes to hiddenimports

    hiddenimports=['ttkthemes'],

    This then appears to work for me

    0 讨论(0)
  • 2021-01-17 01:13

    The code worked for me fine.. Looks like you haven't successfully imported ttkthemes i.e. it's not properly installed. Therefore, you should do it again. To install ttkthemes (assuming you already have python3 and setup tools):

    sudo apt-get install python3-tk
    sudo -H pip3 install ttkthemes
    

    This should work perfectly fine.

    0 讨论(0)
提交回复
热议问题