如何为其余的checkbutton创建selcet all checkbutton?

a64a0gku  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(156)
import multiprocessing
import time
import tkinter as tk    
from tkinter import *
from tkinter import messagebox
import os

root = tk.Tk()
root.title("AFP")
root.resizable(0,0)
root.iconbitmap("logo.ico")
bg = PhotoImage(file = "background.png")

# Show image using label

label1 = Label( root, image = bg)
label1.place(x = -3, y = -3)
root.geometry("700x700")

def quit():
    root.destroy()

def cb():
    if ch.get() ==1:
        c0.config(fg='#00FF00')
        c0.config(activeforeground='#00FF00')
        c5.select
    else:
        c0.config(fg='#49B8F4')
        c0.config(activeforeground='#49B8F4')
    if ff.get() ==1:
        c1.config(fg='#00FF00')
        c1.config(activeforeground='#00FF00')
    else:
        c1.config(fg='#49B8F4')
        c1.config(activeforeground='#49B8F4')
    if op.get() ==1:
        c2.config(fg='#00FF00')
        c2.config(activeforeground='#00FF00')
    else:
        c2.config(fg='#49B8F4')
        c2.config(activeforeground='#49B8F4')
    if dis.get() ==1:
        c3.config(fg='#00FF00')
        c3.config(activeforeground='#00FF00')
    else:
        c3.config(fg='#49B8F4')
        c3.config(activeforeground='#49B8F4')
    if zoom.get() ==1:
        c4.config(fg='#00FF00')
        c4.config(activeforeground='#00FF00')
    else:
        c4.config(fg='#49B8F4')
        c4.config(activeforeground='#49B8F4')
    if wrr.get() ==1:
        c5.config(fg='#00FF00')
        c5.config(activeforeground='#00FF00')
    else:
        c5.config(fg='#49B8F4')
        c5.config(activeforeground='#49B8F4')
    if z7.get() ==1:
        c6.config(fg='#00FF00')
        c6.config(activeforeground='#00FF00')
    else:
        c6.config(fg='#49B8F4')
        c6.config(activeforeground='#49B8F4')
    if pea.get() ==1:
        c7.config(fg='#00FF00')
        c7.config(activeforeground='#00FF00')
    else:
        c7.config(fg='#49B8F4')
        c7.config(activeforeground='#49B8F4')
    if ut.get() ==1:
        c8.config(fg='#00FF00')
        c8.config(activeforeground='#00FF00')
    else:
        c8.config(fg='#49B8F4')
        c8.config(activeforeground='#49B8F4')
    if D1.get() ==1:
        c9.config(fg='#00FF00')
        c9.config(activeforeground='#00FF00')
    else:
        c9.config(fg='#49B8F4')
        c9.config(activeforeground='#49B8F4')
    if D2.get() ==1:
        c10.config(fg='#00FF00')
        c10.config(activeforeground='#00FF00')
    else:
        c10.config(fg='#49B8F4')
        c10.config(activeforeground='#49B8F4')
    if NV.get() ==1:
        c11.config(fg='#00FF00')
        c11.config(activeforeground='#00FF00')
    else:
        c11.config(fg='#49B8F4')
        c11.config(activeforeground='#49B8F4')
    if amd.get() ==1:
        c12.config(fg='#00FF00')
        c12.config(activeforeground='#00FF00')
    else:
        c12.config(fg='#49B8F4')
        c12.config(activeforeground='#49B8F4')
    if IN.get() ==1:
        c13.config(fg='#00FF00')
        c13.config(activeforeground='#00FF00')
    else:
        c13.config(fg='#49B8F4')
        c13.config(activeforeground='#49B8F4')
    if tv.get() ==1:
        c14.config(fg='#00FF00')
        c14.config(activeforeground='#00FF00')
    else:
        c14.config(fg='#49B8F4')
        c14.config(activeforeground='#49B8F4')
    if AD.get() ==1:
        c15.config(fg='#00FF00')
        c15.config(activeforeground='#00FF00')
    else:
        c15.config(fg='#49B8F4')
        c15.config(activeforeground='#49B8F4')

def st1():

# -----------------------------------driver---------------------------------------------------------------#

    if amd.get() == 1:
        os.system("amd.exe")
        return True 
    if NV.get() == 1:
        os.system("NV.exe")
        return True 
    if IN.get() == 1:
        os.system("IN64.exe")
        return True 

# -----------------------------------Contact---------------------------------------------------------------#

    if dis.get() == 1:
        os.system("dis.exe")
        return True 
    if zoom.get() == 1:
        os.system("zoom.exe")
        return True 

# -----------------------------------Browser---------------------------------------------------------------#

    if ch.get() == 1:
        os.system("ch.exe")
        return True 
    if ff.get() == 1:
        os.system("ff.exe")
        return True 
    if op.get() == 1:
        os.system("op.exe")
        return True   
    #-----------------------------------unzip---------------------------------------------------------------#
    if wrr.get() == 1:
        os.system("wrr.exe")
        return True 
    if z7.get() == 1:
        os.system("7z.exe")
        return True 
    if pea.get() == 1:
        os.system("pea.exe")  
        return True   

# -----------------------------------Download---------------------------------------------------------------#

    if D1.get() == 1:
        os.system("D1.exe")
        return True     
    if ut.get() == 1:
        os.system("ut.exe")
        return True 

    if D2.get() == 1:
        os.system("D2.exe")  
        return True         

# -----------------------------------Remote pc---------------------------------------------------------------#

    if tv.get() == 1:
        os.system("tv.exe")
        return True 

    if AD.get() == 1:
        os.system("AD.exe")
        return True 

# -----------------------------------err---------------------------------------------------------------#

    else:
           messagebox.showerror(title="ERROR", message="Please select one program at least ") 

# --- --------------------------------Frames---------------------------------------------------------------#

Frame =tk.Frame(root, bg="#EFEEEC")
Frame.place(relwidth=0.8, relheight=0.8, relx=0.1,rely=0.1)
Frame1 =tk.Frame(Frame,width=500,height=200,bg="#EFEEEC",borderwidth=5,background="#49B8F4",relief=RIDGE)
Frame1.place(relx=0.2,y=330)
Frame2 =tk.Frame(Frame,width=500,height=200,bg="#EFEEEC",borderwidth=5,background="#49B8F4",relief=RIDGE)
Frame2.place(relx=0.6,y=80)
Frame3 =tk.Frame(Frame,width=500,height=200,bg="#EFEEEC",borderwidth=5,background="#49B8F4",relief=RIDGE)
Frame3.place(relx=0.2,y=80)
Frame4 =tk.Frame(Frame,width=500,height=200,bg="#EFEEEC",borderwidth=5,background="#49B8F4",relief=RIDGE)
Frame4.place(relx=0.2,y=220)
Frame5 =tk.Frame(Frame,width=500,height=200,bg="#EFEEEC",borderwidth=5,background="#49B8F4",relief=RIDGE)
Frame5.place(relx=0.6,y=220)
Frame6 =tk.Frame(Frame,width=500,height=200,bg="#EFEEEC",borderwidth=5,background="#49B8F4",relief=RIDGE)
Frame6.place(relx=0.57,y=330)

# -----------------------------------Browser---------------------------------------------------------------#

l0 = Label(Frame, text = "المتصفح",fg="#49B8F4")
l0.pack()
l0.place(relx=0.24,y=300)
l0.config(font=("times", 17, "bold"))
ch= IntVar()
c0 =Checkbutton(Frame1, text=" Chrome  ",variable=ch,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c0.pack()
ff= IntVar()
c1 =Checkbutton(Frame1, text=" Firefox   ",variable=ff,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c1.pack()
op= IntVar()
c2 =Checkbutton(Frame1, text=" Opera    ",variable=op,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c2.pack()

# -----------------------------------Contact---------------------------------------------------------------#

l0 = Label(Frame, text = "تواصل",fg="#49B8F4")
l0.pack()
l0.place(relx=0.246,y=189)
l0.config(font=("times", 17, "bold"))
dis= IntVar()
c3 =Checkbutton(Frame4, text=" Discord  ",variable=dis,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c3.pack()
zoom= IntVar()
c4 =Checkbutton(Frame4, text="  zoom    ",variable=zoom,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c4.pack()

# -----------------------------------unzip---------------------------------------------------------------#

l0 = Label(Frame, text = "فك الضغط ",fg="#49B8F4")
l0.pack()
l0.place(relx=0.224,y=50)
l0.config(font=("times", 17, "bold"))
wrr= IntVar()
c5 =Checkbutton(Frame3, text=" Winrar  ",variable=wrr,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c5.pack()
z7= IntVar()
c6 =Checkbutton(Frame3, text="   7zip    ",variable=z7,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c6.pack()
pea= IntVar()
c7 =Checkbutton(Frame3, text=" Peazip   ",variable=pea,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c7.pack()

# -----------------------------------DM---------------------------------------------------------------#

l0 = Label(Frame, text = "مدير التحميل",fg="#49B8F4")
l0.pack()
l0.place(relx=0.64,y=300)
l0.config(font=("times", 17, "bold"))
ut= IntVar()
c8 =Checkbutton(Frame6, text="        Torrnet         ",variable=ut,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c8.pack()
D1= IntVar()
c9 =Checkbutton(Frame6, text="Download manager1",variable=D1,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c9.pack()
D2= IntVar()
c10 =Checkbutton(Frame6, text="Download manager2",variable=D2,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c10.pack()

# -----------------------------------Drivers---------------------------------------------------------------#

l0 = Label(Frame, text = "تعريفات",fg="#49B8F4")
l0.pack()
l0.place(relx=0.68,y=50)
l0.config(font=("times", 16, "bold"))
NV= IntVar()
c11 =Checkbutton(Frame2, text=" Nvidia drivers  ",variable=NV,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c11.pack()
amd= IntVar()
c12 =Checkbutton(Frame2, text="  AMD drivers    ",variable=amd,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c12.pack()
IN= IntVar()
c13 =Checkbutton(Frame2, text="  Intel drivers    ",variable=IN,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c13.pack()

# -----------------------------------Remote desk---------------------------------------------------------------#

l0 = Label(Frame, text = "التحكم بالكمبيوتر",fg="#49B8F4")
l0.pack()
l0.place(relx=0.62,y=190)
l0.config(font=("times", 17, "bold"))
tv= IntVar()
c14 =Checkbutton(Frame5, text="  Team viewer   ",variable=tv,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c14.pack()
AD= IntVar()
c15 =Checkbutton(Frame5, text="    Any Disk      ",variable=AD,command=cb,fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"))
c15.pack()

# -----------------------------------Buttons---------------------------------------------------------------#

startD = tk.Button(Frame, text=" Start Download", padx=9.49, pady=5,fg="#EFEEEC",bg="#5EB1F6", command=st1,cursor="tcross",font=("Courgette", 10, "bold"))
startD.pack()
startD.place(relx=0.40,rely=0.83)
quit = tk.Button(Frame, text="    Quit    ", padx=28.5, pady=5,fg="#EFEEEC",bg="#5EB1F6", command=quit,cursor="tcross",font=("Courgette", 10, "bold"))
quit.pack()
quit.place(relx=0.40,rely=0.91)

s1 =Checkbutton(root, text="Select all",fg='#49B8F4',cursor="tcross",font=("Courgette", 10, "bold"), padx=9.49, pady=5,)
s1.pack
s1.place(x=0,y=0)

# -----------------------------------Loop---------------------------------------------------------------#

root.mainloop()

我这样做只是为了学习如何使用tkinter,但我不能创建一个全选按钮s1是全选按钮,我不能使一个功能,将使其工作,请帮助我!!!我从其他人那里看到了其他solotion,但他们都没有在我的代码中工作。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题