summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames/translations.py
blob: b705f59c6aabcf39d4229ee363b5924954c8a332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#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):
        default_translations = copy.copy(PLAYOFF_I18N_DEFAULTS)
        default_translations.update(translations)
        values = []
        for value in default_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)

__all__ = ['TranslationConfigurationFrame']