added spinbox missing from 3.6, added spinbox theme, updated config gen to display a file picker for labels with file in it
This commit is contained in:
parent
5003e2356c
commit
4ca9ab910e
3 changed files with 36 additions and 3 deletions
|
@ -9,6 +9,7 @@ DIALOG_PAD = 5
|
|||
class Dialog(tk.Toplevel):
|
||||
def __init__(self, master, app, title, modal=False):
|
||||
super().__init__(master)
|
||||
self.geometry("800x600")
|
||||
self.withdraw()
|
||||
self.app = app
|
||||
self.modal = modal
|
||||
|
|
|
@ -88,6 +88,14 @@ def load(style):
|
|||
},
|
||||
"map": {"fieldbackground": [("disabled", Colors.frame)]},
|
||||
},
|
||||
"TSpinbox": {
|
||||
"configure": {
|
||||
"fieldbackground": Colors.white,
|
||||
"foreground": Colors.black,
|
||||
"padding": (2, 0),
|
||||
},
|
||||
"map": {"fieldbackground": [("disabled", Colors.frame)]},
|
||||
},
|
||||
"TCombobox": {
|
||||
"configure": {
|
||||
"fieldbackground": Colors.white,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import tkinter as tk
|
||||
from functools import partial
|
||||
from tkinter import font, ttk
|
||||
from tkinter import filedialog, font, ttk
|
||||
from tkinter.scrolledtext import ScrolledText
|
||||
|
||||
from core.api.grpc import core_pb2
|
||||
|
@ -19,6 +19,12 @@ INT_TYPES = {
|
|||
PAD = 5
|
||||
|
||||
|
||||
def file_button_click(value):
|
||||
file_path = filedialog.askopenfilename(title="Select File")
|
||||
if file_path:
|
||||
value.set(file_path)
|
||||
|
||||
|
||||
class FrameScroll(ttk.LabelFrame):
|
||||
def __init__(self, master, app, _cls=ttk.Frame, **kw):
|
||||
super().__init__(master, **kw)
|
||||
|
@ -100,8 +106,18 @@ class ConfigFrame(FrameScroll):
|
|||
combobox.grid(row=index, column=1, sticky="ew", pady=pady)
|
||||
elif option.type == core_pb2.ConfigOptionType.STRING:
|
||||
value.set(option.value)
|
||||
entry = ttk.Entry(frame, textvariable=value)
|
||||
entry.grid(row=index, column=1, sticky="ew", pady=pady)
|
||||
if "file" in option.label:
|
||||
file_frame = ttk.Frame(frame)
|
||||
file_frame.grid(row=index, column=1, sticky="ew", pady=pady)
|
||||
file_frame.columnconfigure(0, weight=1)
|
||||
entry = ttk.Entry(file_frame, textvariable=value)
|
||||
entry.grid(row=0, column=0, sticky="ew", padx=padx)
|
||||
func = partial(file_button_click, value)
|
||||
button = ttk.Button(file_frame, text="...", command=func)
|
||||
button.grid(row=0, column=1)
|
||||
else:
|
||||
entry = ttk.Entry(frame, textvariable=value)
|
||||
entry.grid(row=index, column=1, sticky="ew", pady=pady)
|
||||
elif option.type in INT_TYPES:
|
||||
value.set(option.value)
|
||||
entry = ttk.Entry(frame, textvariable=value)
|
||||
|
@ -179,3 +195,11 @@ class CodeText(ScrolledText):
|
|||
relief=tk.FLAT,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
||||
class Spinbox(ttk.Entry):
|
||||
def __init__(self, master=None, **kwargs):
|
||||
super().__init__(master, "ttk::spinbox", **kwargs)
|
||||
|
||||
def set(self, value):
|
||||
self.tk.call(self._w, "set", value)
|
||||
|
|
Loading…
Reference in a new issue