The GUI itself works in the sense that it will display the text and both of the checkboxes, but when I check off a box and hit the "Click to start" button nothing happens.
Here is my code:
import tkinter
import os
window = tkinter.Tk()
window.title("Startup Menu")
tkinter.Label(window, text="Choose the applications to start:", justify=tkinter.LEFT, padx=20).pack()
# N
n_clicked = tkinter.IntVar()
n_check = tkinter.Checkbutton(window, text="N", variable=n_clicked)
n_check.pack()
# S
s_clicked = tkinter.IntVar()
s_check = tkinter.Checkbutton(window, text="S", variable=s_clicked)
s_check.pack()
# Startup button that executes the selected applications
def click():
if n_clicked == 1:
os.startfile(r"(file location)")
if s_clicked == 1:
os.startfile(r"(file location)")
# Start selected applications button
start_up = tkinter.Button(window, text="Click to start", command=click).pack()
window.mainloop()
tkinter variables use a get()
and set()
method to work with them.
if n_clicked.get():
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.