diff options
Diffstat (limited to 'jfr_playoff/gui')
-rw-r--r-- | jfr_playoff/gui/frames/__init__.py | 13 | ||||
-rw-r--r-- | jfr_playoff/gui/frames/network.py | 13 | ||||
-rw-r--r-- | jfr_playoff/gui/tabs.py | 6 |
3 files changed, 29 insertions, 3 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py index bc6bdb9..7c4907f 100644 --- a/jfr_playoff/gui/frames/__init__.py +++ b/jfr_playoff/gui/frames/__init__.py @@ -10,12 +10,14 @@ def getIntVal(widget, default=0): return default class WidgetRepeater(tk.Frame): - def __init__(self, master, widgetClass, headers=None, *args, **kwargs): + def __init__(self, master, widgetClass, headers=None, classParams=None, + *args, **kwargs): if not issubclass(widgetClass, RepeatableFrame): raise AttributeError( 'WidgetRepeater widget must be a RepeatableFrame') tk.Frame.__init__(self, master, **kwargs) self.widgetClass = widgetClass + self.widgetClassParams = classParams self.widgets = [] self.headers = headers self.addButton = ttk.Button( @@ -35,6 +37,8 @@ class WidgetRepeater(tk.Frame): command=lambda i=len(self.widgets): self._removeWidget(i)) removeButton.grid(row=len(self.widgets), column=0, sticky=tk.N) widget = self.widgetClass(self) + if self.widgetClassParams is not None: + widget.configureContent(**self.widgetClassParams) self.widgets.append(widget) self._updateGrid() @@ -77,6 +81,9 @@ class RepeatableFrame(tk.Frame): def renderContent(self): pass + def configureContent(self, **kwargs): + pass + def getValue(self): pass @@ -89,6 +96,10 @@ class RepeatableEntry(RepeatableFrame): self.field = ttk.Entry(self, textvariable=self.value) self.field.pack(expand=True, fill=tk.BOTH) + def configureContent(self, **kwargs): + for param, value in kwargs.iteritems(): + self.field[param] = value + def getValue(self): return self.value.get() diff --git a/jfr_playoff/gui/frames/network.py b/jfr_playoff/gui/frames/network.py index 14deaa0..567f597 100644 --- a/jfr_playoff/gui/frames/network.py +++ b/jfr_playoff/gui/frames/network.py @@ -5,7 +5,8 @@ from tkinter import ttk import tkMessageBox as tkmb from ...db import PlayoffDB -from ..frames import getIntVal +from ..frames import RepeatableEntry, WidgetRepeater +from ..frames import ScrollableFrame, getIntVal class MySQLConfigurationFrame(tk.Frame): def __init__(self, *args, **kwargs): @@ -73,4 +74,12 @@ class MySQLConfigurationFrame(tk.Frame): (ttk.Entry(container, textvariable=self.pass_, show='*')).grid( row=3, column=1, sticky=tk.E+tk.W) -__all__ = ['MySQLConfigurationFrame'] +class RemoteConfigurationFrame(ScrollableFrame): + def renderContent(self, container): + (ttk.Label(container, text='Zdalne pliki konfiguracyjne:')).pack( + side=tk.TOP, fill=tk.BOTH, expand=True) + self.repeater = WidgetRepeater( + container, RepeatableEntry, classParams={'width':100}) + self.repeater.pack(side=tk.TOP, fill=tk.BOTH, expand=True) + +__all__ = ['MySQLConfigurationFrame', 'RemoteConfigurationFrame'] diff --git a/jfr_playoff/gui/tabs.py b/jfr_playoff/gui/tabs.py index 62054bf..043d141 100644 --- a/jfr_playoff/gui/tabs.py +++ b/jfr_playoff/gui/tabs.py @@ -172,6 +172,12 @@ class NetworkTab(PlayoffTab): self.mysqlFrame = MySQLConfigurationFrame(container) self.mysqlFrame.pack(side=tk.TOP, fill=tk.BOTH, expand=True) + (ttk.Separator(container, orient=tk.HORIZONTAL)).pack( + side=tk.TOP, fill=tk.X) + + self.remoteFrame = RemoteConfigurationFrame(container, vertical=True) + self.remoteFrame.pack(side=tk.TOP, fill=tk.BOTH, expand=True) + class VisualTab(PlayoffTab): @property def title(self): |