I am writing a desktop application in Python (3.4) on Linux using Qt (4.8) and PyQt.
Is there a way to use/import Okular’s pdf view functionality as a widget? If yes, how?
Advertisement
Answer
This works for me:
import sys from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs from PyKDE4.kdecore import KLibLoader as ll from PyKDE4.kdeui import KApplication import PyKDE4.kparts as kp appName = "KApplication" catalog = "" programName = ki18n ("KApplication") version = "1.0" description = ki18n ("KApplication") license = KAboutData.License_GPL copyright = ki18n ("(c) 2007 John Doe") text = ki18n ("none") homePage = "www.johndoe.com" bugEmail = "johndoe@nowhere.com " aboutData = KAboutData( appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail ) KCmdLineArgs.init(sys.argv, aboutData) app = KApplication() win = kp.KParts.MainWindow() okupart = ll.self().factory('okularpart').create() win.setCentralWidget(okupart.widget()) win.show() app.exec_()