J'utilise Python 3.6 sur Spyder, et je suis entrain de programmer une interface avec Tkinter. J'ai implémenté des boutons CheckButton, et quand je lance l’exécution sur Spyder, tout marche bien. Mais après la génération de l’exécutable .exe avec Cx-freeze les CheckButton ne marchent plus, et passent en mode disable. J'ai réalisé un petit code illustrant ma situation.
Code de mon interface:
Code du setup.py:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 import tkinter as tk root=tk.Tk() frame = tk.LabelFrame(root,text="Fichiers excel", padx=5, pady=20) frame.grid(row=0,sticky='nesw') cbVar=tk.StringVar() def fct(): if cbVar.get() =='': cbVar.set('salut') else: cbVar.set('') print(cbVar.get()) cb = tk.Checkbutton(frame, text="cb",variable=cbVar,command=fct,state=tk.NORMAL) cb.grid(row=0,column=0) root.mainloop()
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import cx_Freeze import sys import os.path PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__)) os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6') os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6') base = None if sys.platform == 'win32': base = "Win32GUI" executables = [cx_Freeze.Executable("debug.py", base=base)] cx_Freeze.setup( name = "test", options = {"build_exe": {"packages":["tkinter"]}}, version = "0.01", description = "test", executables = executables )