mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-02 02:38:30 +02:00
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from source.mkw.ModSettings import AbstractModSettings
|
|
from source.gui.preview import AbstractPreviewWindow
|
|
|
|
|
|
class String(AbstractModSettings):
|
|
"""
|
|
This setting type allow you to input a string text.
|
|
You can optionally add a "preview" to allow the user to use a window to select the value.
|
|
"""
|
|
|
|
type = "string"
|
|
|
|
def __init__(self, preview: str | None = None, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self.preview = preview
|
|
|
|
def tkinter_show(self, master, checkbox) -> None:
|
|
import tkinter
|
|
from tkinter import ttk
|
|
|
|
super().tkinter_show(master, checkbox)
|
|
variable = self.tkinter_variable(tkinter.StringVar)
|
|
master.grid_columnconfigure(1, weight=1)
|
|
|
|
entry = ttk.Entry(master, textvariable=variable)
|
|
entry.grid(row=1, column=1, sticky="EW")
|
|
|
|
if self.preview is not None:
|
|
button = ttk.Button(
|
|
master, text="...", width=3,
|
|
command=lambda: AbstractPreviewWindow.get(self.preview)(master.root.mod_config, variable)
|
|
)
|
|
button.grid(row=1, column=2, sticky="EW")
|
|
|
|
self.tkinter_bind(master, checkbox)
|