'Why the tkinter app converted to exe not working
I have made a simple gui based application using tkinter. And trying to convert it into exe file. Tried both pyinstaller and auto-py-to-exe. The exe file is created but when i try to open it the cursor is loading yet the application is not opened. And few files are successfully converted to exe and working properly. But few file aren't! I am using the Python version 3.10.2. The pip version is 22.0.3 and the pyinstaller version is 4.9. (Auto py version is 2.17.0)
Here is the Sample code i tried to convert into exe.
# Age Calculator
from tkinter import *
from datetime import *
main = Tk()
main.geometry('500x500')
main.title('Age Calculator')
birthDate = IntVar()
birthMonth = IntVar()
birthYear = IntVar()
def calculate():
date = birthDate.get()
month = birthMonth.get()
year = birthYear.get()
today = datetime.today()
todayDate = today.day
todayMonth = today.month
todayYear = today.year
monthOfYear= [31,28,31,30,31,30,31,30,31,30,31,30]
if date>todayDate:#30>28
todayMonth-=1 #0
todayDate = todayDate+monthOfYear[month-1]#28+31=59,
if month>todayMonth:
todayYear-=1#2021
todayMonth = todayMonth+12#12
calculatedDate = abs(todayDate-date)# (59-30=29)
calculatedMonth = abs(todayMonth-month)#12-1=11
calculatedYear = abs(todayYear-year)#2021-2000=21
age = Label(main, text='You Are {years} Years, {months} Months and {days} Days Old!'.format(years=calculatedYear, months=calculatedMonth, days=calculatedDate),font=('normal',14),justify='center').place(x=0,y=350,width=500)
titleLabel = Label(main, text='Calculate Your Age!',font=('normal',15,'bold'),bg='yellow').place(x=0,y=20,width=500,height=40)
dateLabel = Label(main, text='Birth Date : ',font=('normal',12),).place(x=40,y=100)
date = Entry(main, textvariable = birthDate, font=('normal',13,)).place(x=150,y=100,width=70,height=30)
monthLabel = Label(main, text='Birth Month : ', font=('normal',12)).place(x=40,y=150)
month = Entry(main, textvariable = birthMonth, font=('normal',13,)).place(x=150,y=150,width=70,height=30)
yearLabel = Label(main, text='Birth Year : ', font=('normal',12)).place(x=40,y=200)
year= Entry(main, textvariable = birthYear, font=('normal',13,)).place(x=150,y=200,width=70,height=30)
calci = Button(main, text='Calculate Age',bg='pink',command=calculate).place(x=40,y=250,width=180,height=40)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
