summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-07-07 18:48:22 +0200
committeremkael <emkael@tlen.pl>2019-07-07 18:48:22 +0200
commitadada21ae38d7fbc8f9a6eba1bb1f591a3452480 (patch)
treea3667254ace853f8d9cd63c4adec2c632a2b522c /jfr_playoff/gui/frames
parent185ffdcbfdd5246e127762ad0b290e99116a0215 (diff)
Adjusting alignment and widget sticky/grow for entire GUI
Diffstat (limited to 'jfr_playoff/gui/frames')
-rw-r--r--jfr_playoff/gui/frames/__init__.py35
-rw-r--r--jfr_playoff/gui/frames/match.py42
-rw-r--r--jfr_playoff/gui/frames/network.py92
-rw-r--r--jfr_playoff/gui/frames/team.py14
-rw-r--r--jfr_playoff/gui/frames/translations.py4
-rw-r--r--jfr_playoff/gui/frames/visual.py10
6 files changed, 120 insertions, 77 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index dd4f632..9f762bf 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -200,25 +200,31 @@ class ScrollableFrame(tk.Frame):
horizontal = kwargs['horizontal']
del kwargs['horizontal']
tk.Frame.__init__(self, *args, **kwargs)
- canvas = tk.Canvas(self, borderwidth=0, highlightthickness=0)
+ self.canvas = tk.Canvas(self, borderwidth=0, highlightthickness=0)
if horizontal:
hscroll = tk.Scrollbar(
- self, orient=tk.HORIZONTAL, command=canvas.xview)
+ self, orient=tk.HORIZONTAL, command=self.canvas.xview)
hscroll.pack(side=tk.BOTTOM, fill=tk.X)
- canvas.configure(xscrollcommand=hscroll.set)
+ self.canvas.configure(xscrollcommand=hscroll.set)
if vertical:
vscroll = tk.Scrollbar(
- self, orient=tk.VERTICAL, command=canvas.yview)
+ self, orient=tk.VERTICAL, command=self.canvas.yview)
vscroll.pack(side=tk.RIGHT, fill=tk.Y)
- canvas.configure(yscrollcommand=vscroll.set)
- frame = tk.Frame(canvas, borderwidth=0, highlightthickness=0)
- canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
- canvas.create_window((0,0), window=frame, anchor=tk.N+tk.W)
- frame.bind(
- '<Configure>',
- lambda ev: canvas.configure(scrollregion=canvas.bbox('all')))
+ self.canvas.configure(yscrollcommand=vscroll.set)
+ frame = tk.Frame(self.canvas, borderwidth=0, highlightthickness=0)
+ self.canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
+ self.canvasFrame = self.canvas.create_window(
+ (0,0), window=frame, anchor=tk.N+tk.W)
+ frame.bind('<Configure>', self._onFrameConfigure)
+ self.canvas.bind('<Configure>', self._onCanvasConfigure)
self.renderContent(frame)
+ def _onFrameConfigure(self, event):
+ self.canvas.configure(scrollregion=self.canvas.bbox('all'))
+
+ def _onCanvasConfigure(self, event):
+ self.canvas.itemconfig(self.canvasFrame, width=event.width)
+
def renderContent(self, container):
pass
@@ -300,10 +306,6 @@ class SelectionButton(ttk.Button):
selectionFrame.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
class SelectionFrame(ScrollableFrame):
-
- def renderOption(self, container, option, idx):
- pass
-
def __init__(self, master, title='', options=[],
selected=None, callback=None, *args, **kwargs):
self.values = {}
@@ -315,6 +317,9 @@ class SelectionFrame(ScrollableFrame):
(ttk.Button(master, text='Zapisz', command=self._save)).pack(
side=tk.BOTTOM, fill=tk.Y)
+ def renderOption(self, container, option, idx):
+ pass
+
def _mapValue(self, idx, value):
return idx + 1
diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py
index c2f7026..99eb1b3 100644
--- a/jfr_playoff/gui/frames/match.py
+++ b/jfr_playoff/gui/frames/match.py
@@ -55,6 +55,10 @@ class SwissSettingsFrame(RepeatableFrame):
self.linkLabel = tk.StringVar()
self.linkRelPath = tk.StringVar()
+ self.columnconfigure(1, weight=1)
+ self.columnconfigure(2, weight=1)
+ self.columnconfigure(3, weight=1)
+
(ttk.Label(self, text='Źródło danych:')).grid(
row=0, column=0, sticky=tk.W)
(ttk.Radiobutton(
@@ -108,14 +112,14 @@ class SwissSettingsFrame(RepeatableFrame):
(ttk.Label(self, text='Etykieta linku:')).grid(
row=8, column=0, sticky=tk.E)
(ttk.Entry(self, textvariable=self.linkLabel, width=20)).grid(
- row=8, column=1, sticky=tk.W)
+ row=8, column=1, sticky=tk.W+tk.E)
(ttk.Label(self, text='(domyślnie: "Turniej o #. miejsce")')).grid(
row=8, column=2, sticky=tk.W)
(ttk.Label(self, text='Względna ścieżka linku do swissa:')).grid(
- row=1, column=2)
+ row=1, column=2, sticky=tk.E)
(ttk.Entry(self, textvariable=self.linkRelPath, width=20)).grid(
- row=1, column=3)
+ row=1, column=3, sticky=tk.W+tk.E)
(ttk.Separator(self, orient=tk.HORIZONTAL)).grid(
row=7, column=0, columnspan=6, sticky=tk.E+tk.W)
@@ -435,6 +439,8 @@ class MatchSettingsFrame(RepeatableFrame):
self.matchID = tk.IntVar()
self.matchID.trace('w', self._updateName)
self.matchID.set(self.winfo_toplevel().getNewMatchID(self))
+ self.winfo_toplevel().bind(
+ '<<PhaseRenamed>>', self._updateName, add='+')
self.link = tk.StringVar()
self.source = tk.IntVar()
@@ -451,14 +457,20 @@ class MatchSettingsFrame(RepeatableFrame):
self.winnerPositions = []
self.loserPositions = []
+ self.columnconfigure(1, weight=1)
+ self.columnconfigure(2, weight=1)
+
self.nameLabel.grid(row=0, column=0, sticky=tk.W)
(ttk.Label(self, text='Link:')).grid(row=0, column=1, sticky=tk.E)
(ttk.Entry(self, textvariable=self.link)).grid(
- row=0, column=2, sticky=tk.W)
+ row=0, column=2, sticky=tk.W+tk.E)
bracketGroup = ttk.LabelFrame(self, text='Dane drabinki')
bracketGroup.grid(row=1, column=0, columnspan=3, sticky=tk.W+tk.E)
+ bracketGroup.columnconfigure(0, weight=1)
+ bracketGroup.columnconfigure(1, weight=1)
+
homeTeam = ttk.LabelFrame(bracketGroup, text='Team gospodarzy')
homeTeam.grid(row=0, column=0, sticky=tk.W+tk.E)
awayTeam = ttk.LabelFrame(bracketGroup, text='Team gości')
@@ -473,6 +485,10 @@ class MatchSettingsFrame(RepeatableFrame):
scoreGroup = ttk.LabelFrame(self, text='Dane wyniku meczu')
scoreGroup.grid(row=4, column=0, columnspan=3, sticky=tk.W+tk.E)
+
+ scoreGroup.columnconfigure(1, weight=1)
+ scoreGroup.columnconfigure(3, weight=1)
+
self.scoreWidgets = {
self.SCORE_SOURCE_DB: [
DBSelectionField(scoreGroup, self.scoreDB, self.scoreDB.get()),
@@ -503,10 +519,12 @@ class MatchSettingsFrame(RepeatableFrame):
],
self.SCORE_SOURCE_CUSTOM: [
ttk.Entry(
- scoreGroup, textvariable=self.scoreCustom[0], width=5),
+ scoreGroup, textvariable=self.scoreCustom[0],
+ width=10, justify=tk.RIGHT),
ttk.Label(scoreGroup, text=':'),
ttk.Entry(
- scoreGroup, textvariable=self.scoreCustom[1], width=5),
+ scoreGroup, textvariable=self.scoreCustom[1],
+ width=10, justify=tk.RIGHT),
ttk.Checkbutton(
scoreGroup, variable=self.scoreNotFinished,
text='mecz nie został zakończony, rozegrano:'),
@@ -521,7 +539,7 @@ class MatchSettingsFrame(RepeatableFrame):
scoreGroup, variable=self.source, value=self.SCORE_SOURCE_DB,
text='Baza danych')).grid(row=0, column=0, sticky=tk.W)
self.scoreWidgets[self.SCORE_SOURCE_DB][0].grid(
- row=0, column=1, columnspan=3)
+ row=0, column=1, columnspan=3, sticky=tk.W+tk.E)
for idx in range(1, 5):
self.scoreWidgets[self.SCORE_SOURCE_DB][idx].grid(
row=0, column=idx+3)
@@ -529,7 +547,7 @@ class MatchSettingsFrame(RepeatableFrame):
scoreGroup, variable=self.source, value=self.SCORE_SOURCE_LINK,
text='Strona z wynikami')).grid(row=1, column=0, sticky=tk.W)
self.scoreWidgets[self.SCORE_SOURCE_LINK][0].grid(
- row=1, column=1, columnspan=3)
+ row=1, column=1, columnspan=3, sticky=tk.W+tk.E)
self.scoreWidgets[self.SCORE_SOURCE_LINK][1].grid(
row=1, column=4)
self.scoreWidgets[self.SCORE_SOURCE_LINK][2].grid(
@@ -539,7 +557,7 @@ class MatchSettingsFrame(RepeatableFrame):
text='Ustaw ręcznie')).grid(row=2, column=0, sticky=tk.W)
for idx in range(0, 3):
self.scoreWidgets[self.SCORE_SOURCE_CUSTOM][idx].grid(
- row=2, column=idx+1)
+ row=2, column=idx+1, sticky=tk.E if idx == 0 else tk.W)
self.scoreWidgets[self.SCORE_SOURCE_CUSTOM][3].grid(
row=2, column=4, columnspan=4)
for idx in range(4, 6):
@@ -673,9 +691,11 @@ class MatchPhaseFrame(ScrollableFrame):
headerFrame = tk.Frame(container)
headerFrame.pack(side=tk.TOP, fill=tk.X, expand=True)
(ttk.Label(headerFrame, text='Nazwa:')).pack(side=tk.LEFT)
- (ttk.Entry(headerFrame, textvariable=self.name)).pack(side=tk.LEFT)
+ (ttk.Entry(headerFrame, textvariable=self.name)).pack(
+ side=tk.LEFT, fill=tk.X, expand=True)
(ttk.Label(headerFrame, text='Link:')).pack(side=tk.LEFT)
- (ttk.Entry(headerFrame, textvariable=self.link)).pack(side=tk.LEFT)
+ (ttk.Entry(headerFrame, textvariable=self.link)).pack(
+ side=tk.LEFT, fill=tk.X, expand=True)
self.matches = WidgetRepeater(
container, [MatchSettingsFrame, MatchSeparator])
diff --git a/jfr_playoff/gui/frames/network.py b/jfr_playoff/gui/frames/network.py
index 50c77dd..7112171 100644
--- a/jfr_playoff/gui/frames/network.py
+++ b/jfr_playoff/gui/frames/network.py
@@ -52,44 +52,47 @@ class MySQLConfigurationFrame(GuiFrame):
def renderContent(self):
self.host = tk.StringVar()
+ self.host.trace('w', self._changeNotify)
self.port = tk.StringVar()
+ self.port.trace('w', self._changeNotify)
self.user = tk.StringVar()
+ self.user.trace('w', self._changeNotify)
self.pass_ = tk.StringVar()
+ self.pass_.trace('w', self._changeNotify)
- (ttk.Label(self, text='Ustawienia MySQL')).grid(
- row=0, column=0, columnspan=4, sticky=tk.E+tk.W)
- (ttk.Label(self, text='Host:')).grid(
- row=1, column=0, sticky=tk.E)
- self.host.trace('w', self._changeNotify)
- (ttk.Entry(self, textvariable=self.host)).grid(
- row=1, column=1, sticky=tk.E+tk.W)
+ self.columnconfigure(0, weight=1)
- (ttk.Label(self, text='Port:')).grid(
- row=1, column=2, sticky=tk.E)
- self.port.trace('w', self._changeNotify)
+ frame = ttk.LabelFrame(self, text='Ustawienia MySQL')
+ frame.grid(row=0, column=0, columnspan=4, sticky=tk.E+tk.W+tk.N+tk.S)
+
+ (ttk.Label(frame, text='Host:')).grid(
+ row=0, column=0, sticky=tk.E)
+ (ttk.Entry(frame, textvariable=self.host)).grid(
+ row=0, column=1, sticky=tk.E+tk.W)
+
+ (ttk.Label(frame, text='Port:')).grid(
+ row=0, column=2, sticky=tk.E)
(tk.Spinbox(
- self, textvariable=self.port, width=5,
- from_=0, to=65535)).grid(row=1, column=3, sticky=tk.W)
+ frame, textvariable=self.port, width=5,
+ from_=0, to=65535)).grid(row=0, column=3, sticky=tk.W)
- (ttk.Label(self, text='Użytkownik:')).grid(
- row=2, column=0, sticky=tk.E)
- self.user.trace('w', self._changeNotify)
- (ttk.Entry(self, textvariable=self.user)).grid(
- row=2, column=1, sticky=tk.E+tk.W)
+ (ttk.Label(frame, text='Użytkownik:')).grid(
+ row=1, column=0, sticky=tk.E)
+ (ttk.Entry(frame, textvariable=self.user)).grid(
+ row=1, column=1, sticky=tk.E+tk.W)
(ttk.Button(
- self, text='Testuj ustawienia', command=self._testDB)).grid(
- row=2, column=3)
+ frame, text='Testuj ustawienia', command=self._testDB)).grid(
+ row=1, column=3)
self.dbError = None
- self.dbTestLabel = ttk.Label(self)
- self.dbTestLabel.grid(row=2, column=4)
+ self.dbTestLabel = ttk.Label(frame)
+ self.dbTestLabel.grid(row=1, column=4)
self.dbTestLabel.bind('<Button-1>', self._dbError)
- (ttk.Label(self, text='Hasło:')).grid(
- row=3, column=0, sticky=tk.E)
- self.pass_.trace('w', self._changeNotify)
- (ttk.Entry(self, textvariable=self.pass_, show='*')).grid(
- row=3, column=1, sticky=tk.E+tk.W)
+ (ttk.Label(frame, text='Hasło:')).grid(
+ row=2, column=0, sticky=tk.E)
+ (ttk.Entry(frame, textvariable=self.pass_, show='*')).grid(
+ row=2, column=1, sticky=tk.E+tk.W)
self.setValues({})
@@ -124,31 +127,33 @@ class GoniecConfigurationFrame(GuiFrame):
def renderContent(self):
self.enable = tk.IntVar()
+ self.enable.trace('w', self._enableWidgets)
self.host = tk.StringVar()
self.port = tk.StringVar()
- (ttk.Label(self, text='Konfiguracja Gońca:')).grid(
- row=0, column=0, columnspan=4, sticky=tk.W)
+ self.columnconfigure(0, weight=1)
+
+ frame = ttk.LabelFrame(self, text='Konfiguracja Gońca:')
+ frame.grid(row=0, column=0, columnspan=4, sticky=tk.W+tk.E+tk.N+tk.S)
(ttk.Checkbutton(
- self, text='Włącz obsługę Gońca', variable=self.enable)).grid(
- row=1, column=0, columnspan=2, sticky=tk.W)
- self.enable.trace('w', self._enableWidgets)
+ frame, text='Włącz obsługę Gońca', variable=self.enable)).grid(
+ row=0, column=0, columnspan=2, sticky=tk.W)
- (ttk.Label(self, text='Host:')).grid(row=2, column=0)
- self.hostField = ttk.Entry(self, textvariable=self.host)
- self.hostField.grid(row=2, column=1)
+ (ttk.Label(frame, text='Host:')).grid(row=1, column=0)
+ self.hostField = ttk.Entry(frame, textvariable=self.host)
+ self.hostField.grid(row=1, column=1)
- (ttk.Label(self, text='Port:')).grid(row=2, column=2)
+ (ttk.Label(frame, text='Port:')).grid(row=1, column=2)
self.portField = tk.Spinbox(
- self, textvariable=self.port, width=5)
- self.portField.grid(row=2, column=3)
+ frame, textvariable=self.port, width=5)
+ self.portField.grid(row=1, column=3)
self.testButton = ttk.Button(
- self, text='Testuj ustawienia', command=self._test)
- self.testButton.grid(row=3, column=1, sticky=tk.E)
+ frame, text='Testuj ustawienia', command=self._test)
+ self.testButton.grid(row=2, column=1, sticky=tk.E)
self.testError = None
- self.testLabel = ttk.Label(self)
- self.testLabel.grid(row=3, column=2, sticky=tk.W)
+ self.testLabel = ttk.Label(frame)
+ self.testLabel.grid(row=2, column=2, sticky=tk.W)
self.testLabel.bind('<Button-1>', self._testError)
self.setValues({})
@@ -162,10 +167,11 @@ class GoniecConfigurationFrame(GuiFrame):
class RemoteConfigurationFrame(ScrollableFrame):
def renderContent(self, container):
- (ttk.Label(container, text='Zdalne pliki konfiguracyjne:')).pack(
+ frame = ttk.LabelFrame(container, text='Zdalne pliki konfiguracyjne:')
+ frame.pack(
side=tk.TOP, fill=tk.BOTH, expand=True)
self.repeater = WidgetRepeater(
- container, RepeatableEntry, classParams={'width':100})
+ frame, RepeatableEntry, classParams={'width':100})
self.repeater.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
def setValues(self, values):
diff --git a/jfr_playoff/gui/frames/team.py b/jfr_playoff/gui/frames/team.py
index a304040..90394d0 100644
--- a/jfr_playoff/gui/frames/team.py
+++ b/jfr_playoff/gui/frames/team.py
@@ -186,6 +186,8 @@ class TeamFetchSettingsFrame(GuiFrame):
self.fetchLimit = tk.StringVar()
self.fetchLimit.trace('w', self._changeNotify)
+ self.columnconfigure(3, weight=1)
+
(ttk.Label(self, text=' ')).grid(row=0, column=0, rowspan=2)
(ttk.Radiobutton(
@@ -200,8 +202,8 @@ class TeamFetchSettingsFrame(GuiFrame):
self, text='Strona wyników',
variable=self.fetchSource, value=self.SOURCE_LINK)).grid(
row=1, column=1, columnspan=2, sticky=tk.W)
- self.fetchLink = ttk.Entry(self, width=20, textvariable=self.link)
- self.fetchLink.grid(row=1, column=3)
+ self.fetchLink = ttk.Entry(self, textvariable=self.link)
+ self.fetchLink.grid(row=1, column=3, sticky=tk.W+tk.E)
(ttk.Label(self, text='Pobierz do ')).grid(
row=2, column=0, columnspan=2, sticky=tk.W)
@@ -261,6 +263,8 @@ class TeamSettingsFrame(ScrollableFrame):
self.teamFormat.trace('w', self._enablePanels)
self.teamFormat.trace('w', self._changeNotify)
+ container.columnconfigure(0, weight=1)
+
(ttk.Radiobutton(
container, text='Pobierz z JFR Teamy:',
variable=self.teamFormat, value=self.FORMAT_FETCH)).grid(
@@ -318,10 +322,12 @@ class TeamList(RefreshableOptionMenu):
class TeamAliasRow(RepeatableFrame):
def renderContent(self):
- self.columnconfigure(0, weight=1)
+ self.columnconfigure(0, weight=0)
self.columnconfigure(1, weight=1)
self.teamName = tk.StringVar()
- (TeamList(self, self.teamName, self.teamName.get())).grid(
+ list = TeamList(self, self.teamName, self.teamName.get())
+ list.configure(width=20)
+ list.grid(
row=0, column=0, sticky=tk.W+tk.E+tk.N)
self.names = WidgetRepeater(self, RepeatableEntry)
self.names.grid(row=0, column=1, sticky=tk.W+tk.E)
diff --git a/jfr_playoff/gui/frames/translations.py b/jfr_playoff/gui/frames/translations.py
index b705f59..2429bfe 100644
--- a/jfr_playoff/gui/frames/translations.py
+++ b/jfr_playoff/gui/frames/translations.py
@@ -12,10 +12,10 @@ class TranslationRow(RepeatableFrame):
def renderContent(self):
self.key = tk.StringVar()
(ttk.Entry(self, textvariable=self.key, width=40)).pack(
- side=tk.LEFT)
+ side=tk.LEFT, fill=tk.BOTH, expand=True)
self.value = tk.StringVar()
(ttk.Entry(self, textvariable=self.value, width=80)).pack(
- side=tk.RIGHT)
+ side=tk.RIGHT, fill=tk.BOTH, expand=True)
def setValue(self, value):
self.key.set(value[0])
diff --git a/jfr_playoff/gui/frames/visual.py b/jfr_playoff/gui/frames/visual.py
index 03f9a14..0762e37 100644
--- a/jfr_playoff/gui/frames/visual.py
+++ b/jfr_playoff/gui/frames/visual.py
@@ -201,6 +201,7 @@ class BoxPositionFrame(RepeatableFrame):
self.vertical = tk.IntVar()
self.horizontal = tk.IntVar()
self.matchBox = MatchList(self, self.match)
+ self.matchBox.configure(width=20)
self.matchBox.grid(row=0, column=0)
(ttk.Label(self, text=' w pionie:')).grid(row=0, column=1)
(tk.Spinbox(
@@ -347,8 +348,12 @@ class PositionStyleFrame(RepeatableFrame):
self.name = tk.StringVar()
self.description = tk.StringVar()
+ self.columnconfigure(1, weight=1)
+ self.columnconfigure(5, weight=1)
+
(ttk.Label(self, text='Styl:')).grid(row=0, column=0)
- (ttk.Entry(self, textvariable=self.name)).grid(row=0, column=1)
+ (ttk.Entry(self, textvariable=self.name)).grid(
+ row=0, column=1, sticky=tk.W+tk.E)
(ttk.Label(self, text='Pozycje końcowe:')).grid(row=0, column=2)
self.positionBtn = TeamSelectionButton(
@@ -358,7 +363,8 @@ class PositionStyleFrame(RepeatableFrame):
self.positionBtn.grid(row=0, column=3)
(ttk.Label(self, text='Opis w legendzie:')).grid(row=0, column=4)
- (ttk.Entry(self, textvariable=self.description)).grid(row=0, column=5)
+ (ttk.Entry(self, textvariable=self.description)).grid(
+ row=0, column=5, sticky=tk.W+tk.E)
self.setValue({})