本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setReadOnly方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setReadOnly方法的具體用法?Python QLineEdit.setReadOnly怎麽用?Python QLineEdit.setReadOnly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setReadOnly方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: manage_properties
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
def manage_properties(self):
self.update()
self.setWindowTitle('Properties:')
layout = QGridLayout()
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
button_box.button(QDialogButtonBox.Ok).setDefault(True)
for idx, prop in enumerate(sorted(self.flume_object.properties.keys())):
label = QLabel(prop + ':')
editor = QLineEdit(self.flume_object.properties[prop]["value"])
if prop == "type":
editor.setReadOnly(True)
if self.flume_object.properties[prop]["required"]:
label.setText(prop + ":*")
pass # label.setFont(QFont) TODO
editor.setToolTip(self.flume_object.properties[prop]["description"])
editor.setToolTipDuration(-1)
self.new_properties[prop] = editor
label.setBuddy(self.new_properties[prop])
layout.addWidget(label, idx, 0)
layout.addWidget(self.new_properties[prop], idx, 1)
layout.addWidget(button_box)
self.setLayout(layout)
button_box.accepted.connect(self.accept_prop)
button_box.rejected.connect(self.reject)
示例2: FirstPage
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
class FirstPage(QWizardPage):
def __init__(self, parent=None):
super().__init__(parent)
self.setTitle("Nueva Base de Datos de Pireal")
self.setSubTitle("A continuación elija el nombre y el destino de la DB")
# Widgets
box = QVBoxLayout(self)
hbox = QHBoxLayout()
hbox.addWidget(QLabel(self.tr("Database Name:")))
self._database_name_line = QLineEdit()
hbox.addWidget(self._database_name_line)
box.addLayout(hbox)
hbox = QHBoxLayout()
hbox.addWidget(QLabel(self.tr("Location:")))
self._database_location_line = QLineEdit()
# Left action to change db location
change_location_action = self._database_location_line.addAction(
self.style().standardIcon(QStyle.SP_DirIcon), 1)
self._database_location_line.setReadOnly(True)
hbox.addWidget(self._database_location_line)
box.addLayout(hbox)
hbox = QHBoxLayout()
hbox.addWidget(QLabel(self.tr("Filename:")))
self._database_filename_line = QLineEdit()
self._database_filename_line.setReadOnly(True)
hbox.addWidget(self._database_filename_line)
box.addLayout(hbox)
# Register fields
self.registerField("dbname*", self._database_name_line)
self.registerField("dblocation", self._database_location_line)
self.registerField("dbfilename", self._database_filename_line)
self.__location_folder = settings.PIREAL_DATABASES
self._database_filename_line.setText(self.__location_folder)
self._database_location_line.setText(self.__location_folder)
# Conexiones
self._database_name_line.textChanged.connect(self._update_filename)
change_location_action.triggered.connect(self.__select_location)
@pyqtSlot()
def __select_location(self):
location = QFileDialog.getExistingDirectory(self,
self.tr("Select Folder"))
if not location:
return
self._database_location_line.setText(location)
self.__location_folder = os.path.join(self.__location_folder, location)
self._database_filename_line.setText(os.path.join(
location, self._database_name_line.text()))
@pyqtSlot('QString')
def _update_filename(self, filename):
new_filename = os.path.join(self.__location_folder, filename)
self._database_filename_line.setText(new_filename + '.pdb')
示例3: setUpDialogHeader
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
def setUpDialogHeader(self):
headerLayout = QGridLayout()
self.destinationFolder = paths.writableLocation(paths.DownloadLocation)
torrentName = self.torrentInfo.name()
# Show the torrent name row
nameLabel = QLabel("Torrent name:", self)
headerLayout.addWidget(nameLabel, 0, 0)
nameEdit = QLineEdit(torrentName, self)
nameEdit.setReadOnly(True)
headerLayout.addWidget(nameEdit, 0, 1)
# Show the destination folder row
dirLabel = QLabel("Destination folder:", self)
headerLayout.addWidget(dirLabel, 1, 0)
self.textField = QLineEdit(self.destinationFolder, self)
self.textField.setReadOnly(True)
headerLayout.addWidget(self.textField, 1, 1)
button = QPushButton("Browse", self)
button.clicked.connect(self.selectFolder)
headerLayout.addWidget(button, 1, 2)
self.layout.addLayout(headerLayout)
示例4: init
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
def init(self):
vbox = QVBoxLayout()
self.setLayout(vbox)
text = QLineEdit('0.')
text.setReadOnly(True)
vbox.addWidget(text)
grid = QGridLayout()
vbox.addLayout(grid)
names = ['Exit', 'AC', 'DEL', '+/-',
'7', '8', '9', '/',
'4', '5', '6', '*',
'1', '2', '3', '-',
'0', '.', '=', '+']
positions = [(i, j) for i in range(5) for j in range(4)]
for position, name in zip(positions, names):
btn = QPushButton(name)
grid.addWidget(btn, *position)
self.move(300, 200)
self.setWindowTitle('Calculator')
self.show()
示例5: Form
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
class Form(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.server = wssd.WSSDController()
self.server.worker.browserCmd.connect(self.handle_cmd_event)
startButton = QPushButton('&Start')
stopButton = QPushButton('Sto&p')
startButton.clicked.connect(self.server.start)
stopButton.clicked.connect(self.server.stop)
self.id_edit = QLineEdit()
self.id_edit.setReadOnly(True)
layout = QHBoxLayout()
layout.addWidget(startButton)
layout.addWidget(stopButton)
layout.addWidget(self.id_edit)
self.setLayout(layout)
def handle_cmd_event(self, msg):
print('handle cmd event:', msg)
# TODO: catch exception
event = json.loads(msg)
# TODO: check msg type
self.id_edit.setText(event['id'])
示例6: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
def __init__(self, parent=None):
super(lineEditDemo, self).__init__(parent)
e1 = QLineEdit()
e1.setValidator( QIntValidator() )
e1.setMaxLength(4)
e1.setAlignment( Qt.AlignRight )
e1.setFont( QFont("Arial",20))
e2 = QLineEdit()
e2.setValidator( QDoubleValidator(0.99,99.99,2))
flo = QFormLayout()
flo.addRow("integer validator", e1)
flo.addRow("Double validator",e2)
e3 = QLineEdit()
e3.setInputMask('+99_9999_999999')
flo.addRow("Input Mask",e3)
e4 = QLineEdit()
e4.textChanged.connect( self.textchanged )
flo.addRow("Text changed",e4)
e5 = QLineEdit()
e5.setEchoMode( QLineEdit.Password )
flo.addRow("Password",e5)
e6 = QLineEdit("Hello PyQt5")
e6.setReadOnly(True)
flo.addRow("Read Only",e6 )
e5.editingFinished.connect( self.enterPress )
self.setLayout(flo)
self.setWindowTitle("QLineEdit例子")
示例7: add_line
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [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)
示例8: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
def __init__(self, seed=None, title=None, icon=True, msg=None, options=None,
is_seed=None, passphrase=None, parent=None, for_seed_words=True):
QVBoxLayout.__init__(self)
self.parent = parent
self.options = options
if title:
self.addWidget(WWLabel(title))
if seed: # "read only", we already have the text
if for_seed_words:
self.seed_e = ButtonsTextEdit()
else: # e.g. xpub
self.seed_e = ShowQRTextEdit()
self.seed_e.setReadOnly(True)
self.seed_e.setText(seed)
else: # we expect user to enter text
assert for_seed_words
self.seed_e = CompletionTextEdit()
self.seed_e.setTabChangesFocus(False) # so that tab auto-completes
self.is_seed = is_seed
self.saved_is_seed = self.is_seed
self.seed_e.textChanged.connect(self.on_edit)
self.initialize_completer()
self.seed_e.setMaximumHeight(75)
hbox = QHBoxLayout()
if icon:
logo = QLabel()
logo.setPixmap(QPixmap(icon_path("seed.png"))
.scaledToWidth(64, mode=Qt.SmoothTransformation))
logo.setMaximumWidth(60)
hbox.addWidget(logo)
hbox.addWidget(self.seed_e)
self.addLayout(hbox)
hbox = QHBoxLayout()
hbox.addStretch(1)
self.seed_type_label = QLabel('')
hbox.addWidget(self.seed_type_label)
# options
self.is_bip39 = False
self.is_ext = False
if options:
opt_button = EnterButton(_('Options'), self.seed_options)
hbox.addWidget(opt_button)
self.addLayout(hbox)
if passphrase:
hbox = QHBoxLayout()
passphrase_e = QLineEdit()
passphrase_e.setText(passphrase)
passphrase_e.setReadOnly(True)
hbox.addWidget(QLabel(_("Your seed extension is") + ':'))
hbox.addWidget(passphrase_e)
self.addLayout(hbox)
self.addStretch(1)
self.seed_warning = WWLabel('')
if msg:
self.seed_warning.setText(seed_warning_msg(seed))
self.addWidget(self.seed_warning)
示例9: ChoiceSection
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
class ChoiceSection(QGroupBox):
"""a widget containing a read-only-field and several buttons,
any of which can be used to make the choice,
which is displayed in the field & emitted as signal choice
"""
choice = pyqtSignal(str)
def __init__(self, field_text, btns, parent=None, label_width = None):
super().__init__(parent)
self.field_text = field_text
self.buttons = btns
self.label_width = label_width
self.init_UI()
def init_UI(self):
grid = QGridLayout()
self.setLayout(grid)
label = QLabel(self.field_text, self)
if self.label_width:
label.setMinimumWidth(self.label_width)
label.setMaximumWidth(self.label_width)
grid.addWidget(label, 0, 0)
self.field = QLineEdit(self)
self.field.setReadOnly(True)
self.field.setStyleSheet(general.label_style_entry)
grid.addWidget(self.field, 0, 1)
self.button_dic = {}
row = 1
for (i, button) in enumerate(self.buttons):
row += 1
grid.addWidget(button, row, 0, 1, 2)
self.button_dic[i] = button
if i < len(self.buttons) - 1:
row += 1
or_lbl = QLabel("or", self)
or_lbl.setAlignment(Qt.AlignCenter)
grid.addWidget(or_lbl, row, 0, 1, 2)
for i in self.button_dic:
btn = self.button_dic[i]
btn.done.connect(self.field.setText)
btn.done.connect(self.choice.emit)
for j in self.button_dic:
if i != j:
btn2 = self.button_dic[j]
btn.done.connect(btn2.change_to_normal)
@pyqtSlot()
def reactivate(self):
"""returns buttons to clickme-style if they need to be re-used
"""
for i in self.button_dic:
btn = self.button_dic[i]
btn.setStyleSheet(general.btn_style_clickme)
示例10: box
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [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
示例11: add_path_row
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [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
示例12: LatusFolderPage
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
class LatusFolderPage(QWizardPage):
def __init__(self):
super().__init__()
self.latus_folder_box = QLineEdit()
self.latus_folder_box.setReadOnly(True)
self.setTitle("Latus folder")
self.setSubTitle("This is the Latus folder on your computer. You may edit this path if you wish.")
self.latus_folder_box.show()
layout = QGridLayout()
layout.addWidget(self.latus_folder_box, 0, 1)
self.setLayout(layout)
self.registerField(LATUS_FOLDER_FIELD_STRING, self.latus_folder_box)
def initializePage(self):
latus_folder = latus.wizard.latus_folder_from_cloud_folder(self.field(CLOUD_FOLDER_FIELD_STRING))
self.latus_folder_box.setText(latus_folder)
示例13: SecondPage
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
class SecondPage(QWizardPage):
def __init__(self):
super().__init__()
self.setTitle(translations.TR_WIZARD_PYQT_PROJECT_TITLE_SECOND_PAGE)
self.setSubTitle(
translations.TR_WIZARD_PYQT_PROJECT_SUBTITLE_SECOND_PAGE)
vbox = QVBoxLayout(self)
frame = QFrame(self)
frame.setFrameShape(QFrame.StyledPanel)
vbox.addWidget(frame)
# Fields
fields_box = QGridLayout(frame)
fields_box.addWidget(
QLabel(translations.TR_WIZARD_PYQT_CLASS_NAME), 0, 0)
self._line_class_name = QLineEdit()
self.registerField("class_name*", self._line_class_name)
fields_box.addWidget(self._line_class_name, 0, 1)
fields_box.addWidget(
QLabel(translations.TR_WIZARD_PYQT_BASE_CLASS), 1, 0)
self._combo_class_name = QComboBox()
self._combo_class_name.addItems(["QWidget", "QMainWindow", "QDialog"])
self.registerField(
"base_class", self._combo_class_name, property="currentText")
fields_box.addWidget(self._combo_class_name, 1, 1)
fields_box.addWidget(
QLabel(translations.TR_WIZARD_PYQT_WIDGET_FILE), 2, 0)
self._line_widget_file = QLineEdit()
self._line_widget_file.setReadOnly(True)
fields_box.addWidget(self._line_widget_file, 2, 1)
self._combo_class_name.currentTextChanged.connect(
self.__update_line_widget)
self.__update_line_widget(self._combo_class_name.currentText())
def __update_line_widget(self, text):
text = text.lower()[1:] + ".py"
self._line_widget_file.setText(text)
示例14: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [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()
示例15: add_path_row
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setReadOnly [as 別名]
def add_path_row(self, path, watched):
# path
path_line = QLineEdit(path)
path_line.setReadOnly(True)
width = QFontMetrics(QFont()).width(path) * 1.05
path_line.setMinimumWidth(width)
self._paths_layout.addWidget(path_line, self._paths_row, 0)
# watch label and checkbox
watcher_label = QLabel('watch:')
self._paths_layout.addWidget(watcher_label, self._paths_row, 1)
watcher_check_box = QCheckBox()
watcher_check_box.setChecked(watched)
self._watch_check_boxes[path] = watcher_check_box
self._paths_layout.addWidget(watcher_check_box, self._paths_row, 2)
# remove button
remove_button = QRemovePushButton(path, path_line, watcher_label, watcher_check_box, self._removes, self._adds)
remove_button.clicked.connect(remove_button.remove)
self._paths_layout.addWidget(remove_button, self._paths_row, 3)
self._paths_row += 1