@@ -47,36 +47,26 @@ def _overwrite():
4747
4848 @magicgui .magicgui (call_button = "Create new file" , labels = False )
4949 def _create ():
50- msg_box .close ()
5150 # unfortunately there exists no dialog to create a directory so we have
5251 # to use "create new file" dialog with some adjustments.
5352 dialog = QtWidgets .QFileDialog (None )
5453 dialog .setFileMode (QtWidgets .QFileDialog .AnyFile )
5554 dialog .setOption (QtWidgets .QFileDialog .ShowDirsOnly )
5655 dialog .setNameFilter ("Archives (*.zarr)" )
57- try_cnt = 0
58- while os .path .splitext (new_path ["value" ])[1 ] != ".zarr" :
59- if try_cnt > 3 :
60- new_path ["value" ] = file_path
61- return
62- dialog .exec_ ()
63- res = dialog .selectedFiles ()
64- new_path ["value" ] = res [0 ] if len (res ) > 0 else ""
65- try_cnt += 1
56+ dialog .exec_ ()
57+ res = dialog .selectedFiles ()
58+ new_path ["value" ] = res [0 ] if len (res ) > 0 else ""
59+ if os .path .splitext (new_path ["value" ])[1 ] != ".zarr" :
60+ new_path ["value" ] += ".zarr"
6661 os .makedirs (new_path ["value" ])
62+ msg_box .close ()
6763
6864 @magicgui .magicgui (call_button = "Select different file" , labels = False )
6965 def _select ():
66+ new_path ["value" ] = QtWidgets .QFileDialog .getExistingDirectory (
67+ None , "Open a folder" , os .path .split (file_path )[0 ], QtWidgets .QFileDialog .ShowDirsOnly
68+ )
7069 msg_box .close ()
71- try_cnt = 0
72- while not os .path .exists (new_path ["value" ]):
73- if try_cnt > 3 :
74- new_path ["value" ] = file_path
75- return
76- new_path ["value" ] = QtWidgets .QFileDialog .getExistingDirectory (
77- None , "Open a folder" , os .path .split (file_path )[0 ], QtWidgets .QFileDialog .ShowDirsOnly
78- )
79- try_cnt += 1
8070
8171 msg_box = Container (widgets = [_select , _ignore , _overwrite , _create ], layout = 'horizontal' , labels = False )
8272 msg_box .root_native_widget .setWindowTitle ("The input data does not match the embeddings file" )
0 commit comments