Reading a few threads helped me to create a .exe from my tkinter gui.
Unfortunately, nothing happens when I run the .exe file. The code runs normally, when I run it in vsc.
Following the instructions online I did the following steps.
- I opened the command prompt, moved to my file location with
cd filelocation - I ran the command
pyinstaller name-of-my-file.py(also tried with the--onefilespecification for example.) - I get three folders pycache, dist and build, and within build I find the respective .exe file.
As stated above, nothing happens when I run the .exe file. Also tried running it as an administrator.
Just in case, I will publish my code below.
All kinds of help is appreciated.
from tkinter import *
from tkinter import messagebox
import time
import datetime
def clicked(event=None):
t = presentationDuration.get()
try:
t = float(t)
except ValueError:
messagebox.showerror(title='ValueError', message='The string is empty or there is no number entered!')
return
nSpeaker = nextSpeaker.get()
lbl.configure(text = nSpeaker, font = ("Arial Bold", 80))
t = int(t*60)
update(t)
def update(t):
if(t >= 0):
m,s = divmod(t, 60)
left_Time.configure(text = m)
right_Time.configure(text = s)
if(t <= 60):
nSpeaker = nextSpeaker.get()
lbl.configure(text = nSpeaker, bg = 'red', font = ("Arial Bold", 80))
window.after(1000, update, t-1)
window = Tk()
window.title("presenters Toolkit")
lbl_duration = Label(window, text = "duration [mins]")
lbl_duration.grid(column = 0, row = 0)
presentationDuration = Entry(window, width = 10)
presentationDuration.grid(column = 1, row = 0)
lbl_speaker = Label(window, text = "next Speaker")
lbl_speaker.grid(column = 2, row = 0)
nextSpeaker = Entry(window, width = 30)
nextSpeaker.grid(column = 3, row = 0)
lbl = Label(window, text = "", font = ("Arial Bold", 50))
lbl.grid(column = 1, row = 1)
btn = Button(window, text = "start", command = clicked)
btn.grid(column = 1, row = 3)
left_Time = Label(window, text ="--", font = ("Arial Bold", 80))
left_Time.grid(column = 0, row = 4)
mid_Time = Label(window, text = ":", font = ("Arial Bold", 80))
mid_Time.grid(column = 1, row = 4)
right_Time = Label(window, text = "--", font = ("Arial Bold", 80))
right_Time.grid(column = 2, row = 4)
window.mainloop()
NameError: name 'clicked' is not definedon the linebtn = Button(window, text = "start", command = clicked)when trying to execute your code. - acw1668exeinsidebuilddirectory. Use the directory insidedistdirectory if compile using--onediror theexeinsidedistdirectory if compile using--onefile. - acw1668