Ejemplo n.º 1
0
class DistributionSelector(QWidget):
    """Python distribution selector widget"""
    TITLE = 'Select a Python distribution path'

    # Signals after PyQt4 old SIGNAL removal
    selected_distribution = Signal(str)

    def __init__(self, parent):
        super(DistributionSelector, self).__init__(parent)
        self.browse_btn = None
        self.label = None
        self.line_edit = None
        self.setup_widget()

    def set_distribution(self, path):
        """Set distribution directory"""
        self.line_edit.setText(path)

    def setup_widget(self):
        """Setup workspace selector widget"""
        self.label = QLabel()
        self.line_edit = QLineEdit()
        self.line_edit.setAlignment(Qt.AlignRight)
        self.line_edit.setReadOnly(True)
        # self.line_edit.setDisabled(True)
        self.browse_btn = QPushButton(get_std_icon('DirOpenIcon'), "", self)
        self.browse_btn.setToolTip(self.TITLE)
        # PyQt4 old SIGNAL:self.connect(self.browse_btn, SIGNAL("clicked()"),
        # PyQt4 old SIGNAL:             self.select_directory)
        self.browse_btn.clicked.connect(self.select_directory)
        layout = QHBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.line_edit)
        layout.addWidget(self.browse_btn)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

    def select_directory(self):
        """Select directory"""
        basedir = to_text_string(self.line_edit.text())
        if not osp.isdir(basedir):
            basedir = getcwd()
        while True:
            directory = getexistingdirectory(self, self.TITLE, basedir)
            if not directory:
                break
            if not utils.is_python_distribution(directory):
                QMessageBox.warning(
                    self, self.TITLE,
                    "The following directory is not a Python distribution.",
                    QMessageBox.Ok)
                basedir = directory
                continue
            directory = osp.abspath(osp.normpath(directory))
            self.set_distribution(directory)
            # PyQt4 old SIGNAL: self.emit(SIGNAL('selected_distribution(QString)'), directory)
            self.selected_distribution.emit(directory)
            break
Ejemplo n.º 2
0
class DistributionSelector(QWidget):
    """Python distribution selector widget"""
    TITLE = 'Select a Python distribution path'

    # Signals after PyQt4 old SIGNAL removal
    selected_distribution = Signal(str)

    def __init__(self, parent):
        super(DistributionSelector, self).__init__(parent)
        self.browse_btn = None
        self.label = None
        self.line_edit = None
        self.setup_widget()

    def set_distribution(self, path):
        """Set distribution directory"""
        self.line_edit.setText(path)

    def setup_widget(self):
        """Setup workspace selector widget"""
        self.label = QLabel()
        self.line_edit = QLineEdit()
        self.line_edit.setAlignment(Qt.AlignRight)
        self.line_edit.setReadOnly(True)
        # self.line_edit.setDisabled(True)
        self.browse_btn = QPushButton(get_std_icon('DirOpenIcon'), "", self)
        self.browse_btn.setToolTip(self.TITLE)
        # PyQt4 old SIGNAL:self.connect(self.browse_btn, SIGNAL("clicked()"),
        # PyQt4 old SIGNAL:             self.select_directory)
        self.browse_btn.clicked.connect(self.select_directory)
        layout = QHBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.line_edit)
        layout.addWidget(self.browse_btn)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

    def select_directory(self):
        """Select directory"""
        basedir = to_text_string(self.line_edit.text())
        if not osp.isdir(basedir):
            basedir = getcwd()
        while True:
            directory = getexistingdirectory(self, self.TITLE, basedir)
            if not directory:
                break
            if not utils.is_python_distribution(directory):
                QMessageBox.warning(self, self.TITLE,
                    "The following directory is not a Python distribution.",
                    QMessageBox.Ok)
                basedir = directory
                continue
            directory = osp.abspath(osp.normpath(directory))
            self.set_distribution(directory)
            # PyQt4 old SIGNAL: self.emit(SIGNAL('selected_distribution(QString)'), directory)
            self.selected_distribution.emit(directory)
            break
Ejemplo n.º 3
0
 def setup_widget(self):
     """Setup workspace selector widget"""
     self.label = QLabel()
     self.line_edit = QLineEdit()
     self.line_edit.setAlignment(Qt.AlignRight)
     self.line_edit.setReadOnly(True)
     # self.line_edit.setDisabled(True)
     self.browse_btn = QPushButton(get_std_icon('DirOpenIcon'), "", self)
     self.browse_btn.setToolTip(self.TITLE)
     # PyQt4 old SIGNAL:self.connect(self.browse_btn, SIGNAL("clicked()"),
     # PyQt4 old SIGNAL:             self.select_directory)
     self.browse_btn.clicked.connect(self.select_directory)
     layout = QHBoxLayout()
     layout.addWidget(self.label)
     layout.addWidget(self.line_edit)
     layout.addWidget(self.browse_btn)
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
Ejemplo n.º 4
0
 def setup_widget(self):
     """Setup workspace selector widget"""
     self.label = QLabel()
     self.line_edit = QLineEdit()
     self.line_edit.setAlignment(Qt.AlignRight)
     self.line_edit.setReadOnly(True)
     # self.line_edit.setDisabled(True)
     self.browse_btn = QPushButton(get_std_icon('DirOpenIcon'), "", self)
     self.browse_btn.setToolTip(self.TITLE)
     # PyQt4 old SIGNAL:self.connect(self.browse_btn, SIGNAL("clicked()"),
     # PyQt4 old SIGNAL:             self.select_directory)
     self.browse_btn.clicked.connect(self.select_directory)
     layout = QHBoxLayout()
     layout.addWidget(self.label)
     layout.addWidget(self.line_edit)
     layout.addWidget(self.browse_btn)
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)