summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--playoff_gui.py95
-rw-r--r--resources.py31
3 files changed, 114 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0d20b64
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.pyc
diff --git a/playoff_gui.py b/playoff_gui.py
index 216cb2c..6ebd516 100644
--- a/playoff_gui.py
+++ b/playoff_gui.py
@@ -2,7 +2,7 @@
import random
-import tkinter as tk
+import Tix as tk
class PlayoffGUI(tk.Frame):
@@ -44,22 +44,57 @@ class PlayoffGUI(tk.Frame):
self.phase_count = 0
def add_phase(self, phase):
- phase.grid(row=0, column=self.phase_count)
+ phase.grid(row=0, column=self.phase_count, sticky=tk.N, padx=10, pady=10)
self.phase_count += 1
class PlayoffPhaseGUI(tk.Frame):
def __init__(self, *args, **kwargs):
tk.Frame.__init__(self, *args, **kwargs)
self.match_count = 0
+ self.title = tk.StringVar(self)
+
+ from resources import EDIT_ICON, PLUS_ICON, MINUS_ICON, NEXT_ICON
+
+ self.add_btn = tk.Button(
+ self, image=PLUS_ICON)
+ self.add_btn.grid(column=0, row=0)
+
+ self.header_frame = tk.Frame(self)
+ self.header_frame.grid(row=0, column=0, sticky=tk.N+tk.S+tk.E+tk.W)
+
+ self.title_label = tk.Label(
+ self.header_frame, textvariable=self.title,
+ font=('Arial', 18), width=22, borderwidth=3, relief=tk.GROOVE
+ )
+ self.title_label.grid(
+ row=0, rowspan=2, column=1,
+ sticky=tk.N+tk.S+tk.E+tk.W
+ )
+ self.remove_btn = tk.Button(
+ self.header_frame, image=MINUS_ICON)
+ self.remove_btn.grid(row=0, column=0)
+ self.title_edit_btn = tk.Button(
+ self.header_frame, image=EDIT_ICON)
+ self.title_edit_btn.grid(row=1, column=0)
+ self.new_btn = tk.Button(
+ self.header_frame, image=PLUS_ICON)
+ self.new_btn.grid(row=0, column=2, sticky=tk.S+tk.W)
+ self.write_btn = tk.Button(
+ self.header_frame, image=NEXT_ICON)
+ self.write_btn.grid(row=1, column=2, sticky=tk.N+tk.W)
+
def add_match(self, match):
- match.grid(column=0, row=self.match_count)
+ match.grid(column=0, row=self.match_count+1, pady=10)
self.match_count += 1
+ self.add_btn.grid(column=0, row=self.match_count+1)
class PlayoffMatchGUI(tk.Frame):
def __init__(self, *args, **kwargs):
tk.Frame.__init__(self, *args, **kwargs)
+ self.match_id = tk.StringVar(master=self)
+ self.match_title = tk.StringVar(master=self)
self.table = tk.StringVar(master=self)
self.team_names = [
tk.StringVar(master=self),
@@ -69,38 +104,71 @@ class PlayoffMatchGUI(tk.Frame):
tk.DoubleVar(master=self),
tk.DoubleVar(master=self)
]
- self.winners = tk.StringVar
- self.losers = tk.StringVar
+ self.winners = tk.StringVar(master=self)
+ self.losers = tk.StringVar(master=self)
self.phase = kwargs['phase'] if 'phase' in kwargs else None
self.__create_widgets()
def __create_widgets(self):
+ from resources import EDIT_ICON, MINUS_ICON
+
+ id_label = tk.Label(
+ self, textvariable=self.match_id)
+ id_label.grid(row=0, column=0)
+ remove_btn = tk.Button(
+ self, image=MINUS_ICON)
+ remove_btn.grid(row=1, column=0, sticky=tk.N)
+
+ title_label = tk.Label(
+ self, textvariable=self.match_title,
+ font=('Arial', 16), borderwidth=3, relief=tk.GROOVE)
+ title_label.grid(row=0, column=1, columnspan=3, sticky=tk.W+tk.E)
+ title_edit_btn = tk.Button(
+ self, image=EDIT_ICON)
+ title_edit_btn.grid(row=0, column=4, sticky=tk.W)
+
for row in range(0, 2):
team_label = tk.Label(
self, textvariable=self.team_names[row],
- font=('Arial', 16))
- team_label.grid(row=row, column=1)
+ font=('Arial', 16), width=20, borderwidth=3, relief=tk.GROOVE)
+ team_label.grid(row=row+1, column=1)
if self.phase is not None and self.phase.number == 1:
team_edit_btn = tk.Button(
self, text='#')
- team_edit_btn.grid(row=row, column=2)
+ team_edit_btn.grid(row=row+1, column=2)
score_label = tk.Label(
self, textvariable=self.team_results[row],
- font=('Arial', 16))
- score_label.grid(row=row, column=3)
+ font=('Arial', 16), borderwidth=3, relief=tk.GROOVE)
+ score_label.grid(row=row+1, column=3)
+
table_label = tk.Label(
self, textvariable=self.table)
- table_label.grid(row=2, column=1, columnspan=3)
+ table_label.grid(row=3, column=1, columnspan=3)
+ edit_table_btn = tk.Button(
+ self, image=EDIT_ICON)
+ edit_table_btn.grid(row=3, column=4, sticky=tk.W)
+
+ winners_btn = tk.Button(
+ self, textvariable=self.winners,
+ font=('Arial', 8), width=6)
+ winners_btn.grid(row=1, column=4, sticky=tk.S+tk.W)
+ losers_btn = tk.Button(
+ self, textvariable=self.losers,
+ font=('Arial', 8), width=6)
+ losers_btn.grid(row=2, column=4, sticky=tk.N+tk.W)
def set_data(self, match):
+ self.match_id.set('#%d' % match.id_number)
self.table.set('%s, R%d, T%d' % (match.database_name,
match.round_no,
match.table_no))
for team in range(0, 2):
self.team_names[team].set('Team A/Team B')
self.team_results[team].set('%.2f' % random.uniform(10.0, 30.0))
+ self.winners.set('W (%d)' % len(match.winner))
+ self.losers.set('L (%d)' % len(match.loser))
def get_match(self, match):
pass
@@ -121,10 +189,11 @@ root.state('zoomed')
frame = PlayoffGUI(master=root)
-for j in range(0, 9):
+for j in range(0, random.randint(1, 8)):
phase_gui = PlayoffPhaseGUI(master=frame)
- for i in range(0, 10):
+ for i in range(0, random.randint(1, 12)):
match = PlayoffMatch()
+ match.id_number = random.randint(0, 128)
match.database_name = 'ivld_r3'
match.round_no = 1
match.table_no = 1
diff --git a/resources.py b/resources.py
new file mode 100644
index 0000000..5e14aed
--- /dev/null
+++ b/resources.py
@@ -0,0 +1,31 @@
+import Tix as tk
+
+EDIT_ICON = tk.PhotoImage(data='''
+R0lGODlhEAAQAOMIAMcAAJp5APGRAP+XAP+YAP+eAP+9AP+/AP//////////////////////////////
+/yH5BAEKAAgALAAAAAAQABAAAAQkEMlJq70Yg3w3R4PwSQMxjCWBEuqXri33fuz5GUXMBcfo/5UIADs=
+''')
+MINUS_ICON = tk.PhotoImage(data='''
+R0lGODlhEAAQAMIGAPAQAPEQAPIQAPARAPERAPIRAP///////yH5BAEKAAcALAAAAAAQABAAAAM1eLrc
+fmQM8hYIOIOXe26X122LKJamRx0CVjgFRoZvEwckkXbrsX+W36Dxe4Q6wwpEIOgpnwkAOw==
+''')
+NEXT_ICON = tk.PhotoImage(data='''
+R0lGODlhEAAQAKEDAD9QtT5RtT9Rtf///yH5BAEKAAMALAAAAAAQABAAAAIbnI+py+3PAjwCzCFyyrxz
+5IUC9JHjJF3qyioFADs=
+''')
+PLUS_ICON = tk.PhotoImage(data='''
+R0lGODlhEAAQAMIFAACMBQCMBgCNBQCNBgCNB////////////yH5BAEKAAcALAAAAAAQABAAAAM0eLrc
+fmIM8VaUmDrMcbuS0jHjUR5E2WlB+EjaVXmQymkmJ+oWzwGNzokkBFYOgEDAeGweEgA7
+''')
+REFRESH_ICON = tk.PhotoImage(data='''
+R0lGODlhEAAQAMIHAABVugBWuQBWugBXugBXuwBYuQBYu////yH5BAEKAAcALAAAAAAQABAAAAMteLrc
+PjC6NQQLY1YXyptgBn6T0UAANwQMATnAy6TaSNrUwzaEp7ciTWTgw4ESADs=
+''')
+RESTART_ICON = tk.PhotoImage(data='''
+R0lGODlhEAAQAOMOAE2XAE+XAE6YAE+YAE2ZAE6ZAE+ZAFCZAE2aAE+aAFCaAFCcAFGcAFKdAP//////
+/yH5BAEKAA8ALAAAAAAQABAAAARC8MlJq734gSG6yF74WaJYAYIhhUVHccrqPrP8NG1X0KPNhAQepcPg
+dRbCSecgSRiQh5psN4kKAqSSAIEpYTPgcCUCADs=
+''')
+SYNC_ICON = tk.PhotoImage(data='''
+R0lGODlhEAAQAMIEAP9tAP9uAP9vAP9wAP///////////////yH5BAEKAAQALAAAAAAQABAAAAMvSLrc
+/pAEQaMSg4UNmniblznAxHwRelkq0Trt2wTaQDvDG3r3Uu4Kk2UCtBiPhAQAOw==
+''')