diff --git a/output.json b/output.json index 8ca6a27..9295b89 100644 --- a/output.json +++ b/output.json @@ -1 +1,46 @@ -{"row_col": "1,1", "row_col_one_img": "1,1", "show_scale": "1,1", "row_col_img_unit": "3,1", "gap": "10,10,5,5,3,3,2,2", "magnifer_row_col": "1,1", "output_scale": "1,1", "img_resolution": "-1,-1", "magnifer_resolution": "-1,-1", "magnifier_show_scale": "-1,-1", "line_width": "2,2", "magnifier_out_scale": "1,1", "title_font_size": "20", "box_position": 0, "choice_normalized_size": 0, "choice_output": 0, "image_interp": 2, "Magnifier_format": 1, "title_font": 0, "parallel_sequential": false, "parallel_to_sequential": false, "auto_save_all": false, "move_file": false, "img_vertical": false, "one_img_vertical": false, "img_unit_vertical": false, "magnifer_vertical": true, "show_original": true, "show_magnifer": true, "title_show": true, "auto_layout_check": false, "one_img": false, "onetitle": false, "customfunc": false, "show_box": true, "show_box_in_crop": true, "select_img_box": false, "title_auto": false, "title_exif": false, "title_show_parent": false, "title_show_prefix": true, "title_show_name": true, "title_show_suffix": false, "title_down_up": false} \ No newline at end of file +{ + "row_col": "1,1", + "row_col_one_img": "1,1", + "show_scale": "1,1", + "row_col_img_unit": "3,1", + "gap": "10,10,5,5,3,3,2,2", + "magnifer_row_col": "1,1", + "output_scale": "1,1", + "img_resolution": "-1,-1", + "magnifer_resolution": "-1,-1", + "magnifier_show_scale": "-1,-1", + "line_width": "2,2", + "magnifier_out_scale": "1,1", + "title_font_size": "20", + "box_position": 0, + "choice_normalized_size": 0, + "choice_output": 0, + "image_interp": 2, + "Magnifier_format": 1, + "title_font": 0, + "parallel_sequential": false, + "parallel_to_sequential": false, + "auto_save_all": false, + "move_file": false, + "img_vertical": false, + "one_img_vertical": false, + "img_unit_vertical": false, + "magnifer_vertical": true, + "show_original": true, + "show_magnifer": true, + "title_show": true, + "auto_layout_check": false, + "one_img": false, + "onetitle": false, + "customfunc": false, + "show_box": true, + "show_box_in_crop": true, + "select_img_box": false, + "title_auto": false, + "title_exif": false, + "title_show_parent": false, + "title_show_prefix": true, + "title_show_name": true, + "title_show_suffix": false, + "title_down_up": false +} \ No newline at end of file diff --git a/output_s.json b/output_s.json new file mode 100644 index 0000000..de36b53 --- /dev/null +++ b/output_s.json @@ -0,0 +1,46 @@ +{ + "row_col": "1,1", + "row_col_one_img": "1,1", + "show_scale": "1,1", + "row_col_img_unit": "3,1", + "gap": "10,10,5,5,3,3,2,2", + "magnifer_row_col": "1,1", + "output_scale": "1,1", + "img_resolution": "-1,-1", + "magnifer_resolution": "-1,-1", + "magnifier_show_scale": "-1,-1", + "line_width": "2,2", + "magnifier_out_scale": "1,1", + "title_font_size": "20", + "box_position": 0, + "choice_normalized_size": 0, + "choice_output": 0, + "image_interp": 2, + "Magnifier_format": 1, + "title_font": 0, + "parallel_sequential": false, + "parallel_to_sequential": false, + "auto_save_all": false, + "move_file": false, + "img_vertical": false, + "one_img_vertical": false, + "img_unit_vertical": false, + "magnifer_vertical": true, + "show_original": true, + "show_magnifer": true, + "title_show": true, + "auto_layout_check": false, + "one_img": false, + "onetitle": false, + "customfunc": false, + "show_box": true, + "show_box_in_crop": true, + "select_img_box": false, + "title_auto": false, + "title_exif": false, + "title_show_parent": false, + "title_show_prefix": true, + "title_show_name": true, + "title_show_suffix": false, + "title_down_up": false + } \ No newline at end of file diff --git a/src/mulimgviewer/gui/main_gui.fbp b/src/mulimgviewer/gui/main_gui.fbp index e26cfca..c2ef727 100644 --- a/src/mulimgviewer/gui/main_gui.fbp +++ b/src/mulimgviewer/gui/main_gui.fbp @@ -2693,7 +2693,7 @@ 0 0 wxID_ANY - LayoutConfig + Config 0 0 @@ -2785,7 +2785,82 @@ 5 wxALL|wxALIGN_CENTER_VERTICAL 0 - + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Load + + 0 + + 0 + + + 0 + + 1 + m_button7 + 1 + + + protected + 1 + -1,-1 + + + Resizable + 1 + 50,-1 + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + load_configuration + + + + 5 + wxALL + 0 + 1 1 1 @@ -2794,6 +2869,7 @@ 0 0 + 0 @@ -2804,6 +2880,7 @@ 1 + 0 0 Dock @@ -2828,7 +2905,7 @@ 0 1 - m_toggleBtn4 + m_button9 1 @@ -2840,6 +2917,7 @@ Resizable 1 50,-1 + ; ; forward_declare 0 @@ -2847,16 +2925,15 @@ wxFILTER_NONE wxDefaultValidator - 1 - save_configuration + save_configuration 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxALL 0 1 @@ -2893,7 +2970,7 @@ 0 0 wxID_ANY - Load + Reset 0 @@ -2903,13 +2980,13 @@ 0 1 - m_button7 + m_button8 1 protected 1 - -1,-1 + Resizable @@ -2926,7 +3003,7 @@ - load_configuration + reset_configuration diff --git a/src/mulimgviewer/gui/main_gui.py b/src/mulimgviewer/gui/main_gui.py index 8743236..1a10dac 100644 --- a/src/mulimgviewer/gui/main_gui.py +++ b/src/mulimgviewer/gui/main_gui.py @@ -235,7 +235,7 @@ def __init__( self, parent ): wSizer112 = wx.WrapSizer( wx.HORIZONTAL, wx.WRAPSIZER_DEFAULT_FLAGS ) - self.m_staticText361 = wx.StaticText( self.m_panel4, wx.ID_ANY, u"LayoutConfig", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText361 = wx.StaticText( self.m_panel4, wx.ID_ANY, u"Config", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText361.Wrap( -1 ) wSizer112.Add( self.m_staticText361, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) @@ -243,13 +243,15 @@ def __init__( self, parent ): self.m_staticline201 = wx.StaticLine( self.m_panel4, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL ) wSizer112.Add( self.m_staticline201, 0, wx.EXPAND |wx.ALL, 5 ) - self.m_toggleBtn4 = wx.ToggleButton( self.m_panel4, wx.ID_ANY, u"Save", wx.DefaultPosition, wx.Size( 50,-1 ), 0 ) - self.m_toggleBtn4.SetValue( True ) - wSizer112.Add( self.m_toggleBtn4, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - self.m_button7 = wx.Button( self.m_panel4, wx.ID_ANY, u"Load", wx.Point( -1,-1 ), wx.Size( 50,-1 ), 0 ) wSizer112.Add( self.m_button7, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + self.m_button9 = wx.Button( self.m_panel4, wx.ID_ANY, u"Save", wx.DefaultPosition, wx.Size( 50,-1 ), 0 ) + wSizer112.Add( self.m_button9, 0, wx.ALL, 5 ) + + self.m_button8 = wx.Button( self.m_panel4, wx.ID_ANY, u"Reset", wx.DefaultPosition, wx.Size( 50,-1 ), 0 ) + wSizer112.Add( self.m_button8, 0, wx.ALL, 5 ) + fgSizer3.Add( wSizer112, 1, wx.EXPAND, 5 ) @@ -810,8 +812,9 @@ def __init__( self, parent ): self.choice_normalized_size.Bind( wx.EVT_CHOICE, self.change_img_stitch_mode ) self.parallel_sequential.Bind( wx.EVT_CHECKBOX, self.parallel_sequential_fc ) self.parallel_to_sequential.Bind( wx.EVT_CHECKBOX, self.parallel_to_sequential_fc ) - self.m_toggleBtn4.Bind( wx.EVT_TOGGLEBUTTON, self.save_configuration ) self.m_button7.Bind( wx.EVT_BUTTON, self.load_configuration ) + self.m_button9.Bind( wx.EVT_BUTTON, self.save_configuration ) + self.m_button8.Bind( wx.EVT_BUTTON, self.reset_configuration ) self.select_img_box.Bind( wx.EVT_CHECKBOX, self.select_img_box_func ) self.title_auto.Bind( wx.EVT_CHECKBOX, self.title_auto_fc ) self.title_down_up.Bind( wx.EVT_CHECKBOX, self.title_down_up_fc ) @@ -894,10 +897,13 @@ def parallel_sequential_fc( self, event ): def parallel_to_sequential_fc( self, event ): event.Skip() + def load_configuration( self, event ): + event.Skip() + def save_configuration( self, event ): event.Skip() - def load_configuration( self, event ): + def reset_configuration( self, event ): event.Skip() def select_img_box_func( self, event ): diff --git a/src/mulimgviewer/src/main.py b/src/mulimgviewer/src/main.py index 841bfd8..d9f5d58 100644 --- a/src/mulimgviewer/src/main.py +++ b/src/mulimgviewer/src/main.py @@ -13,6 +13,7 @@ from .utils import MyTestEvent, get_resource_path from .utils_img import ImgManager import json +import shutil class MulimgViewer (MulimgViewerGui): @@ -71,11 +72,12 @@ def __init__(self, parent, UpdateUI, get_type, default_path=None): self.m_button3.SetToolTip("left arrow") self.m_button4.SetToolTip("right arrow") self.m_button5.SetToolTip("refresh") - self.m_toggleBtn4.SetToolTip("save_configuration") + self.m_button9.SetToolTip("save_configuration") self.magnifier.SetToolTip("magnifier") self.rotation.SetToolTip("rotation") self.flip.SetToolTip("flip") self.m_button7.SetToolTip("load_configuration") + self.m_button8.SetToolTip("reset_configuration") # Different platforms may need to adjust the width of the scrolledWindow_set sys_platform = platform.system() if sys_platform.find("Windows") >= 0: @@ -1387,10 +1389,10 @@ def save_configuration(self, event): } with open('output.json', 'w') as file: - json.dump(data, file) + json.dump(data, file, indent=1) - def load_configuration(self, event): - with open('output.json', 'r') as file: + def load_configuration(self, event, config_name="output.json"): + with open(config_name, 'r') as file: data = json.load(file) self.row_col.SetValue(data['row_col']) self.row_col_one_img.SetValue(data['row_col_one_img']) @@ -1436,3 +1438,7 @@ def load_configuration(self, event): self.title_show_name.SetValue(data['title_show_name']) self.title_show_suffix.SetValue(data['title_show_suffix']) self.title_down_up.SetValue(data['title_down_up']) + + def reset_configuration(self, event): + self.load_configuration(event, config_name="output_s.json") + shutil.copy("output_s.json", "output.json")