示例#1
0
 def __init__(self, data, comment="", parent=None):
     QWidget.__init__(self, parent)
     from copy import deepcopy
     self.data = deepcopy(data)
     self.widgets = []
     self.formlayout = QFormLayout(self)
     if comment:
         self.formlayout.addRow(QLabel(comment))
         self.formlayout.addRow(QLabel(" "))
     if DEBUG_FORMLAYOUT:
         print("\n"+("*"*80))
         print("DATA:", self.data)
         print("*"*80)
         print("COMMENT:", comment)
         print("*"*80)
示例#2
0
    def __init__(self, parent=None):
        super(KernelConnectionDialog, self).__init__(parent)
        self.setWindowTitle(_('Connect to an existing kernel'))

        main_label = QLabel(
            _("Please enter the connection info of the kernel "
              "you want to connect to. For that you can "
              "either select its JSON connection file using "
              "the <tt>Browse</tt> button, or write directly "
              "its id, in case it's a local kernel (for "
              "example <tt>kernel-3764.json</tt> or just "
              "<tt>3764</tt>)."))
        main_label.setWordWrap(True)
        main_label.setAlignment(Qt.AlignJustify)

        # connection file
        cf_label = QLabel(_('Connection info:'))
        self.cf = QLineEdit()
        self.cf.setPlaceholderText(_('Path to connection file or kernel id'))
        self.cf.setMinimumWidth(250)
        cf_open_btn = QPushButton(_('Browse'))
        self.connect(cf_open_btn, SIGNAL('clicked()'),
                     self.select_connection_file)

        cf_layout = QHBoxLayout()
        cf_layout.addWidget(cf_label)
        cf_layout.addWidget(self.cf)
        cf_layout.addWidget(cf_open_btn)

        # remote kernel checkbox
        self.rm_cb = QCheckBox(_('This is a remote kernel'))

        # ssh connection
        self.hn = QLineEdit()
        self.hn.setPlaceholderText(_('username@hostname:port'))

        self.kf = QLineEdit()
        self.kf.setPlaceholderText(_('Path to ssh key file'))
        kf_open_btn = QPushButton(_('Browse'))
        self.connect(kf_open_btn, SIGNAL('clicked()'), self.select_ssh_key)

        kf_layout = QHBoxLayout()
        kf_layout.addWidget(self.kf)
        kf_layout.addWidget(kf_open_btn)

        self.pw = QLineEdit()
        self.pw.setPlaceholderText(_('Password or ssh key passphrase'))
        self.pw.setEchoMode(QLineEdit.Password)

        ssh_form = QFormLayout()
        ssh_form.addRow(_('Host name'), self.hn)
        ssh_form.addRow(_('Ssh key'), kf_layout)
        ssh_form.addRow(_('Password'), self.pw)

        # Ok and Cancel buttons
        accept_btns = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)

        self.connect(accept_btns, SIGNAL('accepted()'), self.accept)
        self.connect(accept_btns, SIGNAL('rejected()'), self.reject)

        # Dialog layout
        layout = QVBoxLayout(self)
        layout.addWidget(main_label)
        layout.addLayout(cf_layout)
        layout.addWidget(self.rm_cb)
        layout.addLayout(ssh_form)
        layout.addWidget(accept_btns)

        # remote kernel checkbox enables the ssh_connection_form
        def ssh_set_enabled(state):
            for wid in [self.hn, self.kf, kf_open_btn, self.pw]:
                wid.setEnabled(state)
            for i in range(ssh_form.rowCount()):
                ssh_form.itemAt(2 * i).widget().setEnabled(state)

        ssh_set_enabled(self.rm_cb.checkState())
        self.connect(self.rm_cb, SIGNAL('stateChanged(int)'), ssh_set_enabled)