summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-11-16 14:45:37 +0100
committeremkael <emkael@tlen.pl>2019-11-16 14:45:37 +0100
commit2f2d4788d7f501e76f3b86bec0ad732dc2387433 (patch)
treec01f5e20a9323cf229fe067547c356389765dc3b
parent10cab28b7e5280066cd6b4442d0d3ded11e812e6 (diff)
Fixing checkbox behaviour/value storage for boolean variables
-rw-r--r--jfr_playoff/gui/frames/__init__.py5
-rw-r--r--jfr_playoff/gui/frames/match.py11
-rw-r--r--jfr_playoff/gui/frames/network.py4
-rw-r--r--jfr_playoff/gui/frames/visual.py12
-rw-r--r--jfr_playoff/gui/tabs.py4
-rw-r--r--jfr_playoff/gui/variables.py5
6 files changed, 24 insertions, 17 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index a02791d..f4fdf4f 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -7,7 +7,8 @@ import tkinter as tk
from tkinter import ttk
import tkMessageBox
-from ..variables import NotifyStringVar, NotifyIntVar, NotifyNumericVar, NumericVar
+from ..variables import NotifyStringVar, NotifyIntVar
+from ..variables import NotifyBoolVar, NotifyNumericVar, NumericVar
def setPanelState(frame, state):
for child in frame.winfo_children():
@@ -355,7 +356,7 @@ class SelectionFrame(ScrollableFrame):
self.renderHeader(container)
for idx, option in enumerate(self.options):
key = self._mapValue(idx, option)
- self.values[key] = NotifyIntVar()
+ self.values[key] = NotifyBoolVar()
self.renderOption(container, option, idx)
if self.selected and key in self.selected:
self.values[key].set(True)
diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py
index c91119d..7d0b923 100644
--- a/jfr_playoff/gui/frames/match.py
+++ b/jfr_playoff/gui/frames/match.py
@@ -12,7 +12,8 @@ from ..frames import SelectionFrame, SelectionButton, RefreshableOptionMenu
from ..frames.team import DBSelectionField, TeamSelectionFrame
from ..frames.team import TeamSelectionButton
from ..frames.visual import PositionsSelectionFrame
-from ..variables import NotifyStringVar, NotifyIntVar, NotifyNumericVar
+from ..variables import NotifyStringVar, NotifyIntVar
+from ..variables import NotifyNumericVar, NotifyBoolVar
class SwissSettingsFrame(RepeatableFrame):
SOURCE_LINK = 0
@@ -51,9 +52,9 @@ class SwissSettingsFrame(RepeatableFrame):
self.fetchDB = NotifyStringVar()
self.fetchLink = NotifyStringVar()
self.setFrom = NotifyNumericVar()
- self.setToEnabled = NotifyIntVar()
+ self.setToEnabled = NotifyBoolVar()
self.setTo = NotifyNumericVar()
- self.fetchFromEnabled = NotifyIntVar()
+ self.fetchFromEnabled = NotifyBoolVar()
self.fetchFrom = NotifyNumericVar()
self.linkLabel = NotifyStringVar()
self.linkRelPath = NotifyStringVar()
@@ -304,7 +305,7 @@ class BracketMatchSettingsFrame(GuiFrame):
self.source = NotifyIntVar()
self.source.trace('w', self._enablePanels)
self.source.trace('w', self._configChangeNotify)
- self.selected = NotifyIntVar()
+ self.selected = NotifyBoolVar()
self.selected.trace('w', self._enablePanels)
self.selectedIndex = NotifyStringVar()
self.positions = []
@@ -487,7 +488,7 @@ class MatchSettingsFrame(RepeatableFrame):
self.scoreRound = NotifyNumericVar()
self.scoreTable = NotifyNumericVar()
self.scoreCustom = [NotifyStringVar(), NotifyStringVar()]
- self.scoreNotFinished = NotifyIntVar()
+ self.scoreNotFinished = NotifyBoolVar()
self.scoreNotFinished.trace('w', self._enablePanels)
self.scoreBoards = NotifyNumericVar()
diff --git a/jfr_playoff/gui/frames/network.py b/jfr_playoff/gui/frames/network.py
index 90c21d1..fb27434 100644
--- a/jfr_playoff/gui/frames/network.py
+++ b/jfr_playoff/gui/frames/network.py
@@ -10,7 +10,7 @@ import tkMessageBox as tkmb
from ...db import PlayoffDB
from ..frames import RepeatableEntry, WidgetRepeater, NumericSpinbox
from ..frames import GuiFrame, ScrollableFrame
-from ..variables import NotifyStringVar, NotifyIntVar, NotifyNumericVar
+from ..variables import NotifyStringVar, NotifyNumericVar, NotifyBoolVar
def network_test(connFunction, testLabel):
try:
@@ -128,7 +128,7 @@ class GoniecConfigurationFrame(GuiFrame):
tkmb.showerror('Błąd połączenia z Gońcem', self.testError)
def renderContent(self):
- self.enable = NotifyIntVar()
+ self.enable = NotifyBoolVar()
self.enable.trace('w', self._enableWidgets)
self.host = NotifyStringVar()
self.port = NotifyNumericVar()
diff --git a/jfr_playoff/gui/frames/visual.py b/jfr_playoff/gui/frames/visual.py
index 147d6fe..1cbe177 100644
--- a/jfr_playoff/gui/frames/visual.py
+++ b/jfr_playoff/gui/frames/visual.py
@@ -10,7 +10,7 @@ from ..frames import GuiFrame, RepeatableFrame, ScrollableFrame
from ..frames import WidgetRepeater
from ..frames import SelectionFrame, RefreshableOptionMenu, NumericSpinbox
from ..frames.team import TeamSelectionButton
-from ..variables import NotifyStringVar, NotifyIntVar, NotifyNumericVar
+from ..variables import NotifyStringVar, NotifyNumericVar, NotifyBoolVar
class VisualSettingsFrame(GuiFrame):
DEFAULT_VALUES = {
@@ -32,17 +32,17 @@ class VisualSettingsFrame(GuiFrame):
}
def renderContent(self):
- self.startingPositionIndicators = NotifyIntVar()
- self.finishingPositionIndicators = NotifyIntVar()
+ self.startingPositionIndicators = NotifyBoolVar()
+ self.finishingPositionIndicators = NotifyBoolVar()
self.boxWidth = NotifyNumericVar()
self.boxHeight = NotifyNumericVar()
self.boxMargin = NotifyNumericVar()
- self.shortenTeamNames = NotifyIntVar()
+ self.shortenTeamNames = NotifyBoolVar()
self.teamNameLength = NotifyNumericVar()
self.teamNameEllipsis = NotifyStringVar()
- self.teamNamePredict = NotifyIntVar()
+ self.teamNamePredict = NotifyBoolVar()
self.teamNamePlaceholder = NotifyStringVar()
- self.teamNameSortPredictions = NotifyIntVar()
+ self.teamNameSortPredictions = NotifyBoolVar()
self.teamLabelSeparator = NotifyStringVar()
self.teamNameSeparator = NotifyStringVar()
self.teamNamePrefix = NotifyStringVar()
diff --git a/jfr_playoff/gui/tabs.py b/jfr_playoff/gui/tabs.py
index 3ebc5be..9d71465 100644
--- a/jfr_playoff/gui/tabs.py
+++ b/jfr_playoff/gui/tabs.py
@@ -14,7 +14,7 @@ from .frames.network import *
from .frames.team import *
from .frames.translations import *
from .frames.visual import *
-from .variables import NotifyStringVar, NotifyIntVar, NotifyNumericVar
+from .variables import NotifyStringVar, NotifyNumericVar, NotifyBoolVar
from ..data import PlayoffData
from ..db import PlayoffDB
@@ -54,7 +54,7 @@ class MainSettingsTab(PlayoffTab):
self.outputPath = NotifyStringVar()
self.pageTitle = NotifyStringVar()
self.pageLogoh = NotifyStringVar()
- self.refresh = NotifyIntVar()
+ self.refresh = NotifyBoolVar()
self.refresh.trace('w', self._updateRefreshFields)
self.refreshInterval = NotifyNumericVar()
diff --git a/jfr_playoff/gui/variables.py b/jfr_playoff/gui/variables.py
index 9dcbff2..7e6989c 100644
--- a/jfr_playoff/gui/variables.py
+++ b/jfr_playoff/gui/variables.py
@@ -26,6 +26,11 @@ class NotifyStringVar(NotifyVar, tk.StringVar):
class NotifyIntVar(NotifyVar, tk.IntVar):
pass
+class NotifyBoolVar(NotifyVar, tk.StringVar):
+ def get(self, *args, **kwargs):
+ value = tk.StringVar.get(self, *args, **kwargs)
+ return int(value == '1')
+
class NotifyNumericVar(NumericVar, NotifyVar):
def __init__(self, *args, **kwargs):
NotifyVar.__init__(self, *args, **kwargs)