Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

open pdf from pyqt in the same folder

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *


if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = QLabel()
    path = r"C:UsersShauryaDocumentsTo be savedhello.pdf"
    # or
    # path = QDir.home().filePath(r"DocumentsTo be savedhello.pdf")
    # or
    # path = QDir(QStandardPaths.writableLocation(QStandardPaths.DocumentsLocation)).filePath(r"To be savedhello.pdf")
    url = bytearray(QUrl.fromLocalFile(path).toEncoded()).decode() # file:///C:/Users/Shaurya/Documents/To%20be%20saved/hello.pdf
    text = "<a href={}>Reference Link> </a>".format(url)
    w.setText(text)
    w.setOpenExternalLinks(True)
    w.show()
    sys.exit(app.exec_())
Comment

PREVIOUS NEXT
Code Example
Python :: tkinter auto refresh content periodically 
Python :: what is quit block in python 
Python :: timestamp from date python 
Python :: /var/www/html/flag 
Python :: 1046 uri solution 
Python :: Univariant Variable Analysis - Multiple Plots 
Python :: python get all keys in dict having value in range 
Python :: python requests-session for websites wihout login 
Python :: A Simple Class 
Python :: python glob wildcard filename 
Python :: python scrapy browser headers to dictionary 
Python :: How to add an item from another set or other data structures (lists, dictionaries, and tuples) to a set by using the update() method. 
Python :: adding multiple items to a list python 
Python :: Drop a single column by index 
Python :: how to get each word in a string 
Python :: Difference between the remove() method and discard() method of sets in python 
Python :: Calculate summary statistics across columns 
Python :: python - Creating Tkinter buttons to stop/skip a 2D loop [Solved 
Python :: loop through KeyedVectors 
Python :: comparison operators in python 
Python :: Sampling data in different ways 
Python :: datetime.timedelta 
Python :: Comparison operators and conditional execution 
Python :: msg to pdf converter using python 
Python :: how to filter even or odd model id in django 
Python :: clustermap subplots 
Python :: check two list python not match 
Python :: readline python sin avanzar de linea 
Python :: split credit card number python 
Python :: QMenuBar pyqt 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =