Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to change the disabled color in tkinter

import tkinter as tk

class TestApp(tk.Frame):
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        self.enabled_var = tk.IntVar(value=1)
        self.entry_text = tk.StringVar(value="Hola StackOverflow")

        self.entry = tk.Entry(self,
                              background="#ccff66",
                              foreground="#000000",
                              disabledbackground="#4d4d4d",
                              disabledforeground="#ffffff",
                              textvariable=self.entry_text 
                              )

        self.check_btn = tk.Checkbutton(self,
                                        text= "Enabled",
                                        variable=self.enabled_var,
                                        onvalue = 1,
                                        offvalue = 0,
                                        height=5,
                                        width=20,
                                        command=self.set_entry_state)

        self.entry.pack(side=tk.LEFT, expand=True, fill="x")
        self.check_btn.pack(side=tk.LEFT)

    def set_entry_state(self):
        if self.enabled_var.get():
            self.entry.configure(state=tk.NORMAL)
        else:
            self.entry.configure(state=tk.DISABLED)

if __name__ == "__main__":
    root = tk.Tk()
    TestApp(root).pack(side="top", fill="both", expand=True)
    root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: Python Add a string in a certain position 
Python :: sqlalchemy convert row to dict 
Python :: pyton count number of character in a word 
Python :: how to add captcha in django forms 
Python :: what is kernel_initializer 
Python :: gpt-3 tokenizer python3 
Python :: perform_update serializer django 
Python :: valid parentheses 
Python :: python import file from different directory 
Python :: python if condition 
Python :: python gzip a file 
Python :: python switch columns order csv 
Python :: install fastapi 
Python :: decode utf8 whit python 
Python :: ubuntu 20.10 python 3.8 
Python :: how to plot kmeans centroids 
Python :: discord.py message user 
Python :: how to strip white space of text in python? 
Python :: pandas df to list of dictionaries 
Python :: how to get mac in python 
Python :: selenium python has no attrirute getText 
Python :: too many python versions pip package location 
Python :: smallest number of 3 python 
Python :: dataframe of one row 
Python :: terminal commands for install python on cpanel 
Python :: make tkinter text editing disabled 
Python :: how to create pyw file 
Python :: python split 
Python :: converting tuple into string 
Python :: concatenation of array in python 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =