added styling for listboxes, made use of listbox scroll where all other basic listboxes were being used
This commit is contained in:
parent
585d10dd28
commit
713c42a64e
5 changed files with 34 additions and 29 deletions
|
@ -4,7 +4,7 @@ from tkinter import ttk
|
|||
from core.api.grpc import core_pb2
|
||||
from coretk.dialogs.dialog import Dialog
|
||||
from coretk.themes import PADX, PADY
|
||||
from coretk.widgets import CodeText
|
||||
from coretk.widgets import CodeText, ListboxScroll
|
||||
|
||||
|
||||
class HookDialog(Dialog):
|
||||
|
@ -96,8 +96,9 @@ class HooksDialog(Dialog):
|
|||
self.top.columnconfigure(0, weight=1)
|
||||
self.top.rowconfigure(0, weight=1)
|
||||
|
||||
self.listbox = tk.Listbox(self.top)
|
||||
self.listbox.grid(sticky="nsew", pady=PADY)
|
||||
listbox_scroll = ListboxScroll(self.top)
|
||||
listbox_scroll.grid(sticky="nsew", pady=PADY)
|
||||
self.listbox = listbox_scroll.listbox
|
||||
self.listbox.bind("<<ListboxSelect>>", self.select)
|
||||
for hook_file in self.app.core.hooks:
|
||||
self.listbox.insert(tk.END, hook_file)
|
||||
|
|
|
@ -4,6 +4,7 @@ from tkinter import ttk
|
|||
from coretk.coreclient import Observer
|
||||
from coretk.dialogs.dialog import Dialog
|
||||
from coretk.themes import PADX, PADY
|
||||
from coretk.widgets import ListboxScroll
|
||||
|
||||
|
||||
class ObserverDialog(Dialog):
|
||||
|
@ -27,24 +28,16 @@ class ObserverDialog(Dialog):
|
|||
self.draw_apply_buttons()
|
||||
|
||||
def draw_listbox(self):
|
||||
frame = ttk.Frame(self.top)
|
||||
frame.grid(sticky="nsew", pady=PADY)
|
||||
frame.columnconfigure(0, weight=1)
|
||||
frame.rowconfigure(0, weight=1)
|
||||
|
||||
scrollbar = ttk.Scrollbar(frame, orient=tk.VERTICAL)
|
||||
scrollbar.grid(row=0, column=1, sticky="ns")
|
||||
|
||||
self.observers = tk.Listbox(
|
||||
frame, selectmode=tk.SINGLE, yscrollcommand=scrollbar.set
|
||||
)
|
||||
listbox_scroll = ListboxScroll(self.top)
|
||||
listbox_scroll.grid(sticky="nsew", pady=PADY)
|
||||
listbox_scroll.columnconfigure(0, weight=1)
|
||||
listbox_scroll.rowconfigure(0, weight=1)
|
||||
self.observers = listbox_scroll.listbox
|
||||
self.observers.grid(row=0, column=0, sticky="nsew")
|
||||
self.observers.bind("<<ListboxSelect>>", self.handle_observer_change)
|
||||
for name in sorted(self.app.core.custom_observers):
|
||||
self.observers.insert(tk.END, name)
|
||||
|
||||
scrollbar.config(command=self.observers.yview)
|
||||
|
||||
def draw_form_fields(self):
|
||||
frame = ttk.Frame(self.top)
|
||||
frame.grid(sticky="ew", pady=PADY)
|
||||
|
|
|
@ -4,6 +4,7 @@ from tkinter import ttk
|
|||
from coretk.coreclient import CoreServer
|
||||
from coretk.dialogs.dialog import Dialog
|
||||
from coretk.themes import FRAME_PAD, PADX, PADY
|
||||
from coretk.widgets import ListboxScroll
|
||||
|
||||
DEFAULT_NAME = "example"
|
||||
DEFAULT_ADDRESS = "127.0.0.1"
|
||||
|
@ -32,25 +33,18 @@ class ServersDialog(Dialog):
|
|||
self.draw_apply_buttons()
|
||||
|
||||
def draw_servers(self):
|
||||
frame = ttk.Frame(self.top)
|
||||
frame.grid(pady=PADY, sticky="nsew")
|
||||
frame.columnconfigure(0, weight=1)
|
||||
frame.rowconfigure(0, weight=1)
|
||||
listbox_scroll = ListboxScroll(self.top)
|
||||
listbox_scroll.grid(pady=PADY, sticky="nsew")
|
||||
listbox_scroll.columnconfigure(0, weight=1)
|
||||
listbox_scroll.rowconfigure(0, weight=1)
|
||||
|
||||
scrollbar = ttk.Scrollbar(frame, orient=tk.VERTICAL)
|
||||
scrollbar.grid(row=0, column=1, sticky="ns")
|
||||
|
||||
self.servers = tk.Listbox(
|
||||
frame, selectmode=tk.SINGLE, yscrollcommand=scrollbar.set
|
||||
)
|
||||
self.servers = listbox_scroll.listbox
|
||||
self.servers.grid(row=0, column=0, sticky="nsew")
|
||||
self.servers.bind("<<ListboxSelect>>", self.handle_server_change)
|
||||
|
||||
for server in self.app.core.servers:
|
||||
self.servers.insert(tk.END, server)
|
||||
|
||||
scrollbar.config(command=self.servers.yview)
|
||||
|
||||
def draw_server_configuration(self):
|
||||
frame = ttk.LabelFrame(self.top, text="Server Configuration", padding=FRAME_PAD)
|
||||
frame.grid(pady=PADY, sticky="ew")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
|
||||
THEME_DARK = "black"
|
||||
PADX = (0, 5)
|
||||
|
@ -160,7 +161,21 @@ def update_menu(style, widget):
|
|||
if not abg:
|
||||
abg = bg
|
||||
widget.config(
|
||||
background=bg, foreground=fg, activebackground=abg, activeforeground=fg
|
||||
background=bg, foreground=fg, activebackground=abg, activeforeground=fg, bd=0
|
||||
)
|
||||
|
||||
|
||||
def update_listbox(widget):
|
||||
style = ttk.Style()
|
||||
bg = style.lookup(".", "background")
|
||||
fg = style.lookup(".", "foreground")
|
||||
widget.config(
|
||||
background=bg,
|
||||
foreground=fg,
|
||||
highlightthickness=1,
|
||||
highlightcolor="black",
|
||||
highlightbackground="black",
|
||||
bd=0,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from tkinter import filedialog, font, ttk
|
|||
from tkinter.scrolledtext import ScrolledText
|
||||
|
||||
from core.api.grpc import core_pb2
|
||||
from coretk import themes
|
||||
from coretk.appconfig import ICONS_PATH
|
||||
from coretk.themes import FRAME_PAD, PADX, PADY
|
||||
|
||||
|
@ -184,6 +185,7 @@ class ListboxScroll(ttk.LabelFrame):
|
|||
self.listbox = tk.Listbox(
|
||||
self, selectmode=tk.SINGLE, yscrollcommand=self.scrollbar.set
|
||||
)
|
||||
themes.update_listbox(self.listbox)
|
||||
self.listbox.grid(row=0, column=0, sticky="nsew")
|
||||
self.scrollbar.config(command=self.listbox.yview)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue