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:
JavaScript
x
33
33
1
import sys
2
from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs
3
from PyKDE4.kdecore import KLibLoader as ll
4
from PyKDE4.kdeui import KApplication
5
import PyKDE4.kparts as kp
6
7
8
appName = "KApplication"
9
catalog = ""
10
programName = ki18n ("KApplication")
11
version = "1.0"
12
description = ki18n ("KApplication")
13
license = KAboutData.License_GPL
14
copyright = ki18n ("(c) 2007 John Doe")
15
text = ki18n ("none")
16
homePage = "www.johndoe.com"
17
bugEmail = "johndoe@nowhere.com "
18
19
aboutData = KAboutData(
20
appName, catalog, programName, version, description,
21
license, copyright, text, homePage, bugEmail
22
)
23
24
KCmdLineArgs.init(sys.argv, aboutData)
25
26
app = KApplication()
27
win = kp.KParts.MainWindow()
28
okupart = ll.self().factory('okularpart').create()
29
win.setCentralWidget(okupart.widget())
30
win.show()
31
32
app.exec_()
33