Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entry state="readonly" --> visualize the read only state #63

Open
Pommes1024 opened this issue Dec 15, 2023 · 0 comments
Open

entry state="readonly" --> visualize the read only state #63

Pommes1024 opened this issue Dec 15, 2023 · 0 comments

Comments

@Pommes1024
Copy link

Pommes1024 commented Dec 15, 2023

Hi,

I noticed the read only state on entries is not graphically represented as in stock tkinter, where the background is turned grey.
An editable entry looks just the same as a not-editable one.
Is there a quick fix for this?

Here is an example app to showcase the issue.
Just # the two root.tk.call lines to see the expected behaviour without the theme.

Thank you in advance!

import tkinter as tk
from tkinter import ttk


class App(ttk.Frame):
    def __init__(self, parent):
        ttk.Frame.__init__(self)
        # Create widgets :)
        self.setup_widgets()

    def setup_widgets(self):
        # Create a Frame for the Checkbuttons
        self.check_frame = ttk.LabelFrame(self, text="Checkbuttons", padding=(20, 10))
        self.check_frame.grid(
            row=0, column=0, padx=(20, 10), pady=(20, 10), sticky="nsew"
        )


        # Create a Frame for input widgets
        self.widgets_frame = ttk.Frame(self, padding=(0, 0, 0, 10))
        self.widgets_frame.grid(
            row=0, column=1, padx=10, pady=(30, 10), sticky="nsew", rowspan=3
        )

        # Entry
        self.entry = ttk.Entry(self.widgets_frame)
        self.entry.insert(0, "Entry editable")
        self.entry.config(state="write")
        self.entry.grid(row=0, column=0, padx=5, pady=(0, 10), sticky="ew")

        self.entry2 = ttk.Entry(self.widgets_frame)
        self.entry2.insert(0, "Not editable")
        self.entry2.config(state="readonly")
        self.entry2.grid(row=0, column=1, padx=5, pady=(0, 10), sticky="ew")


if __name__ == "__main__":
    root = tk.Tk()
    root.title("")

    # Simply set the theme
    root.tk.call("source", "azure.tcl")
    root.tk.call("set_theme", "dark")

    app = App(root)
    app.pack(fill="both", expand=True)

    # Set a minsize for the window, and place it in the middle
    root.update()
    root.minsize(root.winfo_width(), root.winfo_height())
    x_cordinate = int((root.winfo_screenwidth() / 2) - (root.winfo_width() / 2))
    y_cordinate = int((root.winfo_screenheight() / 2) - (root.winfo_height() / 2))
    root.geometry("+{}+{}".format(x_cordinate, y_cordinate-20))

    root.mainloop()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant