From fa1821d6a68c2d09763a8c0fc30f6105d07bdd1c Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Mon, 18 Oct 2021 14:23:31 -0400 Subject: [PATCH] set openfile on cli --- jam | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/jam b/jam index c34f042..2cb5a57 100755 --- a/jam +++ b/jam @@ -4,6 +4,7 @@ from kivy.app import App from kivy.uix.widget import Widget from kivy.uix.boxlayout import BoxLayout from kivy.config import Config +import sys from cross import Cross,Cross_painter from status_bar import Status_bar @@ -14,12 +15,16 @@ class Jam_app(App): # name of .kv file for main interface kv_file="jam.kv" + def __init__(self,**kwargs): + # the file open for editing + self.openfile=kwargs.get("openfile","") + + super(Jam_app,self).__init__() + + def build(self): layout=BoxLayout(orientation="vertical") - # the file open for editing - self.openfile="" - # painter self.painter=Cross_painter(self) # status bar @@ -39,6 +44,11 @@ Config.set('input', 'mouse', 'mouse,disable_multitouch') # do not exit on escape Config.set('kivy', 'exit_on_escape', 0) +# read cli +openfile="" +if len(sys.argv)==2: + openfile=sys.argv[1] + # run if __name__ == '__main__': - Jam_app().run() + Jam_app(openfile=openfile).run()