@@ -40,37 +40,58 @@ def convert_rgb_to_rgb332(image_load, path_file):
40
40
def program_menu ():
41
41
#Simple menu with options to execute
42
42
43
- while True :
44
-
45
- print (' Converter RGB to RGB332:' )
46
- print (' [1] -- Select an image --' )
47
- print (' [2] -- Save as a file --' )
48
- print (' [3] -- Exit program --' )
43
+ try :
44
+ while True :
45
+
46
+ print (' Converter RGB to RGB332:' )
47
+ print (' [1] -- Select an image --' )
48
+ print (' [2] -- Save as a file --' )
49
+ print (' [3] -- Exit program --' )
49
50
50
- option = input (' Please choose an option [1-3]: ' )
51
+ option = input (' Please choose an option [1-3]: ' )
51
52
52
- if option == '1' :
53
+ if option == '1' :
54
+
55
+ try :
56
+ print (' [First option has selected]' )
57
+ im_path = im_load ()
58
+ print ('\n [INFO]: Image has loaded from: ' + im_path + '\n ' )
59
+ except TypeError :
60
+ print ()
61
+ print (' [WARN]: Please choose an image to load \n ' )
53
62
54
- print (' [First option has selected]' )
55
- im_path = im_load ()
56
- print ('\n INFO: Image has loaded from: ' + im_path + '\n ' )
63
+ elif option == '2' :
64
+
65
+ try :
66
+ print (' [Second option has selected]' )
67
+ save_output = file_save ()
68
+ convert_rgb_to_rgb332 (im_path , save_output )
69
+ print ('\n [INFO]: File has saved in: ' + save_output + '\n ' )
70
+ except TypeError :
71
+ print ()
72
+ print (' [WARN]: Something went wrong, please try again \n ' )
73
+
74
+ except UnboundLocalError :
75
+ print ()
76
+ print (' [WARN]: No data to save, please load image first to the program \n ' )
57
77
58
- elif option == '2' :
59
-
60
- print (' [Second option has selected]' )
61
- save_output = file_save ()
62
- convert_rgb_to_rgb332 (im_path , save_output )
63
- print ('\n [INFO]: File has saved in: ' + save_output + '\n ' )
78
+ elif option == '3' :
79
+
80
+ print (' Third option has selected' )
81
+ print ('\n [INFO]: Program has closed \n ' )
82
+ exit ()
64
83
65
- elif option == '3' :
66
-
67
- print (' Third option has selected' )
68
- print ('\n [INFO]: Program has closed \n ' )
69
- exit ()
84
+ else :
70
85
71
- else :
86
+ print ( ' \n [WARNING]: Something went wrong, please choose option again \n ' )
72
87
73
- print ('\n [WARNING]: Something went wrong, please choose option again \n ' )
88
+ except EOFError :
89
+ print ()
90
+ print (' [ERROR]: Unexpected action in program' )
91
+ except KeyboardInterrupt :
92
+ print ()
93
+ print (' [INFO]: Program has closed unexpected ' )
94
+ exit ()
74
95
75
96
msg = open ("non-GUI/logo" , "r" )
76
97
print (msg .read ())
0 commit comments