-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·109 lines (73 loc) · 2.63 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.factory import Factory
from kivy.properties import ObjectProperty
from kivy.uix.popup import Popup
from kivy.properties import StringProperty
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.uix.filechooser import FileChooser
from kivy.lang import Builder
import STest
import os
class Mainscrn(ScreenManager):
pass
class FullImage(FloatLayout):
cancel = ObjectProperty(None)
pass
class LoadDialog(FloatLayout):
load = ObjectProperty(None)
cancel = ObjectProperty(None)
class SaveDialog(FloatLayout):
save = ObjectProperty(None)
text_input = ObjectProperty(None)
cancel = ObjectProperty(None)
class Root(Screen):
loadfile = ObjectProperty(None)
savefile = ObjectProperty(None)
text_input = ObjectProperty(None)
def dismiss_popup(self):
self._popup.dismiss()
def show_live(self):
STest.slrlive()
def show_load(self):
content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
self._popup = Popup(title="Load file", content=content,
size_hint=(0.9, 0.9))
self._popup.open()
def show_save(self):
content = SaveDialog(save=self.save, cancel=self.dismiss_popup)
self._popup = Popup(title="Save file", content=content,
size_hint=(0.9, 0.9))
self._popup.open()
def load(self, path, filename):
print(path, filename)
with open(os.path.join(path, filename[0])) as stream:
# self.text_input.text = stream.read()
self.text_input.text = filename[0]
self.dismiss_popup()
pred = STest.slrtest(filename[0])
#print(pred[0])
da = filename[0].replace('\\', '\\\\')
self.parent.ids.SLR.val = str(pred[0])
self.parent.ids.SLR.sour = da
#Mainscrn.img = da
#print(str(Mainscrn.img))
def save(self, path, filename):
with open(os.path.join(path, filename), 'w') as stream:
stream.write(self.text_input.text)
self.dismiss_popup()
pass
class SLRGui(Screen):
val= StringProperty('')
sour=StringProperty('')
pass
presentation = Builder.load_file("editor.kv")
class Editor(App):
def build(self):
Editor.id = 'afd'
return presentation
Factory.register('Root', cls=Root)
Factory.register('LoadDialog', cls=LoadDialog)
Factory.register('SaveDialog', cls=SaveDialog)
if __name__ == '__main__':
Editor().run()