forked from nachifur/MulimgViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MulimgViewer.py
86 lines (67 loc) · 2.31 KB
/
MulimgViewer.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
import wx
from main import MulimgViewer
from path_select import PathSelectFrame
import wx.lib.inspection
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
class GuiManager():
def __init__(self, UpdateUI, get_type):
self.UpdateUI = UpdateUI
self.get_type = get_type
self.frameDict = {}
def GetFrame(self, type):
frame = self.frameDict.get(type)
if frame is None:
frame = self.CreateFrame(type)
self.frameDict[type] = frame
return frame
def CreateFrame(self, type):
if type == 0:
return MulimgViewer(None, self.UpdateUI, self.get_type)
elif type == 1:
return PathSelectFrame(None, self.UpdateUI, self.get_type)
class MainAPP(wx.App):
def OnInit(self):
self.manager = GuiManager(self.UpdateUI, self.get_type)
self.frame = []
self.frame.append(self.manager.GetFrame(0))
self.frame.append(self.manager.GetFrame(1))
self.frame[0].Show()
self.SetTopWindow(self.frame[0])
self.type = 0 # init show MulimgViewer
return True
def UpdateUI(self, type, input_path=None, parallel_to_sequential=False):
# type=1: PathSelectFrame
# type=0: MulimgViewer
# type=-1: Close
self.type = type
if input_path != None:
if len(input_path) != 0:
# refresh one_dir_mul_dir_manual path
self.frame[0].ImgManager.init(
input_path, 1, parallel_to_sequential)
self.frame[1].refresh_txt(input_path)
self.frame[0].show_img_init()
self.frame[0].ImgManager.set_action_count(0)
self.frame[0].show_img()
if type == -1:
# close window
self.frame[0].close(None)
self.frame[1].close(None)
elif type == 0:
# hidden PathSelectFrame, show MulimgViewer
self.frame[1].Show(False)
self.frame[type].Show(True)
elif type == 1:
# show PathSelectFrame
self.frame[type].Show(True)
return True
def get_type(self):
return self.type
def main():
app = MainAPP()
# debug
# wx.lib.inspection.InspectionTool().Show()
app.MainLoop()
if __name__ == '__main__':
main()