'Project creation dialog.'

def __init__(self, parent):

    super(ProjectDialog, self).__init__(parent=parent)
    current_python_version = '.'.join([to_text_string(sys.version_info[0]), to_text_string(sys.version_info[1])])
    python_versions = ['2.7', '3.4', '3.5']
    if (current_python_version not in python_versions):
        python_versions.append(current_python_version)
        python_versions = sorted(python_versions)
    self.project_name = None
    self.location = get_home_dir()
    self.groupbox = QGroupBox()
    self.radio_new_dir = QRadioButton(_('New    directory'))
    self.radio_from_dir = QRadioButton(_('Existing    directory'))
    self.label_project_name = QLabel(_('Project    name'))
    self.label_location = QLabel(_('Location'))
    self.label_project_type = QLabel(_('Project    type'))
    self.label_python_version = QLabel(_('Python    version'))
    self.text_project_name = QLineEdit()
    self.text_location = QLineEdit(get_home_dir())
    self.combo_project_type = QComboBox()
    self.combo_python_version = QComboBox()
    self.button_select_location = QToolButton()
    self.button_cancel = QPushButton(_('Cancel'))
    self.button_create = QPushButton(_('Create'))
    self.bbox = QDialogButtonBox(Qt.Horizontal)
    self.bbox.addButton(self.button_cancel, QDialogButtonBox.ActionRole)
    self.bbox.addButton(self.button_create, QDialogButtonBox.ActionRole)
    self.combo_python_version.addItems(python_versions)
    self.radio_new_dir.setChecked(True)
    self.text_location.setEnabled(True)
    self.text_location.setReadOnly(True)
    self.button_select_location.setIcon(get_std_icon('DirOpenIcon'))
    self.button_cancel.setDefault(True)
    self.button_cancel.setAutoDefault(True)
    self.button_create.setEnabled(False)
    self.combo_project_type.addItems(self._get_project_types())
    self.combo_python_version.setCurrentIndex(python_versions.index(current_python_version))
    self.setWindowTitle(_('Create    new    project'))
    self.setFixedWidth(500)
    self.label_python_version.setVisible(False)
    self.combo_python_version.setVisible(False)
    layout_top = QHBoxLayout()
    layout_top.addWidget(self.radio_new_dir)
    layout_top.addWidget(self.radio_from_dir)
    layout_top.addStretch(1)
    self.groupbox.setLayout(layout_top)
    layout_grid = QGridLayout()
    layout_grid.addWidget(self.label_project_name, 0, 0)
    layout_grid.addWidget(self.text_project_name, 0, 1, 1, 2)
    layout_grid.addWidget(self.label_location, 1, 0)
    layout_grid.addWidget(self.text_location, 1, 1)
    layout_grid.addWidget(self.button_select_location, 1, 2)
    layout_grid.addWidget(self.label_project_type, 2, 0)
    layout_grid.addWidget(self.combo_project_type, 2, 1, 1, 2)
    layout_grid.addWidget(self.label_python_version, 3, 0)
    layout_grid.addWidget(self.combo_python_version, 3, 1, 1, 2)
    layout = QVBoxLayout()
    layout.addWidget(self.groupbox)
    layout.addSpacing(10)
    layout.addLayout(layout_grid)
    layout.addStretch()
    layout.addSpacing(20)
    layout.addWidget(self.bbox)
    self.setLayout(layout)
    self.button_select_location.clicked.connect(self.select_location)
    self.button_create.clicked.connect(self.create_project)
    self.button_cancel.clicked.connect(self.close)
    self.radio_from_dir.clicked.connect(self.update_location)
    self.radio_new_dir.clicked.connect(self.update_location)
    self.text_project_name.textChanged.connect(self.update_location)
