From 0e1ec567ea1cfffd69cd43816a6b851735a97f99 Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 2 Jun 2019 22:23:25 +0200 Subject: Translations configuration frame --- jfr_playoff/gui/frames/translations.py | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 jfr_playoff/gui/frames/translations.py (limited to 'jfr_playoff/gui/frames/translations.py') diff --git a/jfr_playoff/gui/frames/translations.py b/jfr_playoff/gui/frames/translations.py new file mode 100644 index 0000000..94af787 --- /dev/null +++ b/jfr_playoff/gui/frames/translations.py @@ -0,0 +1,40 @@ +#coding=utf-8 + +import copy + +import tkinter as tk +from tkinter import ttk + +from ..frames import RepeatableFrame, WidgetRepeater, ScrollableFrame +from ...i18n import PLAYOFF_I18N_DEFAULTS + +class TranslationRow(RepeatableFrame): + def renderContent(self): + self.key = tk.StringVar() + (ttk.Entry(self, textvariable=self.key, width=40)).pack( + side=tk.LEFT) + self.value = tk.StringVar() + (ttk.Entry(self, textvariable=self.value, width=80)).pack( + side=tk.RIGHT) + + def setValue(self, value): + self.key.set(value[0]) + self.value.set(value[1]) + +class TranslationConfigurationFrame(ScrollableFrame): + + def setTranslations(self, translations): + translations = copy.copy(PLAYOFF_I18N_DEFAULTS) + translations.update(translations) + values = [] + for value in translations.iteritems(): + values.append(value) + self.repeater.setValue(values) + + def renderContent(self, container): + self.repeater = WidgetRepeater(container, TranslationRow) + self.repeater.pack(side=tk.TOP, fill=tk.BOTH, expand=True) + + self.setTranslations({}) + +__all__ = ['TranslationConfigurationFrame'] -- cgit v1.2.3