Kaydet (Commit) 8db487eb authored tarafından Gökmen Göksel's avatar Gökmen Göksel

* Damadın dayısından Qt4 örneği ..

üst 252fca79
all:
pyuic4 mainform.ui -o mainform.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import comar
import mainform
from PyQt4 import QtGui
from PyQt4.QtCore import *
from dbus.mainloop.qt import DBusQtMainLoop
class Window(QtGui.QWidget):
def __init__(self, *args):
QtGui.QWidget.__init__(self, None)
# Create ui
self.ui = mainform.Ui_mainForm()
self.ui.setupUi(self)
# Call Comar
self.link = comar.Link()
# Connect button click event to getServices method
self.connect(self.ui.buttonServices, SIGNAL("clicked()"), self.getServices)
def handleServices(self, package, exception, results):
# Handle request and fill the textEdit in ui
if not exception:
serviceName, serviceDesc, serviceState = results
self.ui.textServices.append("%s - %s - %s - %s" % (package, serviceName, serviceDesc, serviceState))
def getServices(self):
# Get service list from comar link
self.link.System.Service.info(async=self.handleServices)
def main():
app = QtGui.QApplication(sys.argv)
DBusQtMainLoop(set_as_default = True)
win = Window()
win.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
<ui version="4.0" >
<class>mainForm</class>
<widget class="QWidget" name="mainForm" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>459</width>
<height>343</height>
</rect>
</property>
<property name="windowTitle" >
<string>Qt4 &amp; COMAR</string>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QTextEdit" name="textServices" />
</item>
<item row="1" column="0" >
<widget class="QPushButton" name="buttonServices" >
<property name="text" >
<string>Get Services</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment