Sorry for mistakes, I am french. I created a window on Tkinter and I used cx_Freeze to make it executable. It works well but my problem is the size of widgets that switch between when it is showed on python as script and showed as executable. It's bigger as executable. I searched on the forum and I found an advice that says: don't force Tkinter'size, it does it very well by itself. But I need choose size on my Labels whatever happens? So I don't understand. The two images are same size, as you can see the difference :executablePython Here is my code to cx_Freeze:
from cx_Freeze import setup, Executable
setup(
name="Mon super programme",
version="0.1",
description="Affiche le path",
executables=[Executable("Accueil generateur et correcteur.py")]
)
And my other code for the window:
from tkinter import *
fenetre=Tk()
fenetre.geometry("1080x850")
fenetre.config(bg='#4065A4')
###Frame
cadre=Frame(fenetre, width=1080, height=720, borderwidth=0, bg='#4065A4')
frame_bas=Frame(cadre, borderwidth=0, bg='#4065A4')
###Canvas
can1=Canvas(frame_bas, bg='#4065A4', height=50, width=1, bd=0, highlightthickness=0) #Espace
can2=Canvas(frame_bas, bg='#4065A4', height=25, width=1, bd=0, highlightthickness=0) #Espace
can3=Canvas(frame_bas, bg='#4065A4', height=1, width=25, bd=0, highlightthickness=0) #Espace
fond1=Canvas(frame_bas, bg='#4065A4', height=350, width=400, bd=0, highlightthickness=0)
fond2=Canvas(frame_bas, bg='#4065A4', height=350, width=400, bd=0, highlightthickness=0)
fond3=Canvas(frame_bas, bg='#4065A4', height=350, width=400, bd=0, highlightthickness=0)
fond4=Canvas(frame_bas, bg='#4065A4', height=350, width=400, bd=0, highlightthickness=0)
###Formes
fond1.create_rectangle(0, 0, 400, 350, fill="red", width=5,outline="black")
fond2.create_rectangle(0, 0, 400, 350, fill="green", width=5,outline="black")
fond3.create_rectangle(0, 0, 400, 350, fill="blue", width=5,outline="black")
fond4.create_rectangle(0, 0, 400, 350, fill="purple", width=5,outline="black")
###Labels
titre=Label(cadre, text="Générateur et correcteur de QCM", font=('Arial',25), bg='#4065A4')
corriger=Label(frame_bas, text="Corriger une\n épreuve", font=('Arial',25), bg='green')
creer=Label(frame_bas, text="Créer une base\n de questions", font=('Arial',25), bg='red')
generer=Label(frame_bas, text="Générer une\n épreuve \n à partir \nd'une base", font=('Arial',25), bg='blue')
modifier=Label(frame_bas, text="Modifier une\n base de \nquestions", font=('Arial',25), bg='purple')
###Intégration au Frame
titre.grid(row=0, column=0)
can1.grid(row=0, column=0)
can2.grid(row=2, column=0)
can3.grid(row=1, column=1)
corriger.grid(row=1, column=0)
fond2.grid(row=1, column=0)
creer.grid(row=1, column=2)
fond1.grid(row=1, column=2)
generer.grid(row=3, column=0)
fond3.grid(row=3, column=0)
modifier.grid(row=3, column=2)
fond4.grid(row=3, column=2)
frame_bas.grid(row=1, column=0)
###Fonctions action\réaction
def afficher1(event):
print("créer")
def afficher2(event):
print(fenetre.geometry())
def afficher3(event):
print("générer")
def afficher4(event):
print("modifier")
###Action\Réaction
fond1.bind('<Button-1>', afficher1)
creer.bind('<Button-1>', afficher1)
fond2.bind('<Button-1>', afficher2)
corriger.bind('<Button-1>', afficher2)
fond3.bind('<Button-1>', afficher3)
generer.bind('<Button-1>', afficher3)
fond4.bind('<Button-1>', afficher4)
modifier.bind('<Button-1>', afficher4)
cadre.pack()
fenetre.mainloop()
Do you have an explanation or a solution please?
Cordially, Thanks
EDIT : When I print the geometry of the window on Python, it shows "1080x650+38+38" and on the Executable it shows "1080x650+362+19". I don't know where the difference come from.
EDIT 2 : Ok, the difference between "1080x650+38+38" and "1080x650+362+19" come from the position of the window on the screen. If you put the window on the up and left corner, you have "1080x650+0+0". So it's not interesting in my problem...