def __init__(self, callback, roles, values): OkCancelDialog.__init__(self, label=self.vis_label) self.callback = callback self.wnd_role = QComboBox(self) self.wnd_role.setEditable(True) self.wnd_role.addItems(sorted(list(roles))) self.wnd_value = QComboBox(self) self.wnd_value.setEditable(True) self.wnd_value.addItems(sorted(list(roles))) layout = QVBoxLayout(self) layout.addWidget(QLabel(self.msg_role, self)) layout.addWidget(self.wnd_role) layout.addWidget(QLabel(self.msg_value, self)) layout.addWidget(self.wnd_value) self.AddButtons(layout) if self.exec_() == QDialog.Accepted: self.callback( str(self.wnd_role.text()).strip(), str(self.wnd_value.text()).strip()) else: self.callback(None)
def __init__(self, label=None): OkCancelDialog.__init__(self, label=label or self.vis_label) self.wnd_uri = QLineEdit(self) self.wnd_login = QLineEdit(self) self.wnd_password = QLineEdit(self) self.wnd_password.setEchoMode(QLineEdit.Password) self.wnd_report = QPlainTextEdit(self) self.wnd_report.setReadOnly(True) layout = QVBoxLayout(self) layout.addWidget(QLabel(self.msg_uri, self)) layout.addWidget(self.wnd_uri) layout.addWidget(QLabel(self.msg_login, self)) layout.addWidget(self.wnd_login) layout.addWidget(QLabel(self.msg_pasword, self)) layout.addWidget(self.wnd_password) box = QGroupBox(tm.main.connection_log, self) layout.addWidget(box) box_layout = QVBoxLayout(box) box_layout.addWidget(self.wnd_report) self.AddButtons(layout) self.connection = None self.exec_()
def accept(self): self.uri = str(self.wnd_uri.text()).strip() parsed = urlparse.urlparse(self.uri) if parsed.username and parsed.password: self.login = parsed.username self.password = parsed.password s1 = self.uri.split('//', 1)[0] s2 = self.uri.split('@', 1)[-1] self.uri = s1 + '//' + s2 else: self.login = str(self.wnd_login.text()) self.password = str(self.wnd_password.text()) self.wnd_report.setPlainText(self.msg_connecting.format(self.uri)) self.connection = SparqlConnection(self.uri, self.login, self.password) if self.connection.connected: OkCancelDialog.accept(self) return if self.connection.last_err == 401: self.wnd_report.appendPlainText(self.msg_401) elif self.connection.last_err == 0: self.wnd_report.appendPlainText(self.msg_notfound) else: self.wnd_report.appendPlainText( self.msg_error.format(self.connection.last_err)) self.connection = None
def __init__(self, callback, supertemplate=None): OkCancelDialog.__init__(self, label=self.vis_label) self.callback = callback if supertemplate: self.wnd_supertemplate = QLineEdit(supertemplate, self) self.wnd_supertemplate.setReadOnly(True) self.wnd_label = QLineEdit(self) self.wnd_label.setFocus() self.wnd_comment = QPlainTextEdit(self) self.wnd_comment.setTabChangesFocus(True) self.wnd_uri = QLineEdit(self) layout = QVBoxLayout(self) if supertemplate: layout.addWidget(QLabel(self.msg_supertemplate, self)) layout.addWidget(self.wnd_supertemplate) layout.addWidget(QLabel(self.msg_label, self)) layout.addWidget(self.wnd_label) layout.addWidget(QLabel(self.msg_comment, self)) layout.addWidget(self.wnd_comment) layout.addWidget(QLabel(self.msg_uri, self)) layout.addWidget(self.wnd_uri) self.AddButtons(layout) if self.exec_() == QDialog.Accepted: self.callback((str(self.wnd_label.text()).strip(), str(self.wnd_comment.toPlainText()).strip(), str(self.wnd_uri.text()).strip())) else: self.callback(None)
def __init__(self, callback, supertemplate=None): OkCancelDialog.__init__(self, label=self.vis_label) self.callback = callback if supertemplate: self.wnd_supertemplate = QLineEdit(supertemplate, self) self.wnd_supertemplate.setReadOnly(True) self.wnd_label = QLineEdit(self) self.wnd_label.setFocus() self.wnd_comment = QPlainTextEdit(self) self.wnd_comment.setTabChangesFocus(True) self.wnd_uri = QLineEdit(self) layout = QVBoxLayout(self) if supertemplate: layout.addWidget(QLabel(self.msg_supertemplate, self)) layout.addWidget(self.wnd_supertemplate) layout.addWidget(QLabel(self.msg_label, self)) layout.addWidget(self.wnd_label) layout.addWidget(QLabel(self.msg_comment, self)) layout.addWidget(self.wnd_comment) layout.addWidget(QLabel(self.msg_uri, self)) layout.addWidget(self.wnd_uri) self.AddButtons(layout) if self.exec_()==QDialog.Accepted: self.callback((str(self.wnd_label.text()).strip(), str(self.wnd_comment.toPlainText()).strip(), str(self.wnd_uri.text()).strip())) else: self.callback(None)
def __init__(self, callback, uri, prop_list): OkCancelDialog.__init__(self, label=self.vis_label) self.callback = callback self.props = list(prop_list) self.props.sort() self.wnd_prop = QComboBox(self) self.wnd_prop.addItems(self.props) self.wnd_value = QLineEdit(uri, self) self.wnd_value.setReadOnly(True) layout = QVBoxLayout(self) layout.addWidget(QLabel(self.msg_property, self)) layout.addWidget(self.wnd_prop) layout.addWidget(QLabel(self.msg_object, self)) layout.addWidget(self.wnd_value) self.AddButtons(layout) if self.exec_()==QDialog.Accepted: self.callback((str(self.wnd_prop.currentText()).strip(), str(self.wnd_value.text()).strip())) else: self.callback(None)
def __init__(self, callback, uri, prop_list): OkCancelDialog.__init__(self, label=self.vis_label) self.callback = callback self.props = list(prop_list) self.props.sort() self.wnd_prop = QComboBox(self) self.wnd_prop.addItems(self.props) self.wnd_value = QLineEdit(uri, self) self.wnd_value.setReadOnly(True) layout = QVBoxLayout(self) layout.addWidget(QLabel(self.msg_property, self)) layout.addWidget(self.wnd_prop) layout.addWidget(QLabel(self.msg_object, self)) layout.addWidget(self.wnd_value) self.AddButtons(layout) if self.exec_() == QDialog.Accepted: self.callback((str(self.wnd_prop.currentText()).strip(), str(self.wnd_value.text()).strip())) else: self.callback(None)
def __init__(self, callback, etype): OkCancelDialog.__init__(self, label=self.vis_label) self.callback = callback self.wnd_type = QLineEdit(etype, self) self.wnd_type.setReadOnly(True) self.wnd_label = QLineEdit(self) self.wnd_label.setFocus() self.wnd_uri = QLineEdit(self) layout = QVBoxLayout(self) layout.addWidget(QLabel(self.msg_type, self)) layout.addWidget(self.wnd_type) layout.addWidget(QLabel(self.msg_label, self)) layout.addWidget(self.wnd_label) layout.addWidget(QLabel(self.msg_uri, self)) layout.addWidget(self.wnd_uri) self.AddButtons(layout) if self.exec_()==QDialog.Accepted: self.callback((str(self.wnd_label.text()).strip(), str(self.wnd_uri.text()).strip())) else: self.callback(None)
def __init__(self, callback, etype): OkCancelDialog.__init__(self, label=self.vis_label) self.callback = callback self.wnd_type = QLineEdit(etype, self) self.wnd_type.setReadOnly(True) self.wnd_label = QLineEdit(self) self.wnd_label.setFocus() self.wnd_uri = QLineEdit(self) layout = QVBoxLayout(self) layout.addWidget(QLabel(self.msg_type, self)) layout.addWidget(self.wnd_type) layout.addWidget(QLabel(self.msg_label, self)) layout.addWidget(self.wnd_label) layout.addWidget(QLabel(self.msg_uri, self)) layout.addWidget(self.wnd_uri) self.AddButtons(layout) if self.exec_() == QDialog.Accepted: self.callback((str(self.wnd_label.text()).strip(), str(self.wnd_uri.text()).strip())) else: self.callback(None)
def __init__(self, callback, roles, values): OkCancelDialog.__init__(self, label=self.vis_label) self.callback = callback self.wnd_role = QComboBox(self) self.wnd_role.setEditable(True) self.wnd_role.addItems(sorted(list(roles))) self.wnd_value = QComboBox(self) self.wnd_value.setEditable(True) self.wnd_value.addItems(sorted(list(roles))) layout = QVBoxLayout(self) layout.addWidget(QLabel(self.msg_role, self)) layout.addWidget(self.wnd_role) layout.addWidget(QLabel(self.msg_value, self)) layout.addWidget(self.wnd_value) self.AddButtons(layout) if self.exec_()==QDialog.Accepted: self.callback( str(self.wnd_role.text()).strip(), str(self.wnd_value.text()).strip() ) else: self.callback(None)
def accept(self): self.uri = str(self.wnd_uri.text()).strip() parsed = urlparse.urlparse(self.uri) if parsed.username and parsed.password: self.login = parsed.username self.password = parsed.password s1 = self.uri.split('//', 1)[0] s2 = self.uri.split('@', 1)[-1] self.uri = s1+'//'+s2 else: self.login = str(self.wnd_login.text()) self.password = str(self.wnd_password.text()) self.wnd_report.setPlainText(self.msg_connecting.format(self.uri)) self.connection = SparqlConnection(self.uri, self.login, self.password) if self.connection.connected: OkCancelDialog.accept(self) return if self.connection.last_err==401: self.wnd_report.appendPlainText(self.msg_401) elif self.connection.last_err==0: self.wnd_report.appendPlainText(self.msg_notfound) else: self.wnd_report.appendPlainText(self.msg_error.format(self.connection.last_err)) self.connection = None