def __init__(self):
super(MemNavWidget, self).__init__()
self.expr_entry = QtWidgets.QLineEdit()
self.esize_entry = QtWidgets.QLineEdit()
hbox1 = QtWidgets.QHBoxLayout()
hbox1.setContentsMargins(2, 2, 2, 2)
hbox1.setSpacing(4)
hbox1.addWidget(self.expr_entry)
hbox1.addWidget(self.esize_entry)
self.setLayout(hbox1)
self.expr_entry.returnPressed.connect(self.emitUserChangedSignal)
self.esize_entry.returnPressed.connect(self.emitUserChangedSignal)
python类QHBoxLayout()的实例源码
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(188, 48)
Dialog.setWindowTitle("")
self.horizontalLayout = QtWidgets.QHBoxLayout(Dialog)
self.horizontalLayout.setObjectName("horizontalLayout")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setCenterButtons(True)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.horizontalLayout.addLayout(self.verticalLayout)
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def __init__(self):
QWidget.__init__(self)
self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
self.setFixedSize(400, 70)
main_vbox = QVBoxLayout()
hbox= QHBoxLayout()
hbox.setContentsMargins(0, 0, 0, 0)
self.progress = gpvdm_progress()
self.spinner=spinner()
hbox.addWidget(self.progress, 0)
hbox.addWidget(self.spinner, 0)
w=QWidget()
w.setLayout(hbox)
main_vbox.addWidget(w,0)
self.label=QLabel()
self.label.setText(_("Running")+"...")
main_vbox.addWidget(self.label)
self.setLayout(main_vbox)
def __init__(self,file_box=False):
QWidget.__init__(self)
self.hbox=QHBoxLayout()
self.edit=QLineEdit()
self.button=QPushButton()
self.button.setFixedSize(25, 25)
self.button.setText("...")
self.hbox.addWidget(self.edit)
self.hbox.addWidget(self.button)
self.hbox.setContentsMargins(0, 0, 0, 0)
self.edit.setStyleSheet("QLineEdit { border: none }");
if file_box==True:
self.button.clicked.connect(self.callback_button_click)
self.setLayout(self.hbox)
def init_ui(self):
self._mainWidget = QWidget()
self._drawWidget = QWidget()
self._btns_widget = QWidget()
self._layout_buttons = QVBoxLayout()
self._layout_draw = QHBoxLayout()
self._drawWidget.setLayout(self._layout_draw)
self._vLayout = QVBoxLayout()
self._vLayout.setSpacing(2)
self.setCentralWidget(self._mainWidget)
self._mainWidget.setLayout(self._vLayout)
self.configure_buttons()
self._tesseractWidget = TesseractWidget()
self._svs = ScreenViewScene()
self._layout_draw.addWidget(self._btns_widget)
self._layout_draw.addWidget(self._svs)
self._vLayout.addWidget(self._drawWidget)
self._vLayout.addWidget(self._tesseractWidget)
self._svs.signal_send_image.connect(self.setImage)
self._tesseractWidget.signal_send_text.connect(self._svs.switch_to_text)
def main():
application = QtWidgets.QApplication([])
window = QtWidgets.QWidget()
layout_numbers = QtWidgets.QVBoxLayout(window)
result = QtWidgets.QTextEdit()
layout_numbers.addWidget(result)
# Numbers from 0 to 9, Numeros de 0 a 9
for number in range(10):
button = QtWidgets.QPushButton(str(number))
button.clicked.connect(lambda _, number=number:
result.insertPlainText(str(number)))
layout_numbers.addWidget(button)
# Math Operators, Operadores Matematicos
operators = QtWidgets.QWidget()
layout_operators = QtWidgets.QHBoxLayout(operators)
for operator in ("*", "/", "+", "-", "//"):
button = QtWidgets.QPushButton(str(operator))
button.clicked.connect(lambda _, operator=operator:
result.insertPlainText(str(operator)))
layout_operators.addWidget(button)
layout_numbers.addWidget(operators)
# Solve the user input, Resolver lo ingresado por el usuario
solve = QtWidgets.QPushButton("EVAL", window)
solve.clicked.connect(lambda _, maths=result:
result.setPlainText(str(eval(maths.toPlainText()))))
layout_numbers.addWidget(solve)
window.show()
exit(application.exec_())
def __init__(self, parent=None):
super().__init__()
self.parent = parent
self.setVisible(False)
self.setStyleSheet("QDialog {background-color: rgba(22, 22, 22, 150); border-color: rgba(22, 22, 22, 150);" \
"border-width: 1px; border-style outset; border-radius: 10px; color:white; font-weight:bold;}")
layout = QHBoxLayout()
self.setLayout(layout)
label = QLabel()
label.setStyleSheet("QLabel {color:white;}")
label.setText("Kodlama:")
layout.addWidget(label)
self.combobox = QComboBox()
self.combobox.addItems(["ISO 8859-9", "UTF-8"])
self.combobox.setStyleSheet("QComboBox {background-color: rgba(22, 22, 22, 150); border-color: rgba(22, 22, 22, 150);" \
" color:white; font-weight:bold;}")
self.combobox.setCurrentText(settings().value("Subtitle/codec"))
layout.addWidget(self.combobox)
self.combobox.currentTextChanged.connect(self.textCodecChange)
def setupUi(self, window):
window.setObjectName("window")
window.resize(380, 477)
window.setModal(True)
self.verticalLayout = QtWidgets.QVBoxLayout(window)
self.verticalLayout.setObjectName("verticalLayout")
self.txt_list = QtWidgets.QTextEdit(window)
self.txt_list.setMinimumSize(QtCore.QSize(183, 0))
self.txt_list.setAcceptRichText(False)
self.txt_list.setObjectName("txt_list")
self.verticalLayout.addWidget(self.txt_list)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setContentsMargins(-1, -1, -1, 10)
self.horizontalLayout.setObjectName("horizontalLayout")
self.btn_cancel = QtWidgets.QPushButton(window)
self.btn_cancel.setAutoDefault(False)
self.btn_cancel.setObjectName("btn_cancel")
self.horizontalLayout.addWidget(self.btn_cancel)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.btn_ok = QtWidgets.QPushButton(window)
self.btn_ok.setAutoDefault(True)
self.btn_ok.setObjectName("btn_ok")
self.horizontalLayout.addWidget(self.btn_ok)
self.verticalLayout.addLayout(self.horizontalLayout)
self.retranslateUi(window)
QtCore.QMetaObject.connectSlotsByName(window)
def __init__(self, parent):
super().__init__()
self.parent = parent
self.setFixedSize(300, 150)
self.setLayout(QVBoxLayout())
hlayout = QHBoxLayout()
self.layout().addLayout(hlayout)
label = QLabel()
label.setText(self.tr("Mount Point:"))
hlayout.addWidget(label)
self.combobox = QComboBox()
hlayout.addWidget(self.combobox)
self.dialbutton = QDialogButtonBox()
self.dialbutton.setStandardButtons(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
self.layout().addWidget(self.dialbutton)
self.dialbutton.button(QDialogButtonBox.Ok).setText(self.tr("Ok"))
self.dialbutton.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.dialbutton.accepted.connect(self.editAccept)
self.dialbutton.rejected.connect(self.close)
def setupUi(self, Window):
Window.setObjectName("Window")
Window.resize(640, 480)
self.verticalLayout = QtWidgets.QVBoxLayout(Window)
self.verticalLayout.setObjectName("verticalLayout")
self.webView = QtWebKitWidgets.QWebView(Window)
self.webView.setUrl(QtCore.QUrl("http://webkit.org/"))
self.webView.setObjectName("webView")
self.verticalLayout.addWidget(self.webView)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.formLayout = QtWidgets.QFormLayout()
self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.ExpandingFieldsGrow)
self.formLayout.setObjectName("formLayout")
self.elementLabel = QtWidgets.QLabel(Window)
self.elementLabel.setObjectName("elementLabel")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.elementLabel)
self.elementLineEdit = QtWidgets.QLineEdit(Window)
self.elementLineEdit.setObjectName("elementLineEdit")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.elementLineEdit)
self.horizontalLayout.addLayout(self.formLayout)
self.highlightButton = QtWidgets.QPushButton(Window)
self.highlightButton.setObjectName("highlightButton")
self.horizontalLayout.addWidget(self.highlightButton)
self.verticalLayout.addLayout(self.horizontalLayout)
self.elementLabel.setBuddy(self.elementLineEdit)
self.retranslateUi(Window)
QtCore.QMetaObject.connectSlotsByName(Window)
def __init__(self, *args):
QtWidgets.QFrame.__init__(self, *args)
self.setFrameStyle(QtWidgets.QFrame.StyledPanel | QtWidgets.QFrame.Sunken)
self.edit = self.PlainTextEdit()
self.number_bar = self.NumberBar(self.edit)
hbox = QtWidgets.QHBoxLayout(self)
hbox.setSpacing(0)
hbox.setContentsMargins(0,0,0,0) # setMargin
hbox.addWidget(self.number_bar)
hbox.addWidget(self.edit)
self.edit.blockCountChanged.connect(self.number_bar.adjustWidth)
self.edit.updateRequest.connect(self.number_bar.updateContents)
GearBox_template_1010.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 29
收藏 0
点赞 0
评论 0
def quickLayout(self, type, ui_name=""):
the_layout = ''
if type in ("form", "QFormLayout"):
the_layout = QtWidgets.QFormLayout()
the_layout.setLabelAlignment(QtCore.Qt.AlignLeft)
the_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
elif type in ("grid", "QGridLayout"):
the_layout = QtWidgets.QGridLayout()
elif type in ("hbox", "QHBoxLayout"):
the_layout = QtWidgets.QHBoxLayout()
the_layout.setAlignment(QtCore.Qt.AlignTop)
else:
the_layout = QtWidgets.QVBoxLayout()
the_layout.setAlignment(QtCore.Qt.AlignTop)
if ui_name != "":
self.uiList[ui_name] = the_layout
return the_layout
def __init__(self, playbin, parent):
super().__init__(parent)
self._playbin = playbin
self._state = self.STATE_IDLE
self._started = None
self._updater = None
self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self._elapsed = QtWidgets.QLabel('00:00:00')
self._remaining = QtWidgets.QLabel('00:00:00')
self._slider.setMinimum(0)
layout = QtWidgets.QHBoxLayout()
layout.setContentsMargins(2, 2, 2, 2)
layout.addWidget(self._elapsed)
layout.addWidget(self._slider, stretch=1)
layout.addWidget(self._remaining)
self.setLayout(layout)
self._slider.sliderPressed.connect(self._startDragging)
self._slider.sliderMoved.connect(self._drag)
self._slider.sliderReleased.connect(self._stopDragging)
self._updater = asyncio.get_event_loop().create_task(self._poll())
def __init__(self, api, main_window):
super().__init__(main_window)
model = StylesModel(api)
selection_model = QtCore.QItemSelectionModel(model)
self._style_list = StyleList(api, model, selection_model, self)
self._style_editor = StyleEditor(model, selection_model, self)
if api.video.path:
self._preview_box = StylePreview(api, selection_model, self)
else:
self._preview_box = None
self._style_editor.setEnabled(False)
layout = QtWidgets.QHBoxLayout(self)
layout.addWidget(self._style_list)
layout.addWidget(self._style_editor)
if self._preview_box:
layout.addWidget(self._preview_box)
def __init__(self, api, parent=None):
super().__init__(parent)
self.text_edit = TextEdit(
api, 'editor', self,
tabChangesFocus=True)
self.note_edit = TextEdit(
api, 'notes', self,
tabChangesFocus=True,
placeholderText='Notes')
self.text_edit.highlighter = \
SpellCheckHighlighter(api, self.text_edit.document())
layout = QtWidgets.QHBoxLayout(self)
layout.setSpacing(4)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(self.text_edit)
layout.addWidget(self.note_edit)
def initUI(self):
self.tf = 'PlotTextFile.txt'
self.statusbar = 'Ready'
self.createTopGroupBox()
self.createMidTopGroupBox()
self.createMidBottomGroupBox()
self.createBottomLeftGroupBox()
self.createBottomRightGroupBox()
topLayout = QVBoxLayout()
topLayout.addWidget(self.topGroupBox)
topLayout.addWidget(self.midTopGroupBox)
topLayout.addWidget(self.midBottomGroupBox)
bottomLayout = QHBoxLayout()
bottomLayout.addWidget(self.bottomLeftGroupBox)
bottomLayout.addWidget(self.bottomRightGroupBox)
mainLayout = QVBoxLayout()
mainLayout.addLayout(topLayout)
mainLayout.addLayout(bottomLayout)
mainLayout.addStretch(1)
self.setLayout(mainLayout)
self.show()
def createTopGroupBox(self):
self.topGroupBox = QGroupBox('Integration Time')
self.it2_4ms = QRadioButton()
self.it2_4ms.setText('2.4ms')
self.it2_4ms.toggled.connect(lambda: self.itstate(self.it2_4ms))
self.it24ms = QRadioButton()
self.it24ms.setText('24ms')
self.it24ms.toggled.connect(lambda: self.itstate(self.it24ms))
self.it50ms = QRadioButton()
self.it50ms.setText('50ms')
self.it50ms.toggled.connect(lambda: self.itstate(self.it50ms))
self.it101ms = QRadioButton()
self.it101ms.setText('101ms')
self.it101ms.toggled.connect(lambda: self.itstate(self.it101ms))
self.it154ms = QRadioButton()
self.it154ms.setText('154ms')
self.it154ms.toggled.connect(lambda: self.itstate(self.it154ms))
self.it700ms = QRadioButton()
self.it700ms.setText('700ms')
self.it700ms.toggled.connect(lambda: self.itstate(self.it700ms))
self.it2_4ms.setChecked(True)
layout = QHBoxLayout()
layout.addWidget(self.it2_4ms)
layout.addWidget(self.it24ms)
layout.addWidget(self.it50ms)
layout.addWidget(self.it101ms)
layout.addWidget(self.it154ms)
layout.addWidget(self.it700ms)
layout.addStretch(1)
self.topGroupBox.setLayout(layout)
def createMidGroupBox(self):
self.midGroupBox = QGroupBox('Gain')
self.gain1 = QRadioButton()
self.gain1.setText('1X')
self.gain1.toggled.connect(lambda: self.gnstate(self.gain1))
self.gain4 = QRadioButton()
self.gain4.setText('4X')
self.gain4.toggled.connect(lambda: self.gnstate(self.gain4))
self.gain16 = QRadioButton()
self.gain16.setText('16X')
self.gain16.toggled.connect(lambda: self.gnstate(self.gain16))
self.gain60 = QRadioButton()
self.gain60.setText('60X')
self.gain60.toggled.connect(lambda: self.gnstate(self.gain60))
self.gain1.setChecked(True)
layout = QHBoxLayout()
layout.addWidget(self.gain1)
layout.addWidget(self.gain4)
layout.addWidget(self.gain16)
layout.addWidget(self.gain60)
layout.addStretch(1)
self.midGroupBox.setLayout(layout)
def createBottomRightGroupBox(self):
self.bottomRightGroupBox = QGroupBox('Sensor Data')
self.intensityLbl = QLabel('Not Taken')
layout = QHBoxLayout()
layout.addWidget(self.intensityLbl)
layout.addStretch(1)
self.bottomRightGroupBox.setLayout(layout)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(224, 117)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
Form.setSizePolicy(sizePolicy)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setSpacing(1)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.translateLabel = QtWidgets.QLabel(Form)
self.translateLabel.setObjectName("translateLabel")
self.verticalLayout.addWidget(self.translateLabel)
self.rotateLabel = QtWidgets.QLabel(Form)
self.rotateLabel.setObjectName("rotateLabel")
self.verticalLayout.addWidget(self.rotateLabel)
self.scaleLabel = QtWidgets.QLabel(Form)
self.scaleLabel.setObjectName("scaleLabel")
self.verticalLayout.addWidget(self.scaleLabel)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.mirrorImageBtn = QtWidgets.QPushButton(Form)
self.mirrorImageBtn.setToolTip("")
self.mirrorImageBtn.setObjectName("mirrorImageBtn")
self.horizontalLayout.addWidget(self.mirrorImageBtn)
self.reflectImageBtn = QtWidgets.QPushButton(Form)
self.reflectImageBtn.setObjectName("reflectImageBtn")
self.horizontalLayout.addWidget(self.reflectImageBtn)
self.verticalLayout.addLayout(self.horizontalLayout)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)