def _ImportPngs( self, paths ): for path in paths: try: payload = ClientSerialisable.LoadFromPng( path ) except Exception as e: QW.QMessageBox.critical( self, 'Error', str(e) ) return try: obj = HydrusSerialisable.CreateFromNetworkBytes( payload ) self._ImportObject( obj ) except: QW.QMessageBox.critical( self, 'Error', 'I could not understand what was encoded in the file!' ) return
def _ImportFromPng( self ): with QP.FileDialog( self, 'select the png with the urls', wildcard = 'PNG (*.png)' ) as dlg: if dlg.exec() == QW.QDialog.Accepted: path = dlg.GetPath() payload = ClientSerialisable.LoadFromPng( path ) try: urls = self._GetURLsFromURLsString( payload ) self._ImportURLs( urls ) except: QW.QMessageBox.critical( self, 'Error', 'Could not import!' ) raise