Checkbutton non fonctionnelle avec le bg noir

Résolu
natou_nat Messages postés 10 Statut Membre -  
natou_nat Messages postés 10 Statut Membre -

Bonjour,

je suis en train de créer une applis qui genere des mot de passe mais les checkbutton quand le fond est noir on ne vois plus la petite fleche et j aimerais qu'une personne m'aide merci


Windows / Opera 96.0.0.0

5 réponses

  1. natou_nat Messages postés 10 Statut Membre
     
    window.title("generateur de mot de passe")
    window.geometry("1280x720")
    window.minsize(1200, 620)
    window.maxsize(4080, 1060)
    window.iconbitmap(bitmap=("icon.ico"))
    window.config(bg='#262626')
    
    # Create a transparent window
    window.wm_attributes('-transparentcolor', '#add123')
    
    # crée frame
    frame = Frame(window, bg='#262626', border=0, borderwidth=0)
    
    # crée un sous boite
    right_frame = Frame(frame, bg='#262626', border=0, borderwidth=0)
    
    right_frame2 = Frame(frame, bg='#262626')
    
    def chose():
        button1 = choix1.get()
        button2 = choix2.get()
        button3 = choix3.get()
        if str(button1 and button2 and button3) == '1':
            print(generate_password7() in password_entry)
        if str(button2 and button3) == '1':
            print(generate_password6() in password_entry)
        if str(button1 and button3) == '1':
            print(generate_password5() in password_entry)
        if str(button1 and button2) == '1':
            print(generate_password4() in password_entry)
        if str(button1) == '1':
            print(generate_password1() in password_entry)
        if str(button2) == '1':
            print(generate_password2() in password_entry)
        if str(button3) == '1':
            print(generate_password3() in password_entry)
    
    def generate_password1():
        password_min = 12
        password_max = 24
        all_chars = string.ascii_letters
    
        password = "".join(choice(all_chars) for x in range(randint(password_min, password_max)))
        password_entry.delete(0, END)
        password_entry.insert(0, password)
    
    def generate_password2():
        password_min = 12
        password_max = 24
        all_chars = string.punctuation
    
        password = "".join(choice(all_chars) for x in range(randint(password_min, password_max)))
        password_entry.delete(0, END)
        password_entry.insert(0, password)
    
    def generate_password3():
        password_min = 12
        password_max = 24
        all_chars = string.digits
    
        password = "".join(choice(all_chars) for x in range(randint(password_min, password_max)))
        password_entry.delete(0, END)
        password_entry.insert(0, password)
    
    def generate_password4():
        password_min = 12
        password_max = 24
        all_chars = string.punctuation + string.ascii_letters
    
        password = "".join(choice(all_chars) for x in range(randint(password_min, password_max)))
        password_entry.delete(0, END)
        password_entry.insert(0, password)
    
    def generate_password5():
        password_min = 12
        password_max = 24
        all_chars = string.ascii_letters + string.digits
    
        password = "".join(choice(all_chars) for x in range(randint(password_min, password_max)))
        password_entry.delete(0, END)
        password_entry.insert(0, password)
    
    def generate_password6():
        password_min = 12
        password_max = 24
        all_chars = string.punctuation + string.digits
    
        password = "".join(choice(all_chars) for x in range(randint(password_min, password_max)))
        password_entry.delete(0, END)
        password_entry.insert(0, password)
    
    def generate_password7():
        password_min = 12
        password_max = 24
        all_chars = string.punctuation + string.digits + string.ascii_letters
    
        password = "".join(choice(all_chars) for x in range(randint(password_min, password_max)))
        password_entry.delete(0, END)
        password_entry.insert(0, password)
    
    global choix1
    global choix2
    global choix3
    choix1 = IntVar()
    choix2 = IntVar()
    choix3 = IntVar()
    g = 1
    f = 2
    h = 3
    result = f + g
    result1 = f + g + h
    
    # crée un sous boite
    right_frame = Frame(frame, bg='#262626')
    
    right_frame2 = Frame(frame, bg='#262626')
    # crée un titre
    
    lable_title = Label(right_frame, text="Mot de passe", font=("Helvetica", 35), bg='#262626', fg='white')
    lable_title.pack(expand=YES)
    
    def destroye():
        password_entry.destroy(string.punctuation)
    
    def copier():
        window.clipboard_append(password_entry.get())
        if copier():
            print("vous avez copiée le mot de passe" in password_entry)
    
    copybtn = PhotoImage(file='copy.png')
    bt_copie = Button(window, image=copybtn, text="copier", command=copier, relief=FLAT, bg='#262626', activebackground='#ffffff', borderwidth=0, border=0)
    bt_copie.place(x=1055, y=300)
    
    # crée un champs
    password_entry = Entry(right_frame, width=30, font=("Helvetica", 35), bg='#262626', fg='white', relief=GROOVE,
                           borderwidth=1, highlightthickness=0)
    password_entry.pack(expand=YES)
    
    # crée button a cocher
    checkbutton_soleil = Checkbutton(right_frame, text="mot de passe avec des lettre ", font=("Helvetica", 20),
                                     bg='#262626', fg='#ffffff', activebackground='white', variable=choix1)
    checkbutton_soleil.pack()
    checkbutton_pluie = Checkbutton(right_frame, text="mot de passe avec des carctere spéciaux", font=("Helvetica", 20),
                                     fg='white', bg='#262626', variable=choix2)
    checkbutton_pluie.pack()
    checkbutton_moyen = Checkbutton(right_frame, text="mot de passe avec des chiffres", font=("Helvetica", 20),
                                    fg='white', bg='#262626', variable=choix3)
    checkbutton_moyen.pack()
    g = 1
    f = 2
    result = g + f
    
    # crée un boutton
    generate_password_button = Button(right_frame, text="Générer un mot de passe avec que des lettre",font=("Helvetica", 20), bg='#262626', fg='white', relief=GROOVE, borderwidth=2,border=2, command=chose)
    generate_password_button.pack(expand=YES)
    
    # on place la sous boite a droite de la frame principal
    right_frame.grid(row=0, column=1, sticky=W)
    
    right_frame2.grid(row=1, column=1, sticky=W)
    # afficher frame
    frame.pack(expand=YES)
    
    def exit():
        window.destroy()
        root.destroy()
    
    exitbtn = PhotoImage(file='exit.png')
    
    button_exit = Button(window, image=exitbtn, bg='#262626', relief=FLAT, activebackground='#ffffff',highlightthickness=0, command=exit)
    button_exit.place(x=1180, y=620)
    
    # afficher la fentre
    window.overrideredirect(2)
    
    window.wm_attributes('-transparentcolor', '#963963')
    
    def time():
        string = strftime('%H:%M:%S %p')
        label.config(text=string)
        label.after(1000, time)
    
    label = Label(window, font=('arial', 50), foreground='red', bg='#262626')
    label.place(x= 480,y=0)
    time()
    
    
    window.mainloop()
    0
  2. Phil_1857 Messages postés 1883 Date d'inscription   Statut Membre Dernière intervention   169
     

    Bonjour,

    Tu devrais ne garder qu'une seule fonction generate_password et passer all_chars en argument suivant le cas ...

    0
  3. Phil_1857 Messages postés 1883 Date d'inscription   Statut Membre Dernière intervention   169
     

    C'est le bazar, là-dedans

    Tu devrais mettre:

    1_ les imports

    2_ les définitions de fonctions

    3_ les initialisations de variables

    4_ la création de la fenêtre, puis des widgets

    0
  4. plumoir
     

    Salut,

    Il faut à mon sens utiliser l'option selectcolor. Mias le foreground est aussi la couleur du V.

    Tu aurais pu réduire ton code au plus simple, histoire que l'on puisse tester, par ex. comme ceci :

    import tkinter
    
    window = tkinter.Tk()
    window.geometry('100x100')
    
    check_button = tkinter.Checkbutton(window, text='Cocher', bg='black', fg='blue', selectcolor='yellow',)
    check_button.grid()
    
    check_button = tkinter.Checkbutton(window, text='Cocher', bg='black', fg='red', selectcolor='black',)
    check_button.grid()
    
    window.mainloop()
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. natou_nat Messages postés 10 Statut Membre
     

    bonjour et merci beaucoup 

    0