-1

Here is some code:

import tkinter.ttk as _ttk
import tkinter as _tk

class QEntry(_ttk.Widget):
    def __init__(self, master):
        super(QEntry, self).__init__(master, "ttk::entry", {"class": "QEntry", "style": "QEntry"})


def init(widget=None):
    flat = "flat"

    s = _ttk.Style()
    s.theme_create("QUI", "default")
    s.theme_use("QUI")
    s.layout("QEntry", [('Entry.highlight', {'border': 0,'sticky': 'nswe','children': [('Entry.border', {'border': 0,'sticky': 'nswe','children': [('Entry.padding', {'sticky': 'nswe','children': [('Entry.textarea', {'sticky': 'nswe','border': 0})]})]}), ('Entry.bd', {'sticky': 'nswe','border': 0,'children': [('Entry.padding', {'sticky': 'nswe','children': [('Entry.textarea', {'sticky': 'nswe'})]})]})]})])
    s.theme_settings("QUI", {"QEntry": {"configure": {"padding": 4},"map": {"relief": [("active", flat),("focus", flat),("!disabled", flat),("disabled", flat)],"background": [("active", "#00afaf"),("focus", "#6f6f6f"),("!disabled", "#6f6f6f"),("disabled", "#8f8f8f")],"bordercolor": [("active", "#00afaf"),("focus", "#00afaf"),("!disabled", "#6f6f6f"),("disabled", "#5f5f5f")],"foreground": [("active", "#ffffff"),("focus", "#ffffff"),("!disabled", "#afafaf"),("disabled", "#5f5f5f")],}}})


if __name__ == '__main__':
    root = _tk.Tk()
    root.wm_minsize(200, 150)
    init(root)

    frame = _tk.Frame(root)
    entry = QEntry(frame)
    entry.pack(pady=1)
    frame.pack(fill="both", expand=True)

    root.mainloop()

The Entry isn't editable or clickable. Why?
The QEntry(...) class is a subclass of _ttk.Widget.
The init(...) is the initialization for the style / layout.

Qboi
  • 15
  • 1
  • 6
  • ***`class QEntry(_ttk.Widget):`***: Why do you inherit from `.Widget` instead of `ttk.Entry`? ***isn't editable or clickable. Why?***: You have disabled all in your `Style` definition. See [reply.it](https://repl.it/repls/EffectiveBoringCleantech) – stovfl May 16 '20 at 19:23
  • @stovfl I created that for theming – Qboi May 17 '20 at 08:59
  • @stovfl Found it, I changed the `QEntry` in the `class` key to `TEntry` – Qboi May 17 '20 at 09:07
  • ***class QEntry(_ttk.Widget):***: By inheriting from `.Widget`, you are loosing `ttk.Entry` specific methods. ***for theming***: Relevant [is-it-possible-to-have-a-standard-style-for-a-widget](https://stackoverflow.com/questions/52210391) – stovfl May 17 '20 at 10:42

1 Answers1

0

I found it, to do this you only need to change the value of the class key to TEntry in class QEntry(_ttk.Widget):.

import tkinter.ttk as _ttk
import tkinter as _tk

class QEntry(_ttk.Widget):
    def __init__(self, master):
        super(QEntry, self).__init__(master, "ttk::entry", {"class": "TEntry", "style": "QEntry"})


def init(widget=None):
...
Qboi
  • 15
  • 1
  • 6