summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-06-27 13:43:37 +0200
committeremkael <emkael@tlen.pl>2019-06-27 13:43:37 +0200
commit18862958e3f6a99e25aa7db836604c9b9425ea1b (patch)
treeaf802bc380274204f6b8d9d2eff5210848dd8512 /jfr_playoff
parent06dbe4b0a0021ab6e96324dfd729f7b4b9c60101 (diff)
Opening file from command line argument
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/gui/__init__.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/jfr_playoff/gui/__init__.py b/jfr_playoff/gui/__init__.py
index bf81285..0b17b2e 100644
--- a/jfr_playoff/gui/__init__.py
+++ b/jfr_playoff/gui/__init__.py
@@ -1,4 +1,4 @@
-import json
+import json, sys
import tkinter as tk
from tkinter import ttk
@@ -20,7 +20,10 @@ class PlayoffGUI(tk.Tk):
for tab in tabs.__all__:
self.tabs[tab] = globals()[tab](self.notebook)
self.notebook.add(self.tabs[tab], text=self.tabs[tab].title)
- self.newFile()
+ if len(sys.argv) > 1:
+ self.openFile(sys.argv[1])
+ else:
+ self.newFile()
self.mainloop()
def _setValues(self, config):
@@ -28,13 +31,16 @@ class PlayoffGUI(tk.Tk):
tab.setValues(config)
def _resetValues(self):
- self._setValues(json.load(open('../pzbs-liga-playoff/eklasa.json')))
+ self._setValues({})
def newFile(self):
self.newFileIndex += 1
self.title('Nowa drabinka %d' % (self.newFileIndex))
self._resetValues()
+ def openFile(self, filepath):
+ self._setValues(json.load(open(filepath)))
+
def getDbConfig(self):
return self.tabs['NetworkTab'].getDB()