summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-05-25 03:16:21 +0200
committeremkael <emkael@tlen.pl>2019-05-25 03:16:21 +0200
commit9aef8ec85fa1b4b8db4274c33b99e5773f4f4242 (patch)
treed0af8a5704e28dabc2dc48043fcbedb73001d14c
parentdd7902ef7b46f598973cf85541d2e5f63ec2943d (diff)
Basic GUI structure:
* main window with tab manager * page settings tab
-rw-r--r--gui.py4
-rw-r--r--jfr_playoff/gui/__init__.py16
-rw-r--r--jfr_playoff/gui/tabs.py128
3 files changed, 148 insertions, 0 deletions
diff --git a/gui.py b/gui.py
new file mode 100644
index 0000000..3677b41
--- /dev/null
+++ b/gui.py
@@ -0,0 +1,4 @@
+from jfr_playoff.gui import PlayoffGUI
+
+gui = PlayoffGUI()
+gui.run()
diff --git a/jfr_playoff/gui/__init__.py b/jfr_playoff/gui/__init__.py
new file mode 100644
index 0000000..d9c455d
--- /dev/null
+++ b/jfr_playoff/gui/__init__.py
@@ -0,0 +1,16 @@
+import tkinter as tk
+from tkinter import ttk
+
+from .tabs import *
+
+class PlayoffGUI(object):
+ def __init__(self):
+ self.root = tk.Tk()
+
+ def run(self):
+ self.notebook = ttk.Notebook(self.root)
+ self.notebook.pack(fill=tk.BOTH, expand=True)
+ for tab in tabs.__all__:
+ tabObj = globals()[tab](self.notebook)
+ self.notebook.add(tabObj, text=tabObj.title)
+ self.root.mainloop()
diff --git a/jfr_playoff/gui/tabs.py b/jfr_playoff/gui/tabs.py
new file mode 100644
index 0000000..ab70968
--- /dev/null
+++ b/jfr_playoff/gui/tabs.py
@@ -0,0 +1,128 @@
+#coding=utf-8
+
+import os
+
+import tkinter as tk
+from tkinter import ttk
+import tkFileDialog as tkfd
+
+class PlayoffTab(ttk.Frame):
+ def __init__(self, master):
+ ttk.Frame.__init__(self, master)
+ self.frame = ttk.Frame(self)
+ self.frame.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
+ self.renderContent(self.frame)
+
+ @property
+ def title(self):
+ pass
+
+ def renderContent(self, container):
+ pass
+
+class MainSettingsTab(PlayoffTab):
+ @property
+ def title(self):
+ return 'Główne ustawienia'
+
+ def _chooseOutputPath(self):
+ currentPath = self.outputPath.get()
+ filename = tkfd.asksaveasfilename(
+ initialdir=os.path.dirname(currentPath) if currentPath else '.',
+ title='Wybierz plik wyjściowy',
+ filetypes=(('HTML files', '*.html'),))
+ if filename:
+ if not filename.lower().endswith('.html'):
+ filename = filename + '.html'
+ self.outputPath.set(filename)
+
+ def _updateRefreshFields(self):
+ self.refreshInterval.configure(
+ state=tk.NORMAL if self.refresh.get() else tk.DISABLED)
+
+ def renderContent(self, container):
+ (ttk.Label(container, text='Plik wynikowy:')).grid(
+ row=0, column=0, sticky=tk.E, pady=2)
+ outputPath = tk.Frame(container)
+ outputPath.grid(row=0, column=1, sticky=tk.E+tk.W, pady=2)
+ self.outputPath = tk.StringVar()
+ (tk.Entry(outputPath, width=60, textvariable=self.outputPath)).grid(
+ row=0, column=0, sticky=tk.W+tk.E)
+ (tk.Button(
+ outputPath,
+ text='[]', command=self._chooseOutputPath)).grid(row=0, column=1)
+ outputPath.columnconfigure(0, weight=1)
+
+ (ttk.Separator(container, orient=tk.HORIZONTAL)).grid(
+ row=1, column=0, columnspan=2, sticky=tk.E+tk.W, pady=2)
+
+ (ttk.Label(container, text='Ustawienia strony')).grid(
+ row=2, column=0, columnspan=2, sticky=tk.W, pady=5)
+ (ttk.Label(container, text='Tytuł:')).grid(
+ row=3, column=0, sticky=tk.E, pady=2)
+ self.pageTitle = tk.StringVar()
+ (tk.Entry(container, textvariable=self.pageTitle)).grid(
+ row=3, column=1, sticky=tk.W+tk.E, pady=2)
+ (ttk.Label(container, text='Logoh:')).grid(
+ row=4, column=0, sticky=tk.E+tk.N, pady=2)
+ self.pageLogoh = tk.Text(container, width=45, height=10)
+ self.pageLogoh.grid(
+ row=4, column=1,
+ sticky=tk.W+tk.N+tk.E+tk.S, pady=2)
+
+ (ttk.Label(container, text='Odświeżaj:')).grid(
+ row=5, column=0, sticky=tk.E, pady=2)
+ refreshPanel = tk.Frame(container)
+ refreshPanel.grid(row=5, column=1, sticky=tk.W+tk.E, pady=2)
+ self.refresh = tk.IntVar()
+ (tk.Checkbutton(
+ refreshPanel,
+ command=self._updateRefreshFields, variable=self.refresh)).grid(
+ row=0, column=0)
+ (ttk.Label(refreshPanel, text='co:')).grid(row=0, column=1)
+ self.refreshInterval = tk.Spinbox(
+ refreshPanel, from_=30, to=3600, width=5)
+ self.refreshInterval.grid(row=0, column=2)
+ (ttk.Label(refreshPanel, text='sekund')).grid(row=0, column=3)
+ self._updateRefreshFields()
+
+ container.columnconfigure(1, weight=1)
+ container.rowconfigure(4, weight=1)
+
+class TeamsTab(PlayoffTab):
+ @property
+ def title(self):
+ return 'Uczestnicy'
+
+class MatchesTab(PlayoffTab):
+ @property
+ def title(self):
+ return 'Mecze'
+
+class SwissesTab(PlayoffTab):
+ @property
+ def title(self):
+ return 'Swissy'
+
+class NetworkTab(PlayoffTab):
+ @property
+ def title(self):
+ return 'Sieć'
+
+class VisualTab(PlayoffTab):
+ @property
+ def title(self):
+ return 'Wygląd'
+
+class StyleTab(PlayoffTab):
+ @property
+ def title(self):
+ return 'Style'
+
+class TranslationsTab(PlayoffTab):
+ @property
+ def title(self):
+ return 'Tłumaczenia'
+
+__all__ = ['MainSettingsTab', 'TeamsTab', 'MatchesTab', 'SwissesTab',
+ 'NetworkTab', 'VisualTab', 'StyleTab', 'TranslationsTab']