diff options
author | emkael <emkael@tlen.pl> | 2019-06-27 13:43:37 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-06-27 13:43:37 +0200 |
commit | 18862958e3f6a99e25aa7db836604c9b9425ea1b (patch) | |
tree | af802bc380274204f6b8d9d2eff5210848dd8512 /jfr_playoff/gui/__init__.py | |
parent | 06dbe4b0a0021ab6e96324dfd729f7b4b9c60101 (diff) |
Opening file from command line argument
Diffstat (limited to 'jfr_playoff/gui/__init__.py')
-rw-r--r-- | jfr_playoff/gui/__init__.py | 12 |
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() |