def __init__(self): 
    QtGui.QDialog.__init__(self) 
    # Set up the user interface from Designer. 
    self.ui = Ui_MapfileLayer()
    self.ui.setupUi(self) 

    QObject.connect(self.ui.btnMapfile, SIGNAL("clicked()"), self.setMapfile)
class MapfileLayerDialog(QtGui.QDialog):
  def __init__(self): 
    QtGui.QDialog.__init__(self) 
    # Set up the user interface from Designer. 
    self.ui = Ui_MapfileLayer()
    self.ui.setupUi(self) 

    QObject.connect(self.ui.btnMapfile, SIGNAL("clicked()"), self.setMapfile)

  def setMapfile(self):
    mapfile = QFileDialog.getOpenFileName(self, "Mapfile", ".", "MapServer map files (*.map);;All files (*.*)","Filter list for selecting files from a dialog box")
    self.ui.leMapfile.setText(mapfile)
    self.updateInfo()

  def updateInfo(self):
    mapfile = self.ui.leMapfile.text()
    if mapfile != "":
      maprenderer = MapfileRenderer(str(mapfile))
      layers = maprenderer.getLayers()
      self.ui.listLayers.clear()
      for layer in layers:
        item = QtGui.QListWidgetItem(self.ui.listLayers)
        item.setText(layer)