def keyPressEvent(self, event): #Override keyLeft = 16777234 keyRight = 16777236 keyUp = 16777235 keyDown = 16777237 keyReturn = 16777220 if event.key() == Qt.Key_0 or \ event.key() == Qt.Key_1 or \ event.key() == Qt.Key_2 or \ event.key() == Qt.Key_3 or \ event.key() == Qt.Key_4 or \ event.key() == Qt.Key_5 or \ event.key() == Qt.Key_6 or \ event.key() == Qt.Key_7 or \ event.key() == Qt.Key_8 or \ event.key() == Qt.Key_9 or \ event.key() == Qt.Key_Backspace or \ event.key() == Qt.LeftArrow or \ event.key() == Qt.RightArrow or \ event.key() == Qt.UpArrow or \ event.key() == Qt.DownArrow or \ event.key() == Qt.ArrowCursor or \ event.key() == keyLeft or \ event.key() == keyRight or \ event.key() == keyUp or \ event.key() == keyDown or \ event.key() == keyReturn or \ event.key() == Qt.Key_Delete: QLineEdit.keyPressEvent(self, event) else: pass
def keyPressEvent(self, event): #Override keyLeft = 16777234 keyRight = 16777236 keyUp = 16777235 keyDown = 16777237 keyReturn = 16777220 if event.key() == Qt.Key_Period: pass else: QLineEdit.keyPressEvent(self, event)
def buildColorStepsControl(self): """Builds the portion of this widget for color cycling options.""" widget = QWidget() layout = QHBoxLayout() self.stepBox = QCheckBox(self.color_step_label) self.stepBox.stateChanged.connect(self.colorstepsChange) self.stepEdit = QLineEdit("8", self) # Setting max to sys.maxint in the validator causes an overflow! D: self.stepEdit.setValidator(QIntValidator(1, 65536, self.stepEdit)) self.stepEdit.setEnabled(False) self.stepEdit.editingFinished.connect(self.colorstepsChange) if self.color_step > 0: self.stepBox.setCheckState(Qt.Checked) self.stepEdit.setEnabled(True) layout.addWidget(self.stepBox) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(QLabel("with")) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(self.stepEdit) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(QLabel(self.number_steps_label)) widget.setLayout(layout) return widget
def __init__(self, *args, **kwargs): super(TextDialog, self).__init__(*args, **kwargs) self.edit_line = QLineEdit() self.ok_btn = QPushButton("&Ok") # noinspection PyUnresolvedReferences self.ok_btn.clicked.connect(self.accept) self.ok_btn.setDefault(True) self.cancel_btn = QPushButton("&Cancel") # noinspection PyUnresolvedReferences self.cancel_btn.clicked.connect(self.reject) self.h_layout = QHBoxLayout() self.v_layout = QVBoxLayout() self.h_layout.addStretch(0) self.h_layout.addWidget(self.ok_btn) self.h_layout.addWidget(self.cancel_btn) self.v_layout.addWidget(self.edit_line) self.v_layout.addLayout(self.h_layout) self.setLayout(self.v_layout) # noinspection PyUnresolvedReferences self.accepted.connect(self.on_accept) # noinspection PyUnresolvedReferences self.rejected.connect(self.on_reject)
def __init__(self, parent=None): super(LoginForm, self).__init__(parent) self.setWindowTitle("Login") self.status_icon = QIcon.fromTheme("user-offline") self.setWindowIcon(self.status_icon) self.server_status = QLabel() self.server_status.setAlignment(Qt.AlignCenter) self.server_status.setPixmap(self.status_icon.pixmap(64)) self.username = QLineEdit("Username") self.password = QLineEdit("Password") self.password.setEchoMode(QLineEdit.Password) self.login_button = QPushButton("Getting server status...") self.login_button.setEnabled(False) self.login_button.clicked.connect(self.login) self.login_button.setIcon(self.status_icon) self.ping_timer = QTimer(self) self.connect(self.ping_timer, SIGNAL("timeout()"), self.is_server_up) self.ping_timer.start(1000) layout = QVBoxLayout() for w in (self.server_status, self.username, self.password, self.login_button): layout.addWidget(w) self.setLayout(layout) self.logged_in.connect(qtclient.login)
def __init__(self, *args, **kwargs): self.saveInfo = False self.title = '' if kwargs.has_key('title'): self.title = kwargs.pop('title') if kwargs.has_key('saveInfo'): self.saveInfo = kwargs.pop('saveInfo') self.path_uiInfo = path_basedir + "/Widget_Controller_%s.json" % self.title super(Widget_loadObject, self).__init__(*args, **kwargs) self.installEventFilter( self ) mainLayout = QHBoxLayout(self) self.setStyleSheet( "font:12px;" ) label = QLabel( "%s : " % self.title ); label.setFixedWidth( 80 ) lineEdit = QLineEdit(); lineEdit.setStyleSheet( "padding:2px; padding-bottom:1px" ) button = QPushButton( "Load" ); button.setFixedWidth( 70 ) button.setStyleSheet( "padding:3px;padding-left:6px;padding-right:6px" ) mainLayout.addWidget( label ) mainLayout.addWidget( lineEdit ) mainLayout.addWidget( button ) button.clicked.connect( self.load_target ) self.lineEdit = lineEdit if self.saveInfo : self.load_lineEdit_text( self.lineEdit, self.path_uiInfo ) self.button = button
def __init__(self, *args, **kwargs): super(SetDriverDialog, self).__init__(*args, **kwargs) self.setWindowTitle(u"X盘 映射工具") layout = QVBoxLayout() self.setLayout(layout) self.Path_Get = QWidget() path_layout = QHBoxLayout() path_layout.setContentsMargins(0, 0, 0, 0) self.Path_Get.setLayout(path_layout) self.label = QLabel(u"获取本地路径") self.edit = QLineEdit() self.button = QPushButton(u"获取路径") path_layout.addWidget(self.label) path_layout.addWidget(self.edit) path_layout.addWidget(self.button) self.Execute_BTN = QPushButton(u"映射 X 盘") layout.addWidget(self.Path_Get) layout.addWidget(self.Execute_BTN) self.button.clicked.connect(self.getPath) self.Execute_BTN.clicked.connect(self.unc2XDriver)
def setup_general_server_group(self): """ Setup the 'Server' group in the 'General' tab. Returns: -------- A QGroupBox widget """ group = QGroupBox('Server') layout = QFormLayout() layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) email, password = self.auth_credentials() self.email_edit = QLineEdit(email) self.email_edit.textChanged.connect(self.update_auth) layout.addRow('Email', self.email_edit) self.password_edit = QLineEdit(password) self.password_edit.setEchoMode(QLineEdit.Password) self.password_edit.textChanged.connect(self.update_auth) layout.addRow('Password', self.password_edit) show_password_widget = QCheckBox() show_password_widget.stateChanged.connect(self.on_show_password_toggle) layout.addRow('Show password', show_password_widget) test_authentication_button = QPushButton('Test Authentication') test_authentication_button.clicked.connect(self.on_test_authentication) layout.addRow(test_authentication_button) group.setLayout(layout) return group
def __init__(self, parent=None): QWidget.__init__(self, parent) self.__parent = parent self.setWindowTitle("Add Employee") self.id = QLineEdit(self) self.id.setValidator(QRegExpValidator(QRegExp("[a-zA-Z0-9-_]+"))) self.name = QLineEdit(self) self.name.setValidator(QRegExpValidator(QRegExp("[a-zA-Z\s]+"))) self.designation = QComboBox(self) # self.designation.addItems(DatabaseManager.db.getDesignations()) self.originalPay = QLineEdit(self) self.originalPay.setValidator(QDoubleValidator()) self.originalPayGrade = QLineEdit(self) self.originalPayGrade.setValidator(QDoubleValidator()) self.DOJ = DatePicker(self) self.pan = QLineEdit(self) self.pan.setValidator(QRegExpValidator(QRegExp("[A-Z]{5}\d{4}[A-Z]"))) self.bttnAddEmployee = QPushButton("Add Employee") self.bttnCancel = QPushButton("Cancel") self.bttnAddEmployee.setObjectName("OkButton") self.bttnCancel.setObjectName("CancelButton") self.bttnCancel.clicked.connect(self.goBack) self.bttnAddEmployee.clicked.connect(self.add) self.designation.addItems(DatabaseManager.db.getDesignations()) self.setupUI()
def __init__(self, text, minValue, maxValue, defaultValue ): QWidget.__init__( self ) validator = QDoubleValidator(minValue, maxValue, 2, self ) mainLayout = QHBoxLayout( self ) checkBox = QCheckBox() checkBox.setFixedWidth( 115 ) checkBox.setText( text ) lineEdit = QLineEdit() lineEdit.setValidator( validator ) lineEdit.setText( str(defaultValue) ) slider = QSlider( QtCore.Qt.Horizontal ) slider.setMinimum( minValue*100 ) slider.setMaximum( maxValue*100 ) slider.setValue( defaultValue ) mainLayout.addWidget( checkBox ) mainLayout.addWidget( lineEdit ) mainLayout.addWidget( slider ) QtCore.QObject.connect( slider, QtCore.SIGNAL( 'valueChanged(int)' ), self.syncWidthLineEdit ) QtCore.QObject.connect( lineEdit, QtCore.SIGNAL( 'textChanged(QString)' ), self.syncWidthSlider ) QtCore.QObject.connect( checkBox, QtCore.SIGNAL( "clicked()" ), self.updateEnabled ) self.checkBox = checkBox self.slider = slider self.lineEdit = lineEdit self.updateEnabled()
class qlabeled_entry(QWidget): def __init__(self, var, text, pos = "side", max_size = 200): QWidget.__init__(self) self.setContentsMargins(1, 1, 1, 1) if pos == "side": self.layout1=QHBoxLayout() else: self.layout1 = QVBoxLayout() self.layout1.setContentsMargins(1, 1, 1, 1) self.layout1.setSpacing(1) self.setLayout(self.layout1) self.efield = QLineEdit("Default Text") # self.efield.setMaximumWidth(max_size) self.efield.setFont(QFont('SansSerif', 12)) self.label = QLabel(text) # self.label.setAlignment(Qt.AlignLeft) self.label.setFont(QFont('SansSerif', 12)) self.layout1.addWidget(self.label) self.layout1.addWidget(self.efield) self.var = var self.efield.textChanged.connect(self.when_modified) def when_modified(self): self.var.set(self.efield.text()) def hide(self): QWidget.hide(self)
def _initUI(self): # Widgets val, unc = self.result().absorbed self._txt_absorbed = QLineEdit() self._txt_absorbed.setText(u"{0:n} \u00b1 {1:n}".format(val, unc)) self._txt_absorbed.setReadOnly(True) val, unc = self.result().backscattered self._txt_backscattered = QLineEdit() self._txt_backscattered.setText(u"{0:n} \u00b1 {1:n}".format(val, unc)) self._txt_backscattered.setReadOnly(True) val, unc = self.result().transmitted self._txt_transmitted = QLineEdit() self._txt_transmitted.setText(u"{0:n} \u00b1 {1:n}".format(val, unc)) self._txt_transmitted.setReadOnly(True) # Layouts layout = _SaveableResultWidget._initUI(self) sublayout = QFormLayout() if sys.platform == "darwin": # Fix for Mac OS layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow) sublayout.addRow("Absorbed fraction", self._txt_absorbed) sublayout.addRow("Backscattered fraction", self._txt_backscattered) sublayout.addRow("Transmitted fraction", self._txt_transmitted) layout.addLayout(sublayout) layout.addStretch() return layout
def __init__(self, url="", parent=None): super(WSDLDialog, self).__init__() self.setWindowTitle("Select Web Service") layout = QVBoxLayout(self) form = QWidget(self) form_layout = QFormLayout(form) self.wsdl_field = QLineEdit() self.wsdl_field.setText(url) form_layout.addRow("WSDL Address:", self.wsdl_field) layout.addWidget(form) self.auth = QGroupBox("Use HTTP Basic Authentication") self.auth.setCheckable(True) self.auth.setChecked(False) auth_layout = QFormLayout(self.auth) self.user_field = QLineEdit() auth_layout.addRow("Username:"******"Pass:", self.pass_field) layout.addWidget(self.auth) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) layout.addWidget(button_box)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(583, 96) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.gridLayout = QGridLayout() self.gridLayout.setObjectName("gridLayout") self.UI_label = QLabel(self.centralwidget) self.UI_label.setObjectName("UI_label") self.gridLayout.addWidget(self.UI_label, 0, 0, 1, 1) self.seleccionarUI_pushButton = QPushButton(self.centralwidget) self.seleccionarUI_pushButton.setObjectName("seleccionarUI_pushButton") self.gridLayout.addWidget(self.seleccionarUI_pushButton, 0, 2, 1, 1) self.Py_label = QLabel(self.centralwidget) self.Py_label.setObjectName("Py_label") self.gridLayout.addWidget(self.Py_label, 1, 0, 1, 1) self.rutaSalida_pushButton = QPushButton(self.centralwidget) self.rutaSalida_pushButton.setObjectName("rutaSalida_pushButton") self.gridLayout.addWidget(self.rutaSalida_pushButton, 1, 2, 1, 1) self.rutaEntrada_lineEdit = QLineEdit(self.centralwidget) self.rutaEntrada_lineEdit.setEnabled(False) self.rutaEntrada_lineEdit.setObjectName("rutaEntrada_lineEdit") self.gridLayout.addWidget(self.rutaEntrada_lineEdit, 0, 1, 1, 1) self.rutaSalida_lineEdit = QLineEdit(self.centralwidget) self.rutaSalida_lineEdit.setObjectName("rutaSalida_lineEdit") self.gridLayout.addWidget(self.rutaSalida_lineEdit, 1, 1, 1, 1) self.verticalLayout.addLayout(self.gridLayout) self.horizontalWidget = QWidget(self.centralwidget) self.horizontalWidget.setObjectName("horizontalWidget") self.horizontalLayout = QHBoxLayout(self.horizontalWidget) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setObjectName("horizontalLayout") spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.convertir_pushButton = QPushButton(self.horizontalWidget) self.convertir_pushButton.setObjectName("convertir_pushButton") self.horizontalLayout.addWidget(self.convertir_pushButton) self.verticalLayout.addWidget(self.horizontalWidget) MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow)
class PVProbe(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) self.setWindowTitle("PyQt4 PV Probe:") self.pv1name = QLineEdit() self.pv2name = QLineEdit() self.value = PVText(None) self.pvedit = PVLineEdit() grid = QGridLayout() grid.addWidget(QLabel("PV1 Name (Read-only):"), 0, 0) grid.addWidget(QLabel("PV1 Value (Read-only):"), 1, 0) grid.addWidget(QLabel("PV2 Name: (Read-write):"), 2, 0) grid.addWidget(QLabel("PV2 Value (Read-write):"), 3, 0) grid.addWidget(self.pv1name, 0, 1) grid.addWidget(self.value, 1, 1) grid.addWidget(self.pv2name, 2, 1) grid.addWidget(self.pvedit, 3, 1) self.pv1name.returnPressed.connect(self.onPV1NameReturn) self.pv2name.returnPressed.connect(self.onPV2NameReturn) self.setLayout(grid) def onPV1NameReturn(self): self.value.SetPV(self.pv1name.text()) def onPV2NameReturn(self): self.pvedit.SetPV(self.pv2name.text())
def createWidgets(self): """Create children widgets needed by this view""" fieldsWidth = 450 labelsFont = View.labelsFont() editsFont = View.editsFont() self.setLogo() self.localdirLabel = QLabel(self) self.localdirEdit = QLineEdit(self) self.localdirLabel.setText('Choose a folder') self.localdirLabel.setFont(labelsFont) self.localdirEdit.setFixedWidth(fieldsWidth) self.localdirEdit.setReadOnly(False) self.localdirEdit.setFont(editsFont) self.browseButton = QPushButton(self) self.browseButton.setText('Browse') self.browseButton.setFont(labelsFont) self.syncButton = QPushButton(self) self.syncButton.setText('Sync') self.syncButton.setFont(labelsFont) self.browseButton.clicked.connect(self.onBrowseClicked) self.syncButton.clicked.connect(self.onSyncClicked) settings = get_settings() self.localdirEdit.setText(settings.value(SettingsKeys['localdir'], '')) self.statusLabel = QLabel(self) self.statusLabel.setText('Status') self.statusLabel.setFont(View.labelsFont()) self.status = StatusArea(self)
def __init__(self): super(DirectoryDialog, self).__init__() self.setWindowTitle("Query") rect = QApplication.desktop().screenGeometry() height = rect.height() width = rect.width() self.setGeometry(width / 3, height / 3, width / 3, height / 8) formLayout = QFormLayout() self.dir = QLineEdit() self.dir.setReadOnly(True) formLayout.addRow(QLabel("Select a folder"), self.dir) browseBtn = QPushButton("Browse") browseBtn.clicked.connect(self.browseAction) formLayout.addWidget(browseBtn) btnOk = QPushButton("Ok") btnOk.clicked.connect(self.okAction) btnCancel = QPushButton("Cancel") btnCancel.clicked.connect(self.reject) group = QDialogButtonBox() group.addButton(btnOk, QDialogButtonBox.AcceptRole) group.addButton(btnCancel, QDialogButtonBox.RejectRole) formLayout.addRow(group) self.setLayout(formLayout) self.setWindowIcon(QIcon("res/SplashScreen.png")) self.__result = None
def setup_gui(self): """Sets up a sample gui interface.""" central_widget = QWidget(self) central_widget.setObjectName('central_widget') self.label = QLabel('Hello World') self.input_field = QLineEdit() change_button = QPushButton('Change text') close_button = QPushButton('close') quit_button = QPushButton('quit') central_layout = QVBoxLayout() button_layout = QHBoxLayout() central_layout.addWidget(self.label) central_layout.addWidget(self.input_field) # a separate layout to display buttons horizontal button_layout.addWidget(change_button) button_layout.addWidget(close_button) button_layout.addWidget(quit_button) central_layout.addLayout(button_layout) central_widget.setLayout(central_layout) self.setCentralWidget(central_widget) # create a system tray icon. Uncomment the second form, to have an # icon assigned, otherwise you will only be seeing an empty space in # system tray self.systemtrayicon = QSystemTrayIcon(self) self.systemtrayicon.show() # set a fancy icon self.systemtrayicon.setIcon(QIcon.fromTheme('help-browser')) change_button.clicked.connect(self.change_text) quit_button.clicked.connect(QApplication.instance().quit) close_button.clicked.connect(self.hide) # show main window, if the system tray icon was clicked self.systemtrayicon.activated.connect(self.icon_activated)
def __init__(self, parent): super(AddPeriodDialog, self).__init__(parent) t = _("Add a period for an operation definition") self.setWindowTitle(t) self.title_widget = TitleWidget(t, self) top_layout = QVBoxLayout() top_layout.addWidget(self.title_widget) hlayout = QHBoxLayout() hlayout.addWidget(QLabel(_("Start time"), self)) self.date_edit = QLineEdit(self) hlayout.addWidget(self.date_edit) top_layout.addLayout(hlayout) hlayout = QHBoxLayout() hlayout.addWidget(QLabel(_("Hourly cost"), self)) self.hourly_cost = QLineEdit(self) hlayout.addWidget(self.hourly_cost) top_layout.addLayout(hlayout) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) top_layout.addWidget(self.buttons) self.setLayout(top_layout) # QWidget takes ownership of the layout self.buttons.accepted.connect(self.accepted)
def __init__(self, parent=None): super(MainForm, self).__init__(parent) # TODO - set a min width self.setMinimumWidth(500) self.label = QLabel('Input file...') self.input_path = QLineEdit() self.output_path = QLineEdit() convert_button = QPushButton('Convert') input_dialog_button = QPushButton('Browse...') # TODO - provide a dialog for ouput # possibly just a folder picker then they have to provide the name? layout = QGridLayout() layout.addWidget(QLabel('Input Path:'), 0, 0) layout.addWidget(self.input_path, 0, 1) layout.addWidget(input_dialog_button, 0, 2) layout.addWidget(QLabel('Output Path:'), 1, 0) layout.addWidget(self.output_path, 1, 1) layout.addWidget(convert_button, 2, 0) self.setLayout(layout) convert_button.clicked.connect(self.convert) input_dialog_button.clicked.connect(self.open_input_file_dialog) self.setWindowTitle('JWPCE to CSV convert')
class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) self.resultList = QTextBrowser() self.resultInput = QLineEdit( "Enter an expression and press Return key") layout = QVBoxLayout() layout.addWidget(self.resultList) layout.addWidget(self.resultInput) self.setLayout(layout) self.resultInput.selectAll() self.resultInput.setFocus() # New way of Connect the signal self.resultInput.returnPressed.connect(self.compute) # Old Way of connect signal. Does not throw any error #self.connect(self.resultInput,SIGNAL("returnPressed()"),self.compute) def compute(self): try: text = self.resultInput.text() self.resultList.append("{0} = <b> {1} </b>".format( text, eval(text))) except: self.resultList.append( "<font color=red /><b> Expression invalid </b>")
def getParameterWidget(self): matrixLayout = QGridLayout() matrixLayout.setAlignment(Qt.AlignTop) matrixLayout.setContentsMargins(0, 0, 0, 0) matrixLayout.setSpacing(5) matrixLayout.addWidget(QLabel("Transformation matrix:"), 0, 0, 1, 4) self.m1Edits = [QLineEdit() for _ in range(4)] self.m2Edits = [QLineEdit() for _ in range(4)] self.m3Edits = [QLineEdit() for _ in range(4)] self.m4Edits = [QLineEdit() for _ in range(4)] self.initLineEdits(self.m1Edits, matrixLayout, 1, 0) self.initLineEdits(self.m2Edits, matrixLayout, 2, 0) self.initLineEdits(self.m3Edits, matrixLayout, 3, 0) self.initLineEdits(self.m4Edits, matrixLayout, 4, 0) expandingWidget = QWidget() expandingWidget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) matrixLayout.addWidget(expandingWidget, 5, 0, 1, 4) matrixWidget = QWidget() matrixWidget.setLayout(matrixLayout) self.transformUpdated( self.renderWidget.transformations.completeTransform()) return matrixWidget
def __init__(self, lifeline, defaultName, parent=None): super(ClusterDialog, self).__init__(parent) self.lifeline = lifeline layout = QVBoxLayout(self) message = QLabel('Enter group name') layout.addWidget(message) self.editClusterName = QLineEdit(defaultName) self.editClusterName.setFixedHeight(30) self.editClusterName.setFixedWidth(400) self.editClusterName.textChanged.connect(self.validateCluster) layout.addWidget(self.editClusterName) self.validation_msg = QLabel(' ') layout.addWidget(self.validation_msg) buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons) self.validateCluster()
class Form(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) self.resultsLists = QTextBrowser() self.resultsInput = QLineEdit('Enter an expression and press return key') # Layout the application - vertical order layout = QVBoxLayout() layout.addWidget(self.resultsLists) layout.addWidget(self.resultsInput) self.setLayout(layout) # Define signal - signal for pressing enter # When the signal is set it calls the method compute self.resultsInput.returnPressed.connect(self.compute) # Force window to stay on top when start # self.setFocusPolicy(Qt.StrongFocus) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.resultsInput.selectAll() self.resultsInput.setFocus() def compute(self): try: text = self.resultsInput.text() self.resultsLists.append('{0} = <b>{1}</b>'.format(text, eval(text))) except: self.resultsLists.append('<font color=red><b>Expression invalid</b></font>')
def initUi(self): self.grid = QGridLayout() self.grid.addWidget(QLabel("Connection name"), 0, 0) self.grid.addWidget(QLabel("Username"), 2, 0) self.grid.addWidget(QLabel("Password"), 4, 0) self.grid.addWidget(QLabel("Hostname"), 6, 0) self.grid.addWidget(QLabel("Port"), 8, 0) self.connectionNameInput = QLineEdit(self) self.grid.addWidget(self.connectionNameInput, 1, 0) self.userNameInput = QLineEdit(self) self.grid.addWidget(self.userNameInput, 3, 0) self.passwordInput = QLineEdit(self) self.grid.addWidget(self.passwordInput, 5, 0) self.hostnameInput = QLineEdit(self) self.grid.addWidget(self.hostnameInput, 7, 0) self.portSpinBox = QSpinBox(self) self.portSpinBox.setMinimum(1) self.portSpinBox.setMaximum(65535) self.portSpinBox.setValue(22) self.grid.addWidget(self.portSpinBox, 9, 0) self.addButton = QPushButton("Accept") self.grid.addWidget(self.addButton, 10, 0) self.setLayout(self.grid) self.addButton.clicked.connect(self.clickedAddButton) self.show()
def __init__(self, parent = None): super(SettingsPage, self).__init__(parent) self.setMinimumSize(800, 600) self.addProperty(grizzle.User, "email", 0, 0) self.addProperty(grizzle.User, "display_name", 1, 0) self.addProperty(sweattrails.userprofile.UserProfile, "_userprofile.dob", 2, 0) self.addProperty(sweattrails.userprofile.UserProfile, "_userprofile.gender", 3, 0, style = "radio") self.addProperty(sweattrails.userprofile.UserProfile, "_userprofile.height", 4, 0, min = 100, max = 240, suffix = "cm") self.addProperty(sweattrails.userprofile.UserProfile, "_userprofile.units", 5, 0, style = "radio") withingsB = QGroupBox("Withings Support", self) withingsL = QGridLayout(withingsB) self.enableWithings = QCheckBox("Enable Withings", withingsB) self.enableWithings.toggled.connect(self.toggleWithings) withingsL.addWidget(self.enableWithings, 0, 0) withingsL.addWidget(QLabel("Withings User ID"), 1, 0) self.withingsUserID = QLineEdit(withingsB) withingsL.addWidget(self.withingsUserID, 1, 1) withingsL.addWidget(QLabel("Withings Key"), 2, 0) self.withingsKey = QLineEdit(withingsB) withingsL.addWidget(self.withingsKey, 2, 1) self.addWidget(withingsB, self.form.rowCount(), 0, 1, 2) self.addStretch() self.statusMessage.connect(QCoreApplication.instance().status_message)
def __init__(self, currentGroupNames=[], parent=None): super(GroupNameDialog, self).__init__(parent) self._current_groupnames = [ groupname.lower() for groupname in currentGroupNames ] self.setModal(True) self.setWindowTitle(self.tr("Group name")) label_prompt = QLabel(self.tr("Enter new launch group name:")) self._lineedit__groupname = QLineEdit() self._label_warning = QLabel() self._label_warning.setStyleSheet(""" QLabel { color: rgb(213, 17, 27); font-weight: bold; } """) self._button_ok = QPushButton(self.tr("OK")) button_cancel = QPushButton(self.tr("Cancel")) self._button_ok.clicked.connect(self._checkGroupName) button_cancel.clicked.connect(self.reject) layout = QGridLayout() row = 0 col = 0 layout.addWidget(label_prompt, 0, 0, 1, 4) row += 1 layout.addWidget(self._lineedit__groupname, row, col, 1, 4) row += 1 col += 2 layout.addWidget(self._button_ok, row, col) col += 1 layout.addWidget(button_cancel, row, col) self.setLayout(layout)
def __init__(self, parent): global configuration super(EditConfigurationDialog, self).__init__(parent) title = _("Preferences") self.setWindowTitle(title) self.title_widget = TitleWidget(title, self) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) self.font_select = QCheckBox() self.server_address = QLineEdit() form_layout = QFormLayout() form_layout.addRow(_("Fonts"), self.font_select) form_layout.addRow(_("Server's IP address"), self.server_address) top_layout = QVBoxLayout() top_layout.addWidget(self.title_widget) top_layout.addLayout(form_layout) top_layout.addWidget(self.buttons) self.setLayout(top_layout) # QWidget takes ownership of the layout self.buttons.accepted.connect(self.save_and_accept) self.buttons.rejected.connect(self.cancel) self._load_configuration(configuration)
def __init__(self,parent=None): super(QtReducePreferencesComputation,self).__init__(parent) reduceGroup = QGroupBox("Reduce") self.reduceBinary = QLineEdit() # font = self.reduceBinary.font() # font.setFamily(QSettings().value("worksheet/fontfamily", # QtReduceDefaults.FONTFAMILY)) # self.reduceBinary.setFont(font) self.reduceBinary.setText(QSettings().value("computation/reduce", QtReduceDefaults.REDUCE)) self.reduceBinary.editingFinished.connect(self.editingFinishedHandler) reduceLayout = QFormLayout() reduceLayout.addRow(self.tr("Reduce Binary"),self.reduceBinary) reduceGroup.setLayout(reduceLayout) mainLayout = QVBoxLayout() mainLayout.addWidget(reduceGroup) self.setLayout(mainLayout)
def __init__(self, parent=None): super(TransferTaskDialog, self).__init__(parent) layout = QFormLayout(self) self.to_queue_selector = QComboBox() self.from_queue_selector = QComboBox() queue_list = cqmanage.cqQueueList() for queue in queue_list: self.to_queue_selector.addItem(str(queue)) self.from_queue_selector.addItem(str(queue)) self.number_to_transfer = QLineEdit("") layout.addRow("To Queue:", self.to_queue_selector) layout.addRow("From Queue:", self.from_queue_selector) layout.addRow("Amount:", self.number_to_transfer) # OK and Cancel buttons self.buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) layout.addWidget(self.buttons) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.setWindowTitle("Transfer Tasks") self.resize(225, 150)
def __init__(self, group_name, name_list, param_type = int, default_param = None, help_instance = None, handler = None, help_dict = None): QGroupBox.__init__(self, group_name) the_layout = QVBoxLayout() the_layout.setSpacing(5) the_layout.setContentsMargins(1, 1, 1, 1) self.setLayout(the_layout) self.widget_dict = OrderedDict([]) self.mytype= param_type self.is_popup = False if default_param == None: default_param = "" self.default_param = default_param for txt in name_list: qh = QHBoxLayout() cb = QCheckBox(txt) cb.setFont(QFont('SansSerif', 12)) efield = QLineEdit(str(default_param)) efield.setFont(QFont('SansSerif', 10)) efield.setMaximumWidth(25) qh.addWidget(cb) qh.addStretch() qh.addWidget(efield) the_layout.addLayout(qh) if handler != None: cb.toggled.connect(handler) self.widget_dict[txt] = [cb, efield] if (help_dict != None) and (help_instance != None): if txt in help_dict: help_button_widget = help_instance.create_button(txt, help_dict[txt]) qh.addWidget(help_button_widget) return
def add_row(self, *args): """adds a new row entry""" table = self.addeachweek.add_eachweek_table table.setSelectionBehavior(QAbstractItemView.SelectRows) table.setEditTriggers(QAbstractItemView.NoEditTriggers) table.setShowGrid(False) table.setAlternatingRowColors(True) table.setStyleSheet("color:#000000;") if args: table.setRowCount(len(args)) for i, j in enumerate(args): checkbox = QCheckBox() table.setCellWidget(i, 0, checkbox) item = QTableWidgetItem(j['item_no']) table.setItem(i, 1, item) item = QTableWidgetItem(j['item']) table.setItem(i, 2, item) item = QTableWidgetItem(j['category']) table.setItem(i, 3, item) item = QTableWidgetItem(j['rate']) table.setItem(i, 4, item) quantity = QLineEdit() quantity.setValidator(QIntValidator(0, 99999)) table.setCellWidget(i, 5, quantity) table.setColumnWidth(0, table.width() / 9) table.setColumnWidth(1, table.width() / 5) table.setColumnWidth(2, table.width() / 5) table.setColumnWidth(3, table.width() / 5) table.setColumnWidth(4, table.width() / 5)
class AskIPAddress(QDialog): def __init__(self, parent): super(AskIPAddress, self).__init__() layout = QVBoxLayout(self) layout.addWidget(QLabel("Please enter a valid address")) glayout = QGridLayout() self.address = QLineEdit() glayout.addWidget(QLabel("IP Address"), 0, 0) glayout.addWidget(self.address, 0, 1) self.address.setText(guess_server_public_ip()) layout.addLayout(glayout) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) layout.addWidget(self.buttons) self.setLayout(layout) self.buttons.accepted.connect(self.accept) @Slot() def accept(self): return super(AskIPAddress, self).accept()
def __create_filter_ui(self): """ Create filter widgets """ filter_layout = QHBoxLayout() filter_layout.setSpacing(1) filter_layout.setContentsMargins(0, 0, 0, 0) self.filter_reset_btn = QPushButton() icon = QIcon(':/filtersOff.png') self.filter_reset_btn.setIcon(icon) self.filter_reset_btn.setIconSize(QSize(22, 22)) self.filter_reset_btn.setFixedSize(24, 24) self.filter_reset_btn.setToolTip('Reset filter') self.filter_reset_btn.setFlat(True) self.filter_reset_btn.clicked.connect( partial(self.on_filter_set_text, '')) self.filter_line = QLineEdit() self.filter_line.setPlaceholderText('Enter filter string here') self.filter_line.textChanged.connect(self.on_filter_change_text) completer = QCompleter(self) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setModel(QStringListModel([], self)) self.filter_line.setCompleter(completer) filter_layout.addWidget(self.filter_reset_btn) filter_layout.addWidget(self.filter_line) return filter_layout
def addTab(self, label ): layoutWidget = QWidget() vLayout = QVBoxLayout(layoutWidget) vLayout.setContentsMargins(5,5,5,5) setFolderLayout = QHBoxLayout() listWidget = QListWidget() listWidget.setSelectionMode( QAbstractItemView.ExtendedSelection ) vLayout.addLayout( setFolderLayout ) vLayout.addWidget( listWidget ) lineEdit = QLineEdit() setFolderButton = QPushButton( 'Set Folder' ) setFolderLayout.addWidget( lineEdit ) setFolderLayout.addWidget( setFolderButton ) QtCore.QObject.connect( setFolderButton, QtCore.SIGNAL( 'clicked()' ), Functions.setFolder ) QtCore.QObject.connect( listWidget, QtCore.SIGNAL( 'itemSelectionChanged()' ), Functions.loadImagePathArea ) QtCore.QObject.connect( lineEdit, QtCore.SIGNAL( 'textChanged()' ), Functions.lineEdited ) listWidget.setObjectName( Window_global.listWidgetObjectName ) lineEdit.setContextMenuPolicy( QtCore.Qt.NoContextMenu ) lineEdit.setObjectName( Window_global.lineEditObjectName ) lineEdit.returnPressed.connect( Functions.lineEdited ) super( Tab, self ).addTab( layoutWidget, label )
def __init__(self, pvname=None, **kws): QLineEdit.__init__(self, **kws) self.returnPressed.connect(self.onReturn) self.pv = None self.cb_index = None if pvname is not None: self.SetPV(pvname)
def __init__(self): super(PhoneFrame, self).__init__() self.setWindowTitle('Phone Book.') self.name = QLineEdit() self.number = QLineEdit() entry = QFormLayout() entry.addRow(QLabel('Name'), self.name) entry.addRow(QLabel('Number'), self.number) buttons = QHBoxLayout() button = QPushButton('&Add') button.clicked.connect(self._addEntry) buttons.addWidget(button) button = QPushButton('&Update') button.clicked.connect(self._updateEntry) buttons.addWidget(button) button = QPushButton('&Delete') button.clicked.connect(self._deleteEntry) buttons.addWidget(button) dataDisplay = QTableView() dataDisplay.setModel(PhoneDataModel()) layout = QVBoxLayout() layout.addLayout(entry) layout.addLayout(buttons) layout.addWidget(dataDisplay) self.setLayout(layout) self.show()
def create_main_area(self, layout): # Master password master_password_label = QLabel("&Master-Passwort:") self.master_password_edit = QLineEdit() self.master_password_edit.setEchoMode(QLineEdit.EchoMode.Password) self.master_password_edit.textChanged.connect(self.masterpassword_changed) self.master_password_edit.returnPressed.connect(self.move_focus) self.master_password_edit.editingFinished.connect(self.masterpassword_entered) self.master_password_edit.setMaximumHeight(28) master_password_label.setBuddy(self.master_password_edit) layout.addWidget(master_password_label) layout.addWidget(self.master_password_edit) # Domain domain_label = QLabel("&Domain:") self.domain_edit = QComboBox() self.domain_edit.setEditable(True) self.domain_edit.textChanged.connect(self.domain_changed) self.domain_edit.currentIndexChanged.connect(self.domain_changed) self.domain_edit.lineEdit().editingFinished.connect(self.domain_entered) self.domain_edit.lineEdit().returnPressed.connect(self.move_focus) self.domain_edit.setMaximumHeight(28) domain_label.setBuddy(self.domain_edit) layout.addWidget(domain_label) layout.addWidget(self.domain_edit) # Username self.username_label = QLabel("&Username:"******"&Passwortstärke:") self.strength_label.setVisible(False) self.strength_selector = PasswordStrengthSelector() self.strength_selector.set_min_length(4) self.strength_selector.set_max_length(36) self.strength_selector.setMinimumHeight(60) self.strength_selector.set_length(12) self.strength_selector.set_complexity(6) self.strength_selector.strength_changed.connect(self.strength_changed) self.strength_selector.setVisible(False) self.strength_label.setBuddy(self.strength_selector) layout.addWidget(self.strength_label) layout.addWidget(self.strength_selector) # Password self.password_label = QLabel("&Passwort:") self.password_label.setVisible(False) self.password = QLabel() self.password.setTextFormat(Qt.PlainText) self.password.setAlignment(Qt.AlignCenter) self.password.setFont(QFont("Helvetica", 18, QFont.Bold)) self.password.setVisible(False) self.password_label.setBuddy(self.password) layout.addWidget(self.password_label) layout.addWidget(self.password)
def initUI(self): self.layoutFile = FileBrowseWidget("Layout settings file .yaml (*.yaml)") self.layoutFile.setText(DEFAULT_LAYOUT_FILE) self.rfSettingsFile = FileBrowseWidget("Device settings file .yaml (*.yaml)") self.rfSettingsFile.setText(DEFAULT_RF_FILE) layout = QFormLayout() layout.addRow(QLabel("Layout settings file (.yaml):"), self.layoutFile) layout.addRow(QLabel("RF settings file (.yaml):"), self.rfSettingsFile) self.idLine = QLineEdit() self.idLine.setText(str(DEFAULT_DEVICE_ID)) self.idLine.setMaximumWidth(50) self.idLine.setValidator(QIntValidator(0, 63)) layout.addRow(QLabel("Device id (0-63):"), self.idLine) self.generateButton = QPushButton("Generate new RF settings") self.generateButton.setMaximumWidth(230) self.generateButton.clicked.connect(self.generateRFSettings) layout.addRow(None, self.generateButton) label = QLabel("<b>Note:</b> These settings only need to be loaded on each " "device once and are persistent when you update the layout. " "To ensure proper operation and security, each device must " "have a unique device ID for a given RF settings file. " "Since RF settings file contains your encryption key, make " "sure to keep it secret.") label.setTextInteractionFlags(Qt.TextSelectableByMouse) label.setWordWrap(True) layout.addRow(label) self.setLayout(layout)
def __init__(self, parent=None): super(AddDialogWidget, self).__init__(parent) nameLabel = QLabel("Name") addressLabel = QLabel("Address") buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.nameText = QLineEdit() self.addressText = QTextEdit() grid = QGridLayout() grid.setColumnStretch(1, 2) grid.addWidget(nameLabel, 0, 0) grid.addWidget(self.nameText, 0, 1) grid.addWidget(addressLabel, 1, 0, Qt.AlignLeft | Qt.AlignTop) grid.addWidget(self.addressText, 1, 1, Qt.AlignLeft) layout = QVBoxLayout() layout.addLayout(grid) layout.addWidget(buttonBox) self.setLayout(layout) self.setWindowTitle("Add a Contact") buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)
def __init__(self, folderBrowser): super(MovieList, self).__init__() mainLayout = QVBoxLayout() mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(mainLayout) filterLayout = QHBoxLayout() mainLayout.addLayout(filterLayout) self.setWatchedButton = customWidgets.IconButton( "icon_watchList.png", "Set as watched") filterLayout.addWidget(self.setWatchedButton) self.setHideWatchedButton = customWidgets.IconButton( "filter_icon.png", "Set as watched") filterLayout.addWidget(self.setHideWatchedButton) self.filterField = QLineEdit() self.filterField.setObjectName("filterField") filterLayout.addWidget(self.filterField) self.movieList = MovieBrowser(folderBrowser) mainLayout.addWidget(self.movieList) self.progressBar = customWidgets.MyProgress() mainLayout.addWidget(self.progressBar) self.progressBar.setVisible(True) self.setWatchedButton.clicked.connect(self.movieList.setWatched) self.setHideWatchedButton.clicked.connect(self.movieList.hideWatched)
def __init__(self, parent=None): super(Form, self).__init__(parent) #self.setWindowIcon(self.style().standardIcon(QStyle.SP_DirIcon)) #QtGui.QIcon(QtGui.QMessageBox.Critical)) self.txt = QLabel() self.txt.setText("This will remove ALL Suffix from selection objects. .\nDo you want to continue?\n\n\'suffix\'") self.le = QLineEdit() self.le.setObjectName("suffix_filter") self.le.setText(".step") self.pb = QPushButton() self.pb.setObjectName("OK") self.pb.setText("OK") self.pbC = QPushButton() self.pbC.setObjectName("Cancel") self.pbC.setText("Cancel") layout = QFormLayout() layout.addWidget(self.txt) layout.addWidget(self.le) layout.addWidget(self.pb) layout.addWidget(self.pbC) self.setLayout(layout) self.connect(self.pb, SIGNAL("clicked()"),self.OK_click) self.connect(self.pbC, SIGNAL("clicked()"),self.Cancel_click) self.setWindowTitle("Warning ...")
class AreaPage(QWidget): def __init__(self, parent=None): super(AreaPage, self).__init__(parent) name_label = QLabel("Name:") self.name_lineedit = QLineEdit() self.name_lineedit.setReadOnly(True) devicenum_label = QLabel("Number of devices in this relief device area:") self.devicenum_lineedit = QLineEdit() self.devicenum_lineedit.setReadOnly(True) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(name_label, 0, 0) layout.addWidget(self.name_lineedit, 0, 1) layout.addWidget(devicenum_label, 1, 0) layout.addWidget(self.devicenum_lineedit, 1, 1) self.setLayout(layout) self.mapper = QDataWidgetMapper() def setModel(self, proxy_model): self.proxy_model = proxy_model self.mapper.setModel(self.proxy_model.sourceModel()) self.mapper.addMapping(self.name_lineedit, 0) self.mapper.addMapping(self.devicenum_lineedit, 2) def setSelection(self, current): model_index = self.proxy_model.mapToSource(current) parent = model_index.parent() self.mapper.setRootIndex(parent) self.mapper.setCurrentModelIndex(model_index)
def __init__(self, window, ok_handler, cancel_handler): super(SignInDialog, self).__init__(window) self.setWindowTitle("Login") self.setFixedSize(300, 130) self.setModal(True) self.layout = QGridLayout(self) self.username_label = QLabel(self) self.username_label.setText("Username:"******"Password:"******"Login") self.buttons.button(QDialogButtonBox.Cancel).setText("Cancel") self.buttons.button(QDialogButtonBox.Cancel).clicked.connect(cancel_handler) self.buttons.button(QDialogButtonBox.Ok).clicked.connect( lambda: ok_handler(self.edit_username.text(), self.edit_password.text())) self.layout.addWidget(self.username_label, 0, 0) self.layout.addWidget(self.edit_username, 0, 1) self.layout.addWidget(self.password_label, 1, 0) self.layout.addWidget(self.edit_password, 1, 1) self.layout.addWidget(self.buttons, 3, 0, 1, 2, Qt.AlignCenter) self.setLayout(self.layout)
def createEditor(self, parent, option, index): column = index.column() if column == 0: editor = QLineEdit(parent) editor.setValidator(QRegExpValidator(QRegExp(r"^(?!\s*$).+"))) return editor elif column == 1: return None
def __init__(self, parent): QLineEdit.__init__(self, parent) self.__data = None self.setReadOnly(True) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
def __init__(self, parent=None): QLineEdit.__init__(self, parent) self.clear_button = QToolButton(self) self.clear_button.setText("clear") self.clear_button.hide() self.clear_button.clicked.connect(self.clear) # self.clear_button.setIcon(QIcon(":/denied.png")) self.textChanged.connect(self.update_clear_button)
def createEditor(self, parent, option, index): """ Should return a LineEdit with all the Category Names as AutoComplete values """ edit = QLineEdit(parent) completer = QCompleter() edit.setCompleter(completer) model = QStringListModel() completer.setModel(model) self.setCompleterData(model) return edit
class UserListWindow(UberSquareWindow): """ The dialog (window) which shows the list of users, and the filtering text input. """ def __init__(self, title, users, parent): super(UserListWindow, self).__init__(parent) self.setWindowTitle(title) self.cw = QWidget(self) self.setCentralWidget(self.cw) layout = QVBoxLayout(self.cw) self.text_field = QLineEdit(self) self.text_field.setPlaceholderText("Type to filter") self.list = UserListWidget(users, self) self.text_field.textChanged.connect(self.filter) layout.addWidget(self.text_field) layout.addWidget(self.list) updateUsers = Signal() self.connect(self, SIGNAL("updateUsers()"), self._updateUsers) def _updateUsers(self): self.setUsers(self.parent().users()) if not self.shown: self.show() else: QMaemo5InformationBox.information(self, "Leaderboard updated") def filter(self, text): self.list.filter(text) def setUsers(self, users): self.list.setUsers(users) showUser = Signal() self.connect(self, SIGNAL("showUser()"), self.__showUser) def user_selected(self, index): self.uid = self.list.getUser(index)['user']['id'] user = foursquare.get_user(self.uid, foursquare.CacheOrNull) if user: self.userWindow = UserDetailsWindow(user, self) self.userWindow.show() else: t = UserDetailsThread(self.uid, self) t.start() def __showUser(self): user = foursquare.get_user(self.uid, foursquare.CacheOrNull) self.userWindow = UserDetailsWindow(user, self) self.userWindow.show()
class PasteToUpload(QMainWindow): def __init__(self): super(PasteToUpload, self).__init__() self.initUI() def initUI(self): self.resize(290, 150) self.setWindowTitle('PasteToUpload') font = QFont('Helvetica', 16) self.label = QLabel('Ctrl+V', self) self.edit = QLineEdit(self) self.label.setFont(font) self.label.move(45, 25) self.edit.move(45, 85) self.label.setFixedWidth(250) self.edit.setFixedWidth(200) self.edit.setReadOnly(True) self.edit.setFocusPolicy(Qt.NoFocus) self.show() def __sendPost(self, base64): value = { 'key': API_KEY, 'image': base64 } data = urllib.urlencode(value) f = urllib2.urlopen( url='http://api.imgur.com/2/upload.json', data=data ) return json.load(f) def keyPressEvent(self, e): if e.matches(QKeySequence.Paste): clipboard = QApplication.clipboard() mimeData = clipboard.mimeData() if mimeData.hasImage(): image = clipboard.image() byteArray = QByteArray() buf = QBuffer(byteArray) buf.open(QIODevice.WriteOnly) image.save(buf, "PNG") self.label.setText('Uploading') self.thread = NetThread(str(byteArray.toBase64())) self.thread.finished.connect(self.onThreadEnd) self.thread.start() else: self.label.setText('No picture in clipboard') def onThreadEnd(self): url = self.thread.getResult() self.edit.setText(url) QApplication.clipboard().setText(url) self.label.setText('Finish (URL in clipboard)')
def __init__(self, parent): self.parent = parent self.dialog = QDialog(self.parent.parent) mainLayout = QVBoxLayout() aux = QHBoxLayout() name = QLabel("Signal Name: ") self.nameBox = QLineEdit() aux.addWidget(name) aux.addWidget(self.nameBox) aux2 = QWidget() aux2.setLayout(aux) mainLayout.addWidget(aux2) auxBox = QHBoxLayout() self.fileLabel = QLabel("File: ") button = QPushButton("...") button.clicked.connect(self.fileChoosing) auxBox.addWidget(self.fileLabel) auxBox.addWidget(button) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) hBox = QHBoxLayout() hBox.addWidget(QLabel("Sample Rate (Hz): ")) self.sampleRate = QLineEdit() self.sampleRate.setText("60") hBox.addWidget(self.sampleRate) auxW = QWidget() auxW.setLayout(hBox) mainLayout.addWidget(auxW) auxBox = QHBoxLayout() commentaryLabel = QLabel("Commentary: ") self.commentaryBox = QTextEdit() auxBox.addWidget(commentaryLabel) auxBox.addWidget(self.commentaryBox) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) buttonOk = QPushButton("Add Signal") buttonOk.clicked.connect(self.addSignalClicked) mainLayout.addWidget(buttonOk) self.dialog.setLayout(mainLayout) self.dialog.show()
class AddAreaDlg(QDialog): def __init__(self, parent=None): super(AddAreaDlg, self).__init__(parent) self.setWindowTitle("New Relief Device Area") name_label = QLabel("&Name:") self.name_lineedit = QLineEdit() self.name_lineedit.setMaxLength(200) name_label.setBuddy(self.name_lineedit) location_label = QLabel("&Location:") self.location_combobox = QComboBox() self.location_combobox.setEditable(True) location_label.setBuddy(self.location_combobox) self.browse_button = QPushButton("&Browse...") button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) layout = QGridLayout() layout.addWidget(name_label, 0, 0) layout.addWidget(self.name_lineedit, 0, 1) layout.addWidget(location_label, 1, 0) layout.addWidget(self.location_combobox, 1, 1) layout.addWidget(self.browse_button, 1, 2) #layout.addWidget(QFrame.HLine, 2, 0) layout.addWidget(button_box, 2, 1) self.setLayout(layout) self.browse_button.clicked.connect(self.browseFiles) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) def browseFiles(self): self.dirname = QFileDialog.getExistingDirectory(self, "Select file location", options=QFileDialog.ShowDirsOnly) self.location_combobox.insertItem(0, self.dirname) self.location_combobox.setCurrentIndex(0) def accept(self): if len(self.name_lineedit.text().strip()) == 0: QMessageBox.warning(self, "Error: Relief Device Area Name Blank", "The relief device area must be given a name.", QMessageBox.Ok) self.name_lineedit.setFocus() return if len(self.location_combobox.currentText().strip()) == 0: QMessageBox.warning(self, "Error: Location Blank", "You must save the relief device area file to a valid directory.", QMessageBox.Ok) self.location_combobox.setFocus() return if not os.path.exists(self.location_combobox.currentText().replace("\\", "/")): QMessageBox.warning(self, "Error: Directory Does Not Exist", "The specified directory does not exist.", QMessageBox.Ok) self.location_combobox.setFocus() return if os.path.isfile(self.location_combobox.currentText().replace("\\", "/") + "/" + self.name_lineedit.text() + ".rda"): if QMessageBox.question(self, "File Already Exists", "The file {0} already exists at {1}. Are you sure you want to proceed and overwrite this file?".format(self.name_lineedit.text() + ".rda", self.location_combobox.currentText().replace("\\", "/")), QMessageBox.Yes|QMessageBox.No) == QMessageBox.No: self.name_lineedit.setFocus() return QDialog.accept(self) def returnVals(self): return self.name_lineedit.text(), self.location_combobox.currentText().replace("\\", "/") + "/"
def __init__(self, text, validator, minValue, maxValue ): QWidget.__init__( self ) layout = QHBoxLayout( self ) checkBox = QCheckBox() checkBox.setFixedWidth( 115 ) checkBox.setText( text ) layout.addWidget( checkBox ) hLayoutX = QHBoxLayout() lineEditXMin = QLineEdit() lineEditXMax = QLineEdit() hLayoutX.addWidget( lineEditXMin ) hLayoutX.addWidget( lineEditXMax ) lineEditXMin.setValidator( validator ) lineEditXMax.setValidator( validator ) lineEditXMin.setText( str( minValue ) ) lineEditXMax.setText( str( maxValue ) ) layout.addLayout( hLayoutX ) self.checkBox = checkBox self.lineEditX_min = lineEditXMin self.lineEditX_max = lineEditXMax self.lineEdits = [ lineEditXMin, lineEditXMax ] QtCore.QObject.connect( checkBox, QtCore.SIGNAL( "clicked()" ), self.updateEnabled ) self.updateEnabled()
def __init__(self, *args, **kwargs ): QDialog.__init__( self, *args, **kwargs ) self.installEventFilter( self ) self.setWindowTitle( Window.title ) mainLayout = QVBoxLayout( self ) wLabelDescription = QLabel( "Select Object or Group" ) validator = QIntValidator() hLayout = QHBoxLayout() wLabel = QLabel( "Num Controller : " ) wLineEdit= QLineEdit();wLineEdit.setValidator(validator); wLineEdit.setText( '5' ) hLayout.addWidget( wLabel ) hLayout.addWidget( wLineEdit ) button = QPushButton( "Create" ) mainLayout.addWidget( wLabelDescription ) mainLayout.addLayout( hLayout ) mainLayout.addWidget( button ) self.resize(Window.defaultWidth,Window.defaultHeight) self.wlineEdit = wLineEdit QtCore.QObject.connect( button, QtCore.SIGNAL( "clicked()" ), self.cmd_create )
def __init__(self, *args, **kwargs ): QWidget.__init__( self, *args ) self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_SelectionGrow.txt" sgCmds.makeFile( self.infoPath ) validator = QIntValidator() layout = QHBoxLayout( self ); layout.setContentsMargins(0,0,0,0) groupBox = QGroupBox() layout.addWidget( groupBox ) hLayout = QHBoxLayout() labelTitle = QLabel( "Grow Selection : " ) buttonGrow = QPushButton( "Grow" ); buttonGrow.setFixedWidth( 50 ) buttonShrink = QPushButton( "Shrink" ); buttonShrink.setFixedWidth( 50 ) lineEdit = QLineEdit(); lineEdit.setValidator( validator );lineEdit.setText( '0' ) hLayout.addWidget( labelTitle ) hLayout.addWidget( buttonGrow ) hLayout.addWidget( buttonShrink ) hLayout.addWidget( lineEdit ) groupBox.setLayout( hLayout ) self.lineEdit = lineEdit QtCore.QObject.connect( buttonGrow, QtCore.SIGNAL("clicked()"), self.growNum ) QtCore.QObject.connect( buttonShrink, QtCore.SIGNAL("clicked()"), self.shrinkNum ) self.vtxLineEditList = [] self.loadInfo()