summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-07-22 11:52:38 +0200
committeremkael <emkael@tlen.pl>2019-07-22 11:52:38 +0200
commit8c0b4f0f0ea0fddcdad348fb0c5a9f546375ec29 (patch)
treeb06936a260935479b88da715c04a716f5cca98f3 /jfr_playoff/gui/frames
parent8bf96412b75689c578f5690dd0974304265d7fea (diff)
Ordered dictionaries for config export
Diffstat (limited to 'jfr_playoff/gui/frames')
-rw-r--r--jfr_playoff/gui/frames/match.py10
-rw-r--r--jfr_playoff/gui/frames/network.py9
-rw-r--r--jfr_playoff/gui/frames/team.py7
-rw-r--r--jfr_playoff/gui/frames/translations.py5
-rw-r--r--jfr_playoff/gui/frames/visual.py48
5 files changed, 45 insertions, 34 deletions
diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py
index ad22a3b..caf14ea 100644
--- a/jfr_playoff/gui/frames/match.py
+++ b/jfr_playoff/gui/frames/match.py
@@ -1,5 +1,7 @@
#coding=utf-8
+from collections import OrderedDict
+
import tkinter as tk
from tkinter.font import Font
from tkinter import ttk
@@ -171,7 +173,7 @@ class SwissSettingsFrame(RepeatableFrame):
value['relative_path'] if 'relative_path' in value else '')
def getValue(self):
- config = {}
+ config = OrderedDict()
if self.source.get() == self.SOURCE_DB:
config['database'] = self.fetchDB.get()
if self.linkRelPath.get():
@@ -423,7 +425,7 @@ class BracketMatchSettingsFrame(GuiFrame):
if self.source.get() == self.SOURCE_TEAM:
return self.teams
else:
- config = {}
+ config = OrderedDict()
lists = {
5: self.positions,
1: self.winners,
@@ -698,7 +700,7 @@ class MatchSettingsFrame(RepeatableFrame):
self.bracketSettings[idx].setSelectedTeam(-1)
def getValue(self):
- config = {}
+ config = OrderedDict()
config['id'] = self.matchID.get()
if self.link.get():
config['link'] = self.link.get()
@@ -805,7 +807,7 @@ class MatchPhaseFrame(ScrollableFrame):
'<<MatchListChanged>>', when='tail')
def getConfig(self):
- config = {}
+ config = OrderedDict
if self.name.get():
config['title'] = self.name.get()
if self.link.get():
diff --git a/jfr_playoff/gui/frames/network.py b/jfr_playoff/gui/frames/network.py
index fc00575..90c21d1 100644
--- a/jfr_playoff/gui/frames/network.py
+++ b/jfr_playoff/gui/frames/network.py
@@ -1,6 +1,7 @@
#coding=utf-8
import socket
+from collections import OrderedDict
import tkinter as tk
from tkinter import ttk
@@ -27,12 +28,12 @@ class MySQLConfigurationFrame(GuiFrame):
def getConfig(self):
if len(self.host.get().strip()):
- return {
+ return OrderedDict({
'host': self.host.get().strip(),
'port': self.port.get(default=3306),
'user': self.user.get().strip(),
'pass': self.pass_.get().strip()
- }
+ })
return None
def _testDB(self):
@@ -167,9 +168,9 @@ class GoniecConfigurationFrame(GuiFrame):
self.enable.set(values['enabled'] if 'enabled' in values else 0)
def getValues(self):
- config = {
+ config = OrderedDict({
'enabled': self.enable.get()
- }
+ })
if self.enable.get():
config['host'] = self.host.get()
config['port'] = self.port.get()
diff --git a/jfr_playoff/gui/frames/team.py b/jfr_playoff/gui/frames/team.py
index cc474b4..dbef680 100644
--- a/jfr_playoff/gui/frames/team.py
+++ b/jfr_playoff/gui/frames/team.py
@@ -1,5 +1,7 @@
#coding=utf-8
+from collections import OrderedDict
+
import tkinter as tk
from tkinter.font import Font
from tkinter import ttk
@@ -168,7 +170,7 @@ class TeamFetchSettingsFrame(GuiFrame):
'<<TeamSettingsChanged>>', when='tail')
def getTeams(self):
- teams = {}
+ teams = OrderedDict()
if self.fetchSource.get() == self.SOURCE_LINK:
teams['link'] = self.fetchLink.get()
elif self.fetchSource.get() == self.SOURCE_DB:
@@ -364,7 +366,8 @@ class TeamAliasFrame(ScrollableFrame):
self.repeater.grid(row=1, column=0, sticky=tk.W+tk.E)
def getConfig(self):
- return {val[0]: val[1] for val in self.repeater.getValue() if val[0]}
+ return OrderedDict(
+ {val[0]: val[1] for val in self.repeater.getValue() if val[0]})
def setValues(self, values):
self.repeater.setValue(list(values.iteritems()))
diff --git a/jfr_playoff/gui/frames/translations.py b/jfr_playoff/gui/frames/translations.py
index e5b8940..a369159 100644
--- a/jfr_playoff/gui/frames/translations.py
+++ b/jfr_playoff/gui/frames/translations.py
@@ -1,6 +1,7 @@
#coding=utf-8
import copy
+from collections import OrderedDict
import tkinter as tk
from tkinter import ttk
@@ -37,9 +38,9 @@ class TranslationConfigurationFrame(ScrollableFrame):
self.repeater.setValue(values)
def getTranslations(self):
- return {
+ return OrderedDict({
key: value for key, value in self.repeater.getValue()
- }
+ })
def renderContent(self, container):
self.repeater = WidgetRepeater(container, TranslationRow)
diff --git a/jfr_playoff/gui/frames/visual.py b/jfr_playoff/gui/frames/visual.py
index 9bbe5f6..147d6fe 100644
--- a/jfr_playoff/gui/frames/visual.py
+++ b/jfr_playoff/gui/frames/visual.py
@@ -1,5 +1,7 @@
#coding=utf-8
+from collections import OrderedDict
+
import tkinter as tk
from tkinter import ttk
import tkColorChooser as tkcc
@@ -179,23 +181,24 @@ class VisualSettingsFrame(GuiFrame):
self.teamNamePrefix.set(values['team_boxes']['name_prefix'])
def getValues(self):
- return {
- 'width': self.boxWidth.get(default=250),
- 'height': self.boxHeight.get(default=80),
- 'margin': self.boxMargin.get(default=60),
- 'starting_position_indicators': self.startingPositionIndicators.get(),
- 'finishing_position_indicators': self.finishingPositionIndicators.get(),
- 'team_boxes': {
- 'label_length_limit': self.teamNameLength.get(default=25) if self.shortenTeamNames else 0,
- 'predict_teams': self.teamNamePredict.get(),
- 'label_separator': self.teamLabelSeparator.get(),
- 'label_placeholder': self.teamNamePlaceholder.get(),
- 'label_ellipsis': self.teamNameEllipsis.get(),
- 'name_separator': self.teamNameSeparator.get(),
- 'name_prefix': self.teamNamePrefix.get(),
- 'sort_eligible_first': self.teamNameSortPredictions.get()
- }
- }
+ return OrderedDict(
+ {
+ 'width': self.boxWidth.get(default=250),
+ 'height': self.boxHeight.get(default=80),
+ 'margin': self.boxMargin.get(default=60),
+ 'starting_position_indicators': self.startingPositionIndicators.get(),
+ 'finishing_position_indicators': self.finishingPositionIndicators.get(),
+ 'team_boxes': {
+ 'label_length_limit': self.teamNameLength.get(default=25) if self.shortenTeamNames else 0,
+ 'predict_teams': self.teamNamePredict.get(),
+ 'label_separator': self.teamLabelSeparator.get(),
+ 'label_placeholder': self.teamNamePlaceholder.get(),
+ 'label_ellipsis': self.teamNameEllipsis.get(),
+ 'name_separator': self.teamNameSeparator.get(),
+ 'name_prefix': self.teamNamePrefix.get(),
+ 'sort_eligible_first': self.teamNameSortPredictions.get()
+ }
+ })
class MatchList(RefreshableOptionMenu):
@@ -282,7 +285,8 @@ class BoxPositionsFrame(ScrollableFrame):
self.positions.setValue(values_to_set)
def getValues(self):
- return { match: config for match, config in self.positions.getValue() }
+ return OrderedDict(
+ { match: config for match, config in self.positions.getValue() })
class LineStyle(GuiFrame):
def _selectColour(self):
@@ -338,7 +342,7 @@ class LineStylesFrame(GuiFrame):
CONFIG_KEYS = ['colour', 'h_offset', 'v_offset']
def renderContent(self):
- self.lines = {}
+ self.lines = OrderedDict()
for idx, line in enumerate(self.DEFAULT_VALUES):
self.lines[line[0]] = LineStyle(self)
self.lines[line[0]].grid(row=idx+1, column=1, sticky=tk.W)
@@ -357,7 +361,7 @@ class LineStylesFrame(GuiFrame):
self.lines[line[0]].setValue(value)
def getValues(self):
- config = {}
+ config = OrderedDict()
for line, widget in self.lines.iteritems():
value = widget.getValue()
for idx, key in enumerate(self.CONFIG_KEYS):
@@ -423,10 +427,10 @@ class PositionStyleFrame(RepeatableFrame):
self.description.set(value['caption'] if 'caption' in value else '')
def getValue(self):
- config = {
+ config = OrderedDict({
'class': self.name.get(),
'positions': self.positions
- }
+ })
caption = self.description.get()
if caption:
config['caption'] = caption