def printPreview(self): """ export to a temporary PDF file and open in the default pdf viewer Raises `NotImplemented` if print preview is not supported on this platform (yet?) """ pdf_file = NamedTemporaryFile(suffix='.pdf',delete=False) try: self.exportToPDF(pdf_file) """ #this clever pure-python implementation is probably not as portable as letting Qt handle it #though I'm not sure #get appropriate "document opener" program for the platform if 'linux' in sys.platform: prog_name = 'xdg-open' elif sys.platform == 'darwin': #Mac OS X prog_name = 'open' elif sys.platform == 'win32': #64 bit windows is still "win32" prog_name = 'start' else: raise NotImplemented('Your Platform (%s) does not support the print preview feature,'\ 'Export to PDF instead, please report this error' % sys.platform) subprocess.check_call([prog_name, pdf_file.name]) """ QDesktopServices.openUrl(QUrl.fromLocalFile(pdf_file.name)) finally: pdf_file.close()
def link_click_handler(self, url): if url.path() == u'blank': if url.hasFragment(): if url.fragment() == u'quit': QApplication.instance().quit() else: QDesktopServices.openUrl(url)
def email_note(self): body = self.page.mainFrame().toPlainText()[ len(self.title): ].strip() url = QUrl("mailto:") url.addQueryItem("subject", self.title) url.addQueryItem("body", body) QDesktopServices.openUrl(url)
def www_view(self): """ Context Menu Action. Opens the stream in a web page. """ if self.stream is not None: print "Opening %s in a web browser..." % self.stream QDesktopServices.openUrl(self.stream.url)
def event_link_clicked(self, url): url_string = url.toString() if 'file' in urlparse.parse_qs(urlparse.urlparse(url_string).query): msgbox = QMessageBox() msgbox.setWindowTitle('Installing') msgbox.setText('Installing theme. Please wait...') msgbox.setStandardButtons(0) msgbox.setAttribute(Qt.WA_DeleteOnClose) msgbox.setWindowModality(Qt.NonModal) msgbox.show() msgbox.repaint() # Qt didn't want to show the text so we force a repaint # Download and install the theme package = self.module.download('http://localhost/test/download.php?file=2800&name=Fat-flat.xpf') #package = self.module.download(url_string) try: self.module.install(package) msgbox.close() complete_msgbox = QMessageBox() complete_msgbox.setWindowTitle('Complete') complete_msgbox.setText('Install complete.') complete_msgbox.setStandardButtons(QMessageBox.Ok) complete_msgbox.setAttribute(Qt.WA_DeleteOnClose) complete_msgbox.exec_() except: msgbox.close() print "Unexpected error:", sys.exc_info()[:2] failed_msgbox = QMessageBox() failed_msgbox.setWindowTitle('Failed') failed_msgbox.setText('Install failed. Please try again later.') failed_msgbox.setStandardButtons(QMessageBox.Ok) failed_msgbox.setAttribute(Qt.WA_DeleteOnClose) failed_msgbox.exec_() else: QDesktopServices.openUrl(url)
def open_external_urls(url): QDesktopServices.openUrl(url)
def writeCSVReportForShotSelection(self, shotSelection=None, savePath=None): """Writes a csv file from a shotSelection, optionally saves tagged shots only. If running""" if not shotSelection: shotSelection = getSelectedShotsForActiveView() if len(shotSelection) <= 0: # If we're here we have no shots to work with - bail out. return sequence = shotSelection[0].parentSequence() tagDict = self.buildUniqueTagsDictFromShotSelection(shotSelection) if not savePath: currentTimeString = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d_%H-%M-%S') saveName = "TagReport_%s_%s.csv" % (sequence.name().replace(" ", "_"), currentTimeString) csvSavePath = os.path.join(os.getenv('HOME'), 'Desktop', saveName) savePath = openFileBrowser(caption="Save Tag Report .CSV as...", initialPath=csvSavePath, mayNotExist=True, forSave=True, pattern="*.csv") print "Save path %s" % savePath # A list is returned here, we SHOULD only get one file name, but force this to be only one, then check for .csv extension. if len(savePath)!=1: return else: savePath=savePath[0] if not savePath.lower().endswith(".csv"): savePath+".csv" if len(savePath)==0: return # The Header row for the CSV will contain some basic info re. the shot... sortedTagNames = sorted(tagDict) ### THIS HEADER MUST MATCH THE table_data line below ### csvHeader = ["Shot Name", "Duration", "Source Clip", "Track", "Type", "No. Tags"] # Plus Tag names as columns if len(sortedTagNames)>0: csvHeader.extend(sortedTagNames) # Get a CSV writer object csvFile = open(savePath, 'w') csvWriter = csv.writer( csvFile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) # Write the Header row to the CSV file csvWriter.writerow(csvHeader) for shot in shotSelection: currentTags = shot.tags() currentShotTagNames = [tag.name() for tag in currentTags] ### THIS LIST MUST MATCH THE csvHeader above ### table_data = [shot.name(), shot.duration(), shot.source().name(), shot.parentTrack().name(), shotMediaType(shot), str(len(currentTags))] # Then add the remaining columns as TRUE/FALSE values in the tag columns for tag in sortedTagNames: if tag in currentShotTagNames: table_data += ["TRUE"] else: table_data += ["FALSE"] csvWriter.writerow(table_data) # Be good and close the file csvFile.close() print 'CSV Tag Report saved to: ' + str(savePath) # Conveniently show the CSV file in the native file browser... QDesktopServices.openUrl(QUrl('file:///%s' % (os.path.dirname(savePath))))
def on_pushButtonHelpOnline_clicked(self): QDesktopServices.openUrl(QUrl("http://desenvolvedoresdaruma.com.br/home/downloads/Site_2011/Help/DarumaFrameworkHelpOnline/Daruma_Framework.htm"))
def open_plot_folder(self): f_next, _ = os.path.splitext(str(self.ui.edit_file.text())) plot_folder = os.path.join(f_next, 'plots') QDesktopServices.openUrl(QUrl(plot_folder))
def _on_edit_export_style(self): file_path = os.path.join( QDesktopServices.storageLocation(QDesktopServices.DataLocation), FORMAT_FILE) QDesktopServices.openUrl(QUrl.fromLocalFile(file_path))
def help_matlab(self): QDesktopServices.openUrl( QUrl("http://ch.mathworks.com/products/matlab/"))
def on_open(self): if sys.platform.startswith('darwin'): url = '/Applications/Listen 1.app/Contents/MacOS/media/music/' QDesktopServices.openUrl(QUrl.fromLocalFile(url)) else: QDesktopServices.openUrl(QUrl.fromLocalFile('./media/music'))
def email_note(self): body = self.page.mainFrame().toPlainText()[len(self.title):].strip() url = QUrl("mailto:") url.addQueryItem("subject", self.title) url.addQueryItem("body", body) QDesktopServices.openUrl(url)
def acceptNavigationRequest(self, frame, request, type): modifiers = QApplication.keyboardModifiers() if modifiers == Qt.ControlModifier and type == QWebPage.NavigationTypeLinkClicked: QDesktopServices.openUrl(request.url()) return False
def fetch_code(): url = "https://foursquare.com/oauth2/authenticate?client_id=" + foursquare.CLIENT_ID + "&response_type=code&redirect_uri=" + foursquare.CALLBACK_URI + "&display=touch" QDesktopServices.openUrl(QUrl(url, QUrl.StrictMode)) httpd = HTTPServer(("localhost", 6060), Handler) httpd.handle_request()
def _link_activated ( self, url ): """ Handles the user clicking on a hyperlink. """ QDesktopServices.openUrl( QUrl( url ) ) if self.factory.label != '': self.value = unicode( url )
def show_uri(parent, link): from PySide.QtGui import QDesktopServices from PySide.QtCore import QUrl QDesktopServices.openUrl(QUrl(link, QUrl.TolerantMode))
def openZipCodeTWAbout(self, *args, **kwargs): QDesktopServices.openUrl(QUrl('http://zipcode.mosky.tw/about'))
def on_start(self): self.myProcess = MyWorkerThread() self.myProcess.start() QDesktopServices.openUrl('http://localhost:8888/')
def redirect_to_permission_page(): QDesktopServices.openUrl(get_permission_url()) quickstart(auth_server)
def help_phy(self): QDesktopServices.openUrl( QUrl("https://github.com/kwikteam/phy-contrib"))
def open_log_file(self): assert self.last_log_file is not None QDesktopServices.openUrl(QUrl(self.last_log_file))
def view_param(self): f_next, _ = os.path.splitext(str(self.ui.edit_file.text())) f_params = f_next + '.params' QDesktopServices.openUrl(QUrl(f_params))
def on_donate_button_clicked(self): """Opens the donation link in a browser of the operating system.""" QDesktopServices.openUrl(QUrl("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDQAJJ74TTYGJ", QUrl.StrictMode))
def _on_edit_verbs_list(self): file_path = os.path.join( QDesktopServices.storageLocation(QDesktopServices.DataLocation), VERBS_FILE) QDesktopServices.openUrl(QUrl.fromLocalFile(file_path))