def __onAttach (self, event): """ Обработчик события при нажатии на кнопку для прикрепления файла """ if self._page.readonly: raise outwiker.core.exceptions.ReadonlyException # Кусок ниже практически полностью скопирован из функции outwiker.core.commands.attachFilesWithDialog dlg = wx.FileDialog (self._dialog, style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) if dlg.ShowModal() == wx.ID_OK: files = dlg.GetPaths() files.sort() attachFiles (self._dialog, self._page, files) self._loadAttachmentState() # Выберем только что добавленный файл newfile = os.path.basename (files[0]) if newfile in self._dialog.attachmentComboBox.GetItems(): self._dialog.attachmentComboBox.SetStringSelection (newfile) self._dialog.fileCheckBox.SetValue (True) self.updateFileChecked() dlg.Destroy()
def OnDropFiles (self, x, y, files): if (Application.wikiroot != None and Application.wikiroot.selectedPage != None): cmd.attachFiles (self._mainWindow, Application.wikiroot.selectedPage, files) return True
def __onAttach(self, event): """ Обработчик события при нажатии на кнопку для прикрепления файла """ if self._page.readonly: raise outwiker.core.exceptions.ReadonlyException # Кусок ниже практически полностью скопирован из функции outwiker.core.commands.attachFilesWithDialog dlg = wx.FileDialog(self._dialog, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) if dlg.ShowModal() == wx.ID_OK: files = dlg.GetPaths() files.sort() attachFiles(self._dialog, self._page, files) self._loadAttachmentState() # Выберем только что добавленный файл newfile = os.path.basename(files[0]) if newfile in self._dialog.attachmentComboBox.GetItems(): self._dialog.attachmentComboBox.SetStringSelection(newfile) self._dialog.fileCheckBox.SetValue(True) self.updateFileChecked() dlg.Destroy()
def OnDropFiles(self, x, y, files): if (self._application.wikiroot is not None and self._application.wikiroot.selectedPage is not None): attachFiles(self._dropWnd, self._application.wikiroot.selectedPage, files) return True
def OnDropFiles (self, x, y, files): if (Application.wikiroot is not None and Application.wikiroot.selectedPage is not None): cmd.attachFiles (self._dropWnd, Application.wikiroot.selectedPage, files) return True
def OnDropFiles(self, x, y, files): correctedFiles = self.correctFileNames(files) flags_mask = wx.TREE_HITTEST_ONITEMICON | wx.TREE_HITTEST_ONITEMLABEL item, flags = self.targetWindow.HitTest((x, y)) if flags & flags_mask: page = self._notesTree.getPageByItemId(item) if page is not None: file_names = [os.path.basename(fname) for fname in correctedFiles] text = _("Attach files to the note '{title}'?\n\n{files}").format( title=page.display_title, files='\n'.join(file_names) ) if MessageBox(text, _("Attach files to the note?"), wx.YES_NO | wx.ICON_QUESTION) == wx.YES: attachFiles(self._application.mainWindow, page, correctedFiles) return True return False
def OnDropFiles(self, x: int, y: int, files: List[str]) -> bool: correctedFiles = self.correctFileNames(files) if (self._application.wikiroot is not None and self._application.wikiroot.selectedPage is not None): attachFiles(self._application.mainWindow, self._application.wikiroot.selectedPage, correctedFiles) return True return False
def _attachFilesWithDialog (self, parent, page): """ Вызвать диалог для приаттачивания файлов к странице parent - родительское окно page - страница, куда прикрепляем файлы """ if page.readonly: raise ReadonlyException dlg = wx.FileDialog (parent, style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) if dlg.ShowModal() == wx.ID_OK: files = dlg.GetPaths() files.sort() attachFiles (parent, page, files) dlg.Destroy()
def OnDropFiles(self, x, y, files): if len(files) == 1 and '\n' in files[0]: files = files[0].split('\n') file_protocol = 'file://' correctedFiles = [] for fname in files: if not fname.strip(): continue if fname.startswith(file_protocol): fname = fname[len(file_protocol):] correctedFiles.append(fname) if (self._application.wikiroot is not None and self._application.wikiroot.selectedPage is not None): attachFiles(self._application.mainWindow, self._application.wikiroot.selectedPage, correctedFiles) return True