-1

everyone, I am using Tkinter and I want to open a window after clicking on the button but I have this problem that when I run the program it will open the window not the button and the button is completely useless this is my code

import tkinter as tk
from tkinter import filedialog, Text
import os

root = tk.Tk()


def addApp():
    filename = filedialog.askopenfilename(initialdir="/", title="Select File",
                                          filetypes=(("executable", "*.exe"), ("allfiles", "*.*")))


canvas = tk.Canvas(root, height=700, width=700, bg="#263D42")
canvas.pack()

frame = tk.Frame(root, bg="white")
frame.place(relwidth=0.8, relheight=0.8, relx=0.1, rely=0.1)

openFile = tk.Button(root, text="OpenFile", padx=10,
                     pady=5, fg="white", bg="#263D42", command=addApp())
openFile.pack()

runApps = tk.Button(root, text="RunApps", padx=10, pady=5, fg="white", bg="#263D42")
runApps.pack()

root.mainloop()
nazanin n
  • 131
  • 1
  • 11

1 Answers1

0

Rename command=addApp() to command=addApp

Alderven
  • 7,569
  • 5
  • 26
  • 38