Skip to content

Commit 2e4632d

Browse files
author
Luciano Wolf
committed
Update servicebrowser example to have the same behaviour as C++ example.
1 parent bc0b209 commit 2e4632d

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

mobility/servicebrowser/servicebrowser.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
"""
3838

3939

40-
from PySide.QtGui import QWidget, QListWidgetItem, QListWidget, QRadioButton, QGroupBox, QPushButton, QButtonGroup, QVBoxLayout, QLabel, QStackedLayout, QComboBox
40+
from PySide.QtGui import QWidget, QListWidgetItem, QListWidget, QRadioButton, QGroupBox, QPushButton, QButtonGroup, QVBoxLayout, QLabel, QStackedLayout, QComboBox, QGridLayout
4141
from PySide.QtCore import QCoreApplication, Qt
4242
from QtMobility.ServiceFramework import QServiceManager, QServiceInterfaceDescriptor
4343

4444
class ServiceBrowser(QWidget):
4545
def __init__(self, parent = None):
4646
QWidget.__init__(self, parent)
4747
self.serviceManager = QServiceManager(self)
48-
self.registerExampleServices();
48+
self.registerExampleServices()
4949
self.initWidgets()
5050
self.reloadServicesList()
5151
self.setWindowTitle(self.tr("Services Browser"))
@@ -62,10 +62,10 @@ def currentInterfaceImplChanged(self, current, previous):
6262
self.reloadAttributesRadioButtonText()
6363
if descriptor.isValid():
6464
self.defaultInterfaceButton.setText(self.tr("Set as default implementation for %s" % str(descriptor.interfaceName())))
65-
self.defaultInterfaceButton.setEnabled(True);
65+
self.defaultInterfaceButton.setEnabled(True)
6666

6767
def reloadServicesList(self):
68-
self.servicesListWidget.clear();
68+
self.servicesListWidget.clear()
6969
services = self.serviceManager.findServices()
7070
for serv in services:
7171
self.servicesListWidget.addItem(serv)
@@ -120,7 +120,7 @@ def reloadAttributesList(self):
120120
self.attributesListWidget.addItem(self.tr("(Error loading service plugin)"))
121121
return
122122

123-
metaObject = implementationRef.metaObject();
123+
metaObject = implementationRef.metaObject()
124124
self.attributesGroup.setTitle(self.tr("Invokable attributes for %s class" % metaObject.className()))
125125
for i in range(metaObject.methodCount()):
126126
method = metaObject.method(i)
@@ -170,7 +170,7 @@ def initWidgets(self):
170170
self.interfacesListWidget.addItem(self.tr("(Select a service)"))
171171
self.attributesListWidget = QListWidget()
172172
self.attributesListWidget.addItem(self.tr("(Select an interface implementation)"))
173-
self.interfacesListWidget.setMinimumWidth(450);
173+
self.interfacesListWidget.setMinimumWidth(450)
174174
self.servicesListWidget.currentItemChanged.connect(self.reloadInterfaceImplementationsList)
175175
self.interfacesListWidget.currentItemChanged.connect(self.currentInterfaceImplChanged)
176176
self.defaultInterfaceButton = QPushButton(self.tr("Set as default implementation"))
@@ -203,18 +203,11 @@ def initWidgets(self):
203203
attributesLayout.addWidget(self.selectedImplRadioButton)
204204
attributesLayout.addWidget(self.defaultImplRadioButton)
205205

206-
layout = QVBoxLayout()
207-
stackedLayout = QStackedLayout()
208-
stackedLayout.addWidget(self.servicesGroup);
209-
stackedLayout.addWidget(self.interfacesGroup)
210-
stackedLayout.addWidget(self.attributesGroup);
206+
self.attributesGroup.setLayout(attributesLayout)
211207

212-
pageComboBox = QComboBox()
213-
pageComboBox.addItem(self.tr("Services"))
214-
pageComboBox.addItem(self.tr("Interfaces"))
215-
pageComboBox.addItem(self.tr("Attributes"))
216-
pageComboBox.activated[int].connect(stackedLayout.setCurrentIndex)
208+
layout = QGridLayout()
209+
layout.addWidget(self.servicesGroup, 0, 0)
210+
layout.addWidget(self.attributesGroup, 0, 1, 2, 1)
211+
layout.addWidget(self.interfacesGroup, 1, 0)
217212

218-
layout.addWidget(pageComboBox)
219-
layout.addLayout(stackedLayout)
220213
self.setLayout(layout)

0 commit comments

Comments
 (0)