def __init__(self, parent, flat_media, do_export_and_then_quit=False): ClientGUIScrolledPanels.ReviewPanel.__init__(self, parent) new_options = HG.client_controller.new_options self._media_to_paths = {} self._existing_filenames = set() self._last_phrase_used = '' self._last_dir_used = '' self._tags_box = ClientGUICommon.StaticBoxSorterForListBoxTags( self, 'files\' tags') services_manager = HG.client_controller.services_manager self._neighbouring_txt_tag_service_keys = services_manager.FilterValidServiceKeys( new_options.GetKeyList( 'default_neighbouring_txt_tag_service_keys')) t = ClientGUIListBoxes.ListBoxTagsSelection(self._tags_box, include_counts=True, collapse_siblings=True) self._tags_box.SetTagsBox(t) self._tags_box.SetMinSize((220, 300)) columns = [('number', 8), ('mime', 20), ('expected path', -1)] self._paths = ClientGUIListCtrl.BetterListCtrl( self, 'export_files', 24, 64, columns, self._ConvertDataToListCtrlTuples, use_simple_delete=True) self._paths.Sort(0) self._export_path_box = ClientGUICommon.StaticBox(self, 'export path') self._directory_picker = wx.DirPickerCtrl(self._export_path_box) self._directory_picker.Bind(wx.EVT_DIRPICKER_CHANGED, self.EventRecalcPaths) self._open_location = wx.Button(self._export_path_box, label='open this location') self._open_location.Bind(wx.EVT_BUTTON, self.EventOpenLocation) self._filenames_box = ClientGUICommon.StaticBox(self, 'filenames') self._pattern = wx.TextCtrl(self._filenames_box) self._update = wx.Button(self._filenames_box, label='update') self._update.Bind(wx.EVT_BUTTON, self.EventRecalcPaths) self._examples = ClientGUICommon.ExportPatternButton( self._filenames_box) self._delete_files_after_export = wx.CheckBox( self, label='delete files from client after export?') self._delete_files_after_export.SetForegroundColour( wx.Colour(127, 0, 0)) text = 'This will export all the files\' tags, newline separated, into .txts beside the files themselves.' self._export_tag_txts = wx.CheckBox(self, label='export tags to .txt files?') self._export_tag_txts.SetToolTip(text) self._export_tag_txts.Bind(wx.EVT_CHECKBOX, self.EventExportTagTxtsChanged) self._export = wx.Button(self, label='export') self._export.Bind(wx.EVT_BUTTON, self.EventExport) # export_path = ClientExporting.GetExportPath() self._directory_picker.SetPath(export_path) phrase = new_options.GetString('export_phrase') self._pattern.SetValue(phrase) if len(self._neighbouring_txt_tag_service_keys) > 0: self._export_tag_txts.SetValue(True) self._paths.SetData(list(enumerate(flat_media))) self._delete_files_after_export.SetValue( HG.client_controller.new_options.GetBoolean( 'delete_files_after_export')) self._delete_files_after_export.Bind(wx.EVT_CHECKBOX, self.EventDeleteFilesChanged) # top_hbox = wx.BoxSizer(wx.HORIZONTAL) top_hbox.Add(self._tags_box, CC.FLAGS_EXPAND_PERPENDICULAR) top_hbox.Add(self._paths, CC.FLAGS_EXPAND_BOTH_WAYS) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self._directory_picker, CC.FLAGS_EXPAND_BOTH_WAYS) hbox.Add(self._open_location, CC.FLAGS_VCENTER) self._export_path_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS) hbox.Add(self._update, CC.FLAGS_VCENTER) hbox.Add(self._examples, CC.FLAGS_VCENTER) self._filenames_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(top_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS) vbox.Add(self._export_path_box, CC.FLAGS_EXPAND_PERPENDICULAR) vbox.Add(self._filenames_box, CC.FLAGS_EXPAND_PERPENDICULAR) vbox.Add(self._delete_files_after_export, CC.FLAGS_LONE_BUTTON) vbox.Add(self._export_tag_txts, CC.FLAGS_LONE_BUTTON) vbox.Add(self._export, CC.FLAGS_LONE_BUTTON) self.SetSizer(vbox) self._RefreshTags() wx.CallAfter(self._export.SetFocus) self._paths.Bind(wx.EVT_LIST_ITEM_SELECTED, self.EventSelectPath) self._paths.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.EventSelectPath) if do_export_and_then_quit: wx.CallAfter(self._DoExport, True)
def __init__(self, parent, export_folder): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) self._export_folder = export_folder (name, path, export_type, delete_from_client_after_export, file_search_context, period, phrase) = self._export_folder.ToTuple() self._path_box = ClientGUICommon.StaticBox(self, 'name and location') self._name = wx.TextCtrl(self._path_box) self._path = wx.DirPickerCtrl(self._path_box, style=wx.DIRP_USE_TEXTCTRL) # self._type_box = ClientGUICommon.StaticBox(self, 'type of export') self._type = ClientGUICommon.BetterChoice(self._type_box) self._type.Append('regular', HC.EXPORT_FOLDER_TYPE_REGULAR) self._type.Append('synchronise', HC.EXPORT_FOLDER_TYPE_SYNCHRONISE) self._delete_from_client_after_export = wx.CheckBox(self._type_box) # self._query_box = ClientGUICommon.StaticBox(self, 'query to export') self._page_key = 'export folders placeholder' predicates = file_search_context.GetPredicates() self._predicates_box = ClientGUIListBoxes.ListBoxTagsActiveSearchPredicates( self._query_box, self._page_key, predicates) self._searchbox = ClientGUIACDropdown.AutoCompleteDropdownTagsRead( self._query_box, self._page_key, file_search_context) # self._period_box = ClientGUICommon.StaticBox(self, 'export period') self._period = ClientGUITime.TimeDeltaButton(self._period_box, min=3 * 60, days=True, hours=True, minutes=True) # self._phrase_box = ClientGUICommon.StaticBox(self, 'filenames') self._pattern = wx.TextCtrl(self._phrase_box) self._examples = ClientGUICommon.ExportPatternButton(self._phrase_box) # self._name.SetValue(name) self._path.SetPath(path) self._type.SelectClientData(export_type) self._delete_from_client_after_export.SetValue( delete_from_client_after_export) self._period.SetValue(period) self._pattern.SetValue(phrase) # rows = [] rows.append(('name: ', self._name)) rows.append(('folder path: ', self._path)) gridbox = ClientGUICommon.WrapInGrid(self._path_box, rows) self._path_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) # text = '''regular - try to export the files to the directory, overwriting if the filesize if different synchronise - try to export the files to the directory, overwriting if the filesize if different, and delete anything else in the directory If you select synchronise, be careful!''' st = ClientGUICommon.BetterStaticText(self._type_box, label=text) st.SetWrapWidth(440) self._type_box.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR) self._type_box.Add(self._type, CC.FLAGS_EXPAND_PERPENDICULAR) rows = [] rows.append(('delete files from client after export: ', self._delete_from_client_after_export)) gridbox = ClientGUICommon.WrapInGrid(self._type_box, rows) self._type_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) self._query_box.Add(self._predicates_box, CC.FLAGS_EXPAND_BOTH_WAYS) self._query_box.Add(self._searchbox, CC.FLAGS_EXPAND_PERPENDICULAR) self._period_box.Add(self._period, CC.FLAGS_EXPAND_PERPENDICULAR) phrase_hbox = wx.BoxSizer(wx.HORIZONTAL) phrase_hbox.Add(self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS) phrase_hbox.Add(self._examples, CC.FLAGS_VCENTER) self._phrase_box.Add(phrase_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self._path_box, CC.FLAGS_EXPAND_PERPENDICULAR) vbox.Add(self._type_box, CC.FLAGS_EXPAND_PERPENDICULAR) vbox.Add(self._query_box, CC.FLAGS_EXPAND_BOTH_WAYS) vbox.Add(self._period_box, CC.FLAGS_EXPAND_PERPENDICULAR) vbox.Add(self._phrase_box, CC.FLAGS_EXPAND_PERPENDICULAR) self.SetSizer(vbox) self._UpdateTypeDeleteUI() self._type.Bind(wx.EVT_CHOICE, self.EventTypeChoice) self._delete_from_client_after_export.Bind( wx.EVT_CHECKBOX, self.EventDeleteFilesAfterExport)