def openLink(self, key, arg="", fileArg=None): """Use `QDesktopServices` to open an url using the system default applications Parameters: key: the entry key or the link (if `arg` == "link") arg: if `arg` == "file", `fileArg` must be the file name if `arg` == "link", `key` must be the link to be opened for any other values, the link will be generated using the `physbiblio.view.viewWntry.getLink` method fileArg: the file name if `arg` == "file", or the argument passed to `physbiblio.view.viewWntry.getLink` if needed """ if isinstance(key, list): for k in key: self.openLink(k, arg, fileArg) else: if arg == "file": url = QUrl.fromLocalFile(fileArg) elif arg == "link": url = QUrl(key) else: link = self.getLink(key, arg=arg, fileArg=fileArg) url = QUrl(link) if QDesktopServices.openUrl(url): pBLogger.debug(ccstr.openSuccess % (url.toString(), key)) else: pBLogger.warning(ccstr.openFailed % key)
def _graph_url_changed(self, url: QtCore.QUrl): node_uri = url.toString() node_uri_stem = node_uri.split("/")[-1] node_index = node_uri_stem.split("node_id_")[-1] if node_index.isdigit(): node_index = int(node_index) self._update_node_graph_view([node_index])
def testSetAttributes(self): #Construct QUrl by set* methods url = QUrl() url.setScheme('ftp') self.assertEqual(url.toString(), 'ftp:') url.setHost('www.google.com') self.assertEqual(url.toString(), 'ftp://www.google.com') url.setPort(8080) self.assertEqual(url.toString(), 'ftp://www.google.com:8080') url.setPath('/mail/view') self.assertEqual(url.toString(), 'ftp://www.google.com:8080/mail/view') url.setUserName('john') self.assertEqual(url.toString(), 'ftp://[email protected]:8080/mail/view') url.setPassword('abc123') self.assertEqual(url.toString(), 'ftp://*****:*****@www.google.com:8080/mail/view')
def testSetAttributes(self): #Construct QUrl by set* methods url = QUrl() url.setScheme('ftp') self.assertEqual(url.toString(), 'ftp:') url.setHost('www.google.com') self.assertEqual(url.toString(), 'ftp://www.google.com') url.setPort(8080) self.assertEqual(url.toString(), 'ftp://www.google.com:8080') url.setPath('mail/view') self.assertEqual(url.toString(), 'ftp://www.google.com:8080/mail/view') url.setUserName('john') self.assertEqual(url.toString(), 'ftp://[email protected]:8080/mail/view') url.setPassword('abc123') self.assertEqual(url.toString(), 'ftp://*****:*****@www.google.com:8080/mail/view')
def __isModelExtensionValid(self, modelPath:QUrl) -> bool: if modelPath.toString().toLower().endsWith('.stl') or modelPath.toString().toLower().endsWith('.obj'): return True else: return False
def testBasic(self): #Default constructor for QUrl url = QUrl() self.assertEqual(url.toString(), "")
def _url_changed(self, url: QtCore.QUrl) -> None: self.address_line_edit.setText(url.toString())