Graphics Reference
In-Depth Information
self.buttons.addWidget(self.okButton)
self.buttons.addWidget(self.cancelButton)
Finally, we can place the form and our buttons within the dialog box, and lay everything
out:
self.layout = QVBoxLayout(self)
self.layout.addLayout(self.form)
self.layout.addSpacing(10)
self.layout.addLayout(self.buttons)
self.setLayout(self.layout)
self.resize(self.sizeHint())
So much for the __init__() method. With the dialog box set up, we next want to
define a method to copy the feature's attributes in the dialog window:
def loadAttributes(self, feature):
type_attr = feature.attribute("type")
name_attr = feature.attribute("name")
direction_attr = feature.attribute("direction")
status_attr = feature.attribute("status")
if type_attr == TRACK_TYPE_ROAD: index = 0
elif type_attr == TRACK_TYPE_WALKING: index = 1
elif type_attr == TRACK_TYPE_BIKE: index = 2
elif type_attr == TRACK_TYPE_HORSE: index = 3
else: index = 0
self.trackType.setCurrentIndex(index)
if name_attr != None:
self.trackName.setText(name_attr)
else:
self.trackName.setText("")
if direction_attr == TRACK_DIRECTION_BOTH:
index = 0
elif direction_attr == TRACK_DIRECTION_FORWARD:
index = 1
Search WWH ::




Custom Search