本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setMinimumWidth方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setMinimumWidth方法的具體用法?Python QLineEdit.setMinimumWidth怎麽用?Python QLineEdit.setMinimumWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setMinimumWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: AnsBox
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class AnsBox(QDialog):
"""Solicit an input answer from the User
"""
def __init__(self, lbl, format=str, parent=None):
"""
Parameters
----------
lbl : str
format : str
Format for value
"""
super(AnsBox, self).__init__(parent)
self.format=format
#
label = QLabel(lbl)
self.box = QLineEdit()
self.box.setMinimumWidth(90)
# Connect
self.box.textChanged[str](self.setv)
# Layout
vbox = QVBoxLayout()
vbox.addWidget(label)
vbox.addWidget(self.box)
self.setLayout(vbox)
def setv(self):
try:
self.value = self.format(ustr(self.box.text()))
except ValueError:
print('Bad input value! Try again with right type')
else:
self.done(0)
示例2: Avance
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class Avance(QWidget):
def __init__(self, parent):
QWidget.__init__(self, parent)
self.parent = parent
prm = parent.param
### Liste des options avancées de la calculatrice ###
self.pave = QVBoxLayout()
box = QGroupBox("Post-traitement")
box_layout = QVBoxLayout()
box.setLayout(box_layout)
box_layout.addWidget(QLabel("Traitement automatiquement du résultat :"))
self.traitement = QLineEdit()
traitement = self.parent.param("appliquer_au_resultat") or '_'
self.traitement.setText(traitement)
self.traitement.setMinimumWidth(100)
self.traitement.setToolTip("Fonction ou opérations à appliquer automatiquement au résultat (représenté par _). Ex: 'factoriser(_)'.")
self.traitement.editingFinished.connect(self.EvtAppliquerResultat)
box_layout.addWidget(self.traitement)
self.pave.addWidget(box)
self.setLayout(self.pave)
self.pave.addStretch()
def EvtAppliquerResultat(self, event=None):
val = self.traitement.text().strip()
if not val:
self.traitement.setText('_')
val = None
elif val == '_':
val = None
self.parent.param("appliquer_au_resultat", val)
示例3: LoggingToolbar
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class LoggingToolbar(QToolBar):
def __init__(self, network_handler):
super().__init__("Logging Control")
self._nh = network_handler
file_tag = QLabel()
file_tag.setText("Log file tag:")
self._tag_edit = QLineEdit()
self._tag_edit.setMinimumWidth(100)
self._tag_edit.setMaximumWidth(140)
self._tag_edit.setAlignment(QtCore.Qt.AlignRight)
self.addWidget(file_tag)
self.addWidget(self._tag_edit)
self.addAction("Start logging", self._start_logging)
self.addAction("Stop logging", self._stop_logging)
@QtCore.pyqtSlot()
def _start_logging(self):
file_tag = self._tag_edit.text()
self._nh.send_command("START_LOGGING", file_tag)
@QtCore.pyqtSlot()
def _stop_logging(self):
self._nh.send_command("STOP_LOGGING")
示例4: add_line
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
def add_line(self, label, value, row_number, layout):
layout.addWidget(QLabel(label), row_number, 0)
log_dir_widget = QLineEdit(value)
log_dir_widget.setReadOnly(True)
width = QFontMetrics(QFont()).width(value) * 1.05
log_dir_widget.setMinimumWidth(width)
layout.addWidget(log_dir_widget, row_number+1, 0)
示例5: NetworkToolbar
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class NetworkToolbar(QToolBar):
reset_hexacopter_parameters = pyqtSignal()
def __init__(self, network_handler):
super().__init__("Network")
self._nh = network_handler
self._connected = False
ping_timer = QtCore.QTimer(self)
ping_timer.timeout.connect(self._send_ping)
ping_timer.start(500)
host_text = QLabel("Connect to hexapi:")
self._host_edit = QLineEdit()
self._host_edit.setMinimumWidth(100)
self._host_edit.setMaximumWidth(140)
self._host_edit.setAlignment(QtCore.Qt.AlignRight)
self._host_edit.setPlaceholderText("192.169.1.2")
self.addWidget(host_text)
self.addWidget(self._host_edit)
self.addAction("Set host", self._connect)
self.addAction("Land", self._land)
self.addAction("Kill!", self._kill)
@QtCore.pyqtSlot()
def _connect(self):
logging.info("MA: Setting host")
self._connected = True
host_and_port = self._host_edit.text().split(":")
if len(host_and_port) == 2:
port = int(host_and_port[1])
else:
port = 4092
self._nh.set_host(host_and_port[0], port)
@QtCore.pyqtSlot()
def _send_ping(self):
if self._connected:
self._nh.send_command("PING")
@QtCore.pyqtSlot()
def _land(self):
self._nh.send_command("LAND")
self.reset_hexacopter_parameters.emit()
@QtCore.pyqtSlot()
def _kill(self):
self._nh.send_command("KILL")
self.reset_hexacopter_parameters.emit()
示例6: _create_text_edit
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
def _create_text_edit(placeholder_text):
edit = QLineEdit()
edit.setMinimumWidth(80)
edit.setMaximumWidth(100)
edit.setAlignment(QtCore.Qt.AlignRight)
edit.setPlaceholderText(placeholder_text)
return edit
示例7: ExperienceFrame
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class ExperienceFrame(MyMiniFrame):
def __init__(self, parent):
MyMiniFrame.__init__(self, parent, "Simulation d'une expérience")
self.parent = parent
sizer = QVBoxLayout()
exp = QHBoxLayout()
exp.addWidget(QLabel("Experience:"))
self.experience = QLineEdit()
self.experience.setMinimumWidth(120)
self.experience.returnPressed.connect(self.actualiser)
exp.addWidget(self.experience)
sizer.addLayout(exp)
nbr = QHBoxLayout()
nbr.addWidget(QLabel("Nombre d'expériences:"))
sc = self.sc = QSpinBox()
sc.setRange(1, 100000)
sc.setValue(5)
sc.valueChanged.connect(self.actualiser)
nbr.addWidget(sc)
sizer.addLayout(nbr)
val = QHBoxLayout()
val.addWidget(QLabel("Valeurs possibles:"))
self.valeurs = QLineEdit()
self.valeurs.setMinimumWidth(120)
self.valeurs.returnPressed.connect(self.actualiser)
val.addWidget(self.valeurs)
sizer.addLayout(val)
self.cb = QCheckBox("Lancer une animation:")
sizer.addWidget(self.cb)
self.cb.stateChanged.connect(self.actualiser)
boutons = QHBoxLayout()
fermer = QPushButton("Fermer")
boutons.addWidget(fermer)
lancer = QPushButton("Lancer l'experience")
boutons.addWidget(lancer)
fermer.clicked.connect(self.close)
lancer.clicked.connect(self.actualiser)
sizer.addLayout(boutons)
self.setLayout(sizer)
def actualiser(self, event = None):
n = self.sc.value()
exp = self.experience.text()
vals = msplit(self.valeurs.text(), (" ", ",", ";"))
print(alea)
if exp:
self.parent.experience(exp, n, [eval(val, DIC) for val in vals if val])
示例8: box
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
def box(text, tool_tip):
w = QLineEdit(self)
w.setReadOnly(True)
w.setFont(get_monospace_font())
w.setText(str(text))
w.setToolTip(tool_tip)
fm = QFontMetrics(w.font())
magic_number = 10
text_size = fm.size(0, w.text())
w.setMinimumWidth(text_size.width() + magic_number)
return w
示例9: ReplaceWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class ReplaceWidget(QWidget):
"""Replace widget to find and replace occurrences of words in editor."""
def __init__(self, parent=None):
super(ReplaceWidget, self).__init__(parent)
hReplace = QHBoxLayout(self)
hReplace.setContentsMargins(0, 0, 0, 0)
self._lineReplace = QLineEdit()
self._lineReplace.setMinimumWidth(250)
self._btnCloseReplace = QPushButton(
self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
self._btnCloseReplace.setIconSize(QSize(16, 16))
self._btnReplace = QPushButton(self.tr("Replace"))
self._btnReplaceAll = QPushButton(self.tr("Replace All"))
self._btnReplaceSelection = QPushButton(
self.tr("Replace Selection"))
hReplace.addWidget(self._btnCloseReplace)
hReplace.addWidget(self._lineReplace)
hReplace.addWidget(self._btnReplace)
hReplace.addWidget(self._btnReplaceAll)
hReplace.addWidget(self._btnReplaceSelection)
self._btnReplace.clicked['bool'].connect(self.replace)
self._btnReplaceAll.clicked['bool'].connect(self.replace_all)
self._btnReplaceSelection.clicked['bool'].connect(self.replace_selected)
def replace(self):
"""Replace one occurrence of the word."""
status_search = IDE.get_service("status_search")
main_container = IDE.get_service("main_container")
editor = None
if main_container:
editor = main_container.get_current_editor()
if editor:
editor.replace_match(status_search.search_text,
self._lineReplace.text())
status_search.find()
def replace_selected(self):
"""Replace the occurrences of the word in the selected blocks."""
self.replace_all(True)
def replace_all(self, selected=False):
"""Replace all the occurrences of the word."""
status_search = IDE.get_service("status_search")
main_container = IDE.get_service("main_container")
editor = None
if main_container:
editor = main_container.get_current_editor()
if editor:
editor.replace_match(status_search.search_text,
self._lineReplace.text(), True,
selected)
示例10: add_path_row
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
def add_path_row(self, path):
path_line = QLineEdit(path)
path_line.setReadOnly(True)
width = QFontMetrics(QFont()).width(path) * 1.05
path_line.setMinimumWidth(width)
# path line
self._paths_layout.addWidget(path_line, self._paths_row, 0)
# scan button
scan_button = QScanPushButton(path, path_line, self._app_data_folder, self._system_tray)
scan_button.clicked.connect(scan_button.scan)
self._paths_layout.addWidget(scan_button, self._paths_row, 1)
self._paths_row += 1
示例11: MyPopup
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class MyPopup(QWidget):
def __init__(self):
global text_
global fig, chartFig
QWidget.__init__(self)
self.setWindowTitle('Add new Speaker')
self.main_widget = QtWidgets.QWidget(self)
self.speakerID = QLineEdit(self)
self.Ok = QPushButton("Ok", self)
#self.show()
# Draw new Speaker window
#----------------------
def paintEvent(self, e):
self.speakerID.setPlaceholderText('Speaker...')
self.speakerID.setMinimumWidth(100)
self.speakerID.setEnabled(True)
self.speakerID.move(90, 15)
self.Ok.move(115, 60)
self.speakerID.textChanged.connect(self.speakerLabel)
self.Ok.clicked.connect(self.closeSpeaker)
self.Ok.show()
self.speakerID.show()
def speakerLabel(self,text):
global text_
text_ = 'Speech::' + text
# Close and save new Speaker ID
#----------------------
def closeSpeaker(self):
global text_
global fig, chartFig
if text_ != 'Add New Speaker':
text_ = 'Speech::' + self.speakerID.text()
self.Ok.clicked.disconnect()
self.close()
fig.saveAnnotation()
fig.draw()
chartFig.axes.clear()
chartFig.drawChart()
chartFig.draw()
示例12: _add_note
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
def _add_note(self, index):
current_bookmark = self._manager.get_bookmark_for_index(index)
dialog = QDialog(self)
dialog.setWindowTitle(translations.TR_ADD_BOOKMARK_NOTE_TITLE)
layout = QFormLayout(dialog)
note_edit = QLineEdit()
note_edit.setMinimumWidth(300)
note_edit.setText(current_bookmark.note)
button_box = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
layout.addRow(translations.TR_ADD_BOOKMARK_NOTE_LABEL, note_edit)
layout.addWidget(button_box)
button_box.accepted.connect(dialog.accept)
button_box.rejected.connect(dialog.reject)
if dialog.exec_() == QDialog.Accepted:
self._manager.update_note(current_bookmark, note_edit.text())
示例13: ReplaceWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class ReplaceWidget(QWidget):
def __init__(self, parent):
super(ReplaceWidget, self).__init__(parent)
hReplace = QHBoxLayout(self)
hReplace.setContentsMargins(0, 0, 0, 0)
self._lineReplace = QLineEdit()
self._lineReplace.setMinimumWidth(250)
self._btnCloseReplace = QPushButton(
self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
self._btnReplace = QPushButton(_translate("ReplaceWidget", "Replace"))
self._btnReplaceAll = QPushButton(_translate("ReplaceWidget", "Replace All"))
self._btnReplaceSelection = QPushButton(
_translate("ReplaceWidget", "Replace Selection"))
hReplace.addWidget(self._btnCloseReplace)
hReplace.addWidget(self._lineReplace)
hReplace.addWidget(self._btnReplace)
hReplace.addWidget(self._btnReplaceAll)
hReplace.addWidget(self._btnReplaceSelection)
示例14: EditBox
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class EditBox(QWidget):
""" Generate a simple box for editing
"""
def __init__(self, initv, lbl, format, parent=None):
"""
Parameters
----------
initv : str
Initial value
lbl : str
format : str
Format for text
"""
super(EditBox, self).__init__(parent)
self.value = initv
#
label = QLabel(lbl)
self.box = QLineEdit()
# Format
self.box.frmt = format
self.box.setText(self.box.frmt.format(self.value))
self.box.setMinimumWidth(90)
# Connect
self.box.textChanged[str].connect(self.setv)
#self.connect(self.box,
# QtCore.SIGNAL('editingFinished ()'), self.setv)
# Layout
vbox = QVBoxLayout()
vbox.addWidget(label)
vbox.addWidget(self.box)
self.setLayout(vbox)
def setv(self, text):
self.box.setText(text)
self.box.adjustSize()
self.value = str(self.box.text())
def set_text(self,value):
self.value = value
self.box.setText(self.box.frmt.format(self.value))
示例15: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumWidth [as 別名]
class LineUI:
"""
Set up the folder widgets
"""
def __init__(self, name, value, method=None, button_text="Select..."):
self.label = QLabel(name + ":")
self.line = QLineEdit(value)
self.line.setMinimumWidth(600) # swag
self.select_button = QDialogButtonBox()
self.line.setReadOnly(True) # guide user via dialog boxes - don't allow them to just type anything in
if method:
self.select_button.addButton(button_text, QDialogButtonBox.AcceptRole)
self.select_button.accepted.connect(method)
def layout(self, grid, column):
grid.addWidget(self.label, column, 0)
grid.addWidget(self.line, column, 1)
grid.addWidget(self.select_button, column, 2)
def get(self):
return self.line.text()