-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_widgets.py
More file actions
24 lines (21 loc) · 1008 Bytes
/
Copy pathcustom_widgets.py
File metadata and controls
24 lines (21 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Benutzerdefinierte UI-Widgets für das Datei-Sortierungsprogramm
"""
import tkinter as tk
from tkinter import ttk
# Angepasste Version für ColorLabel-Widget für Farbige Symbole
class ColorLabel(tk.Frame):
"""Ein benutzerdefiniertes Label mit farbigem Symbol und normalem Text"""
def __init__(self, parent, symbol, color, text, **kwargs):
super().__init__(parent, **kwargs)
self.columnconfigure(1, weight=1)
# Symbol mit Farbe
self.symbol_label = tk.Label(self, text=symbol, fg=color, font=("Segoe UI", 11))
self.symbol_label.grid(row=0, column=0, padx=(0, 2))
# Text mit normaler Farbe
text_font = kwargs.get('font', ("Segoe UI", 10))
text_font_style = "bold" if kwargs.get('bold', False) else "normal"
self.text_label = tk.Label(self, text=text, font=(text_font[0], text_font[1], text_font_style))
self.text_label.grid(row=0, column=1, sticky="w")