3
# [SNIPPET_NAME: Solid (Device)]
4
# [SNIPPET_CATEGORIES: PyKDE4]
5
# [SNIPPET_DESCRIPTION: Device integration framework for a device]
6
# [SNIPPET_AUTHOR: Jim Bublitz <jbublitz@nwinternet.com>]
7
# [SNIPPET_LICENSE: GPL]
8
# [SNIPPET_DOCS: http://api.kde.org/pykde-4.3-api/solid/index.html, http://api.kde.org/pykde-4.3-api/solid/Solid.Device.html]
10
from PyQt4.QtCore import SIGNAL, Qt
11
from PyQt4.QtGui import QTreeWidget, QTreeWidgetItem, QLabel
13
from PyKDE4.kdecore import i18n
14
from PyKDE4.solid import Solid
15
from PyKDE4.kdeui import KVBox
17
helpText = """The Solid class discovers information about the hardware on a machine.
19
Solid.Device is the base class for the various types of devices. It provides a list
20
of the types of devices on the machine. The table below shows the data for your
23
Individual device type classes can be interrogated to discover specific information
24
suitable to each device type.
27
class MainFrame(KVBox):
28
def __init__(self, parent=None):
29
KVBox.__init__(self, parent)
30
self.help = QLabel (i18n (helpText), self)
31
self.layout ().setAlignment (self.help, Qt.AlignHCenter)
34
display = QTreeWidget (self)
35
display.setHeaderLabels (["Product", "Vendor", "UDI"])
36
display.setColumnWidth (0, 300)
38
# retrieve a list of Solid.Device for this machine
39
deviceList = Solid.Device.allDevices ()
41
for device in deviceList:
42
item = QTreeWidgetItem (display, [device.product (), device.vendor (), device.udi ()])
47
# This example can be run standalone
49
if __name__ == '__main__':
53
from PyKDE4.kdecore import KCmdLineArgs, KAboutData, KLocalizedString, ki18n
54
from PyKDE4.kdeui import KApplication, KMainWindow
58
class MainWin (KMainWindow):
59
def __init__ (self, *args):
60
KMainWindow.__init__ (self)
63
self.setCentralWidget (MainFrame (self))
65
#-------------------- main ------------------------------------------------
67
appName = "Solid_Devices"
69
programName = ki18n ("Solid_Devices") #ki18n required here
71
description = ki18n ("Solid.Devices Example") #ki18n required here
72
license = KAboutData.License_GPL
73
copyright = ki18n ("(c) 2007 Jim Bublitz") #ki18n required here
74
text = ki18n ("none") #ki18n required here
75
homePage = "www.riverbankcomputing.com"
76
bugEmail = "jbublitz@nwinternet.com"
78
aboutData = KAboutData (appName, catalog, programName, version, description,
79
license, copyright, text, homePage, bugEmail)
81
# ki18n required for first two addAuthor () arguments
82
aboutData.addAuthor (ki18n ("Troy Melhase"), ki18n ("original concept"))
83
aboutData.addAuthor (ki18n ("Jim Bublitz"), ki18n ("pykdedocs"))
85
KCmdLineArgs.init (sys.argv, aboutData)
88
mainWindow = MainWin (None, "main window")
90
app.connect (app, SIGNAL ("lastWindowClosed ()"), app.quit)