From 18862958e3f6a99e25aa7db836604c9b9425ea1b Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 27 Jun 2019 13:43:37 +0200 Subject: Opening file from command line argument --- jfr_playoff/gui/__init__.py | 12 +++++++++--- 1 file 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() -- cgit v1.2.3