本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setMaximumWidth方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setMaximumWidth方法的具體用法?Python QLineEdit.setMaximumWidth怎麽用?Python QLineEdit.setMaximumWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setMaximumWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: LoggingToolbar
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [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")
示例2: ASCreation
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
class ASCreation(QWidget):
@update_paths
def __init__(self, nodes, links, controller):
super().__init__()
self.controller = controller
self.nodes = nodes
self.links = links
self.setWindowTitle('Create AS')
# AS type
AS_type = QLabel('Type')
self.AS_type_list = QObjectComboBox()
self.AS_type_list.addItems(AS_subtypes)
# AS name
AS_name = QLabel('Name')
self.name_edit = QLineEdit()
self.name_edit.setMaximumWidth(120)
# AS ID
AS_id = QLabel('ID')
self.id_edit = QLineEdit()
self.id_edit.setMaximumWidth(120)
# confirmation button
button_create_AS = QPushButton()
button_create_AS.setText('Create AS')
button_create_AS.clicked.connect(self.create_AS)
# cancel button
cancel_button = QPushButton()
cancel_button.setText('Cancel')
# position in the grid
layout = QGridLayout()
layout.addWidget(AS_type, 0, 0, 1, 1)
layout.addWidget(self.AS_type_list, 0, 1, 1, 1)
layout.addWidget(AS_name, 1, 0, 1, 1)
layout.addWidget(self.name_edit, 1, 1, 1, 1)
layout.addWidget(AS_id, 2, 0, 1, 1)
layout.addWidget(self.id_edit, 2, 1, 1, 1)
layout.addWidget(button_create_AS, 3, 0, 1, 1)
layout.addWidget(cancel_button, 3, 1, 1, 1)
self.setLayout(layout)
def create_AS(self):
# automatic initialization of the AS id in case it is empty
id = self.id_edit.text()
id = int(id) if id else len(self.network.pnAS) + 1
new_AS = self.network.AS_factory(
self.AS_type_list.text,
self.name_edit.text(),
id,
self.links,
self.nodes
)
self.close()
示例3: NetworkToolbar
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [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()
示例4: _create_text_edit
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [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
示例5: word_dialog
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
def word_dialog(self, msg):
dialog = WindowModalDialog(self.top_level_window(), "")
hbox = QHBoxLayout(dialog)
hbox.addWidget(QLabel(msg))
text = QLineEdit()
text.setMaximumWidth(100)
text.returnPressed.connect(dialog.accept)
hbox.addWidget(text)
hbox.addStretch(1)
dialog.exec_() # Firmware cannot handle cancellation
self.word = text.text()
self.done.set()
示例6: formMain
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
def formMain(self):
leProbSheet = QLineEdit()
leProbSheet.setMaximumWidth(50)
self.frmMain.addRow(QLabel("Enter Problem Sheet ID:"), leProbSheet)
hbShip = self.createRadioGroup("Ship")
rbtnShipYes = self.rb.get("ShipYes")
rbtnShipNo = self.rb.get("ShipNo")
rbtnShipNo.setChecked(True)
self.frmMain.addRow(QLabel("Did you confirm the correct shipping was \n selected and the correct pricing was quoted?"), hbShip)
hbYY = self.createRadioGroup("YY")
rbtnYYYes = self.rb.get("YYYes")
rbtnYYNo = self.rb.get("YYNo")
rbtnYYNo.setChecked(True)
self.frmMain.addRow(QLabel("Is the order a YY or a non-suspicious NY/YN?"), hbYY)
hbOver = self.createRadioGroup("Over")
rbtnOverYes = self.rb.get("OverYes")
rbtnOverNo = self.rb.get("OverNo")
rbtnOverNo.setChecked(True)
self.frmMain.addRow(QLabel("Did you override and upgrade the shipping \n in Stone Edge?"), hbOver)
teNotes = QTextEdit()
teNotes.setMaximumHeight(125)
self.frmMain.addRow(QLabel("Additional Notes:"))
self.frmMain.addRow(teNotes)
btnApprove = QPushButton("Approved")
btnApprove.clicked.connect(lambda: self.btnApprove_Click(leProbSheet.text(), rbtnShipYes.isChecked(), rbtnYYYes.isChecked(), rbtnOverYes.isChecked(), teNotes.toPlainText()))
btnDeny = QPushButton("Not Approved")
btnDeny.clicked.connect(lambda: self.btnDeny_Click(leProbSheet.text(), rbtnShipYes.isChecked(), rbtnYYYes.isChecked(), rbtnOverYes.isChecked(), teNotes.toPlainText()))
btnQuit = QPushButton("Quit")
btnQuit.clicked.connect(self.btnCancel_Click)
hbBtnBox = QHBoxLayout()
hbBtnBox.addWidget(btnApprove)
hbBtnBox.addWidget(btnDeny)
hbBtnBox.addWidget(btnQuit)
self.frmMain.addRow(hbBtnBox)
示例7: BudgetPanel
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
class BudgetPanel(Panel):
FIELDS = [
('amountEdit', 'amount'),
('notesEdit', 'notes'),
]
PERSISTENT_NAME = 'budgetPanel'
def __init__(self, model, mainwindow):
Panel.__init__(self, mainwindow)
self.setAttribute(Qt.WA_DeleteOnClose)
self._setupUi()
self.model = model
self.accountComboBox = ComboboxModel(model=self.model.account_list, view=self.accountComboBoxView)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
def _setupUi(self):
self.setWindowTitle(tr("Budget Info"))
self.resize(230, 230)
self.setModal(True)
self.verticalLayout = QVBoxLayout(self)
self.formLayout = QFormLayout()
self.formLayout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
self.accountComboBoxView = QComboBox(self)
self.formLayout.setWidget(0, QFormLayout.FieldRole, self.accountComboBoxView)
self.label_3 = QLabel(tr("Account:"))
self.formLayout.setWidget(0, QFormLayout.LabelRole, self.label_3)
self.amountEdit = QLineEdit(self)
self.amountEdit.setMaximumWidth(120)
self.formLayout.setWidget(1, QFormLayout.FieldRole, self.amountEdit)
self.label_5 = QLabel(tr("Amount:"))
self.formLayout.setWidget(1, QFormLayout.LabelRole, self.label_5)
self.notesEdit = QPlainTextEdit(tr("Notes:"))
self.formLayout.setWidget(2, QFormLayout.FieldRole, self.notesEdit)
self.label = QLabel(self)
self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label)
self.verticalLayout.addLayout(self.formLayout)
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Save)
self.verticalLayout.addWidget(self.buttonBox)
self.label_3.setBuddy(self.accountComboBoxView)
self.label_5.setBuddy(self.amountEdit)
示例8: DocumentationGroupBox
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
class DocumentationGroupBox(QGroupBox):
def __init__(self, enabled=False, max_deduction=0, deduction=0):
def onMaxEditPoint(new_max):
self.max_deduction = int(new_max)
def onEditPoint(new_deduction):
if int(new_deduction) > self.max_deduction:
error = QMessageBox(QMessageBox.Critical, 'Error',"The point deduction per element missing can't be greater than the maximum point deduction", QMessageBox.Ok, self)
error.show()
else:
self.deduction_per_elem = int(new_deduction)
super().__init__()
self.max_deduction = max_deduction;
self.deduction_per_elem = deduction
point_validator = QIntValidator()
point_label = QLabel('Points deduction per element missing:')
self.point_edit = QLineEdit()
self.point_edit.setMaximumWidth(50)
self.point_edit.setText('0')
self.point_edit.setValidator(point_validator)
self.point_edit.textChanged.connect(lambda new_deduction: onEditPoint(new_deduction))
max_point_label = QLabel('Maximum points deduction:')
self.max_point_edit = QLineEdit()
self.max_point_edit.setMaximumWidth(50)
self.max_point_edit.setText('0')
self.max_point_edit.setValidator(point_validator)
self.max_point_edit.textChanged.connect(lambda new_max: onMaxEditPoint(new_max))
gb_grid = QGridLayout()
gb_grid.addWidget(point_label, 0, 0, 1, 1)
gb_grid.addWidget(self.point_edit, 0, 1, 1, 1)
gb_grid.addWidget(max_point_label, 1, 0, 1, 1)
gb_grid.addWidget(self.max_point_edit, 1, 1, 1, 1)
self.setLayout(gb_grid)
self.setTitle('Documentation')
self.setCheckable(True)
self.setChecked(enabled)
示例9: MultipleNodes
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
class MultipleNodes(QWidget):
def __init__(self, x, y, controller):
super().__init__()
self.controller = controller
self.x, self.y = x, y
self.setWindowTitle('Multiple nodes')
nb_nodes = QLabel('Number of nodes')
self.nb_nodes_edit = QLineEdit()
self.nb_nodes_edit.setMaximumWidth(120)
# list of node type
node_type = QLabel('Type of node')
self.node_subtype_list = QObjectComboBox()
self.node_subtype_list.addItems(node_name_to_obj)
# confirmation button
confirmation_button = QPushButton()
confirmation_button.setText('OK')
confirmation_button.clicked.connect(self.create_nodes)
# cancel button
cancel_button = QPushButton()
cancel_button.setText('Cancel')
# position in the grid
layout = QGridLayout()
layout.addWidget(nb_nodes, 0, 0, 1, 1)
layout.addWidget(self.nb_nodes_edit, 0, 1, 1, 1)
layout.addWidget(node_type, 1, 0, 1, 1)
layout.addWidget(self.node_subtype_list, 1, 1, 1, 1)
layout.addWidget(confirmation_button, 2, 0, 1, 1)
layout.addWidget(cancel_button, 2, 1, 1, 1)
self.setLayout(layout)
@update_paths
def create_nodes(self, _):
nb_nodes = int(self.nb_nodes_edit.text())
subtype = node_name_to_obj[self.node_subtype_list.currentText()]
self.view.draw_objects(*self.network.multiple_nodes(nb_nodes, subtype))
self.close()
示例10: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
def __init__(self, controller):
super().__init__()
self.controller = controller
self.setWindowTitle('Spring layout parameters')
self.resize(480, 320)
grid = QGridLayout()
spring_groupbox = QGroupBox('Spring layout parameters')
layout = QGridLayout(spring_groupbox)
self.line_edits = []
for index, (parameter, value) in enumerate(self.spring_parameters.items()):
label = QLabel(parameter)
line_edit = QLineEdit()
line_edit.setText(str(value))
line_edit.setMaximumWidth(120)
self.line_edits.append(line_edit)
layout.addWidget(label, index, 0, 1, 1)
layout.addWidget(line_edit, index, 1, 1, 1)
grid.addWidget(spring_groupbox, 0, 0, 1, 1)
self.setLayout(grid)
示例11: CreateArea
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
class CreateArea(QWidget):
def __init__(self, asm):
super().__init__()
self.setWindowTitle('Create area')
area_name = QLabel('Area name')
area_id = QLabel('Area id')
self.name_edit = QLineEdit()
self.name_edit.setMaximumWidth(120)
self.id_edit = QLineEdit()
self.id_edit.setMaximumWidth(120)
# confirmation button
button_create_area = QPushButton()
button_create_area.setText('OK')
button_create_area.clicked.connect(lambda: self.create_area(asm))
# cancel button
cancel_button = QPushButton()
cancel_button.setText('Cancel')
# position in the grid
layout = QGridLayout()
layout.addWidget(area_name, 0, 0, 1, 1)
layout.addWidget(self.name_edit, 0, 1, 1, 1)
layout.addWidget(area_id, 1, 0, 1, 1)
layout.addWidget(self.id_edit, 1, 1, 1, 1)
layout.addWidget(button_create_area, 2, 0, 1, 1)
layout.addWidget(cancel_button, 2, 1, 1, 1)
self.setLayout(layout)
def create_area(self, asm):
asm.add_area(self.name_edit.text(), self.id_edit.text())
self.close()
示例12: AppWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
#.........這裏部分代碼省略.........
spacer_start.setFixedSize(QSize(10, 1))
self.toolbar.addWidget(spacer_start)
favourite_view_icon = QIcon(gui_constants.STAR_BTN_PATH)
favourite_view_action = QAction(favourite_view_icon, "Favourite", self)
#favourite_view_action.setText("Manga View")
favourite_view_action.triggered.connect(lambda: self.setCurrentIndex(1)) #need lambda to pass extra args
self.toolbar.addAction(favourite_view_action)
catalog_view_icon = QIcon(gui_constants.HOME_BTN_PATH)
catalog_view_action = QAction(catalog_view_icon, "Library", self)
#catalog_view_action.setText("Catalog")
catalog_view_action.triggered.connect(lambda: self.setCurrentIndex(0)) #need lambda to pass extra args
self.toolbar.addAction(catalog_view_action)
self.toolbar.addSeparator()
series_icon = QIcon(gui_constants.PLUS_PATH)
series_action = QAction(series_icon, "Add series...", self)
series_action.triggered.connect(self.manga_list_view.SERIES_DIALOG.emit)
series_menu = QMenu()
series_menu.addSeparator()
populate_action = QAction("Populate from folder...", self)
populate_action.triggered.connect(self.populate)
series_menu.addAction(populate_action)
series_action.setMenu(series_menu)
self.toolbar.addAction(series_action)
spacer_middle = QWidget() # aligns buttons to the right
spacer_middle.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.toolbar.addWidget(spacer_middle)
self.search_bar = QLineEdit()
self.search_bar.setPlaceholderText("Search title, artist, genres")
self.search_bar.setMaximumWidth(200)
self.toolbar.addWidget(self.search_bar)
self.toolbar.addSeparator()
settings_icon = QIcon(gui_constants.SETTINGS_PATH)
settings_action = QAction(settings_icon, "Set&tings", self)
self.toolbar.addAction(settings_action)
self.addToolBar(self.toolbar)
spacer_end = QWidget() # aligns About action properly
spacer_end.setFixedSize(QSize(10, 1))
self.toolbar.addWidget(spacer_end)
def setCurrentIndex(self, number, index=None):
"""Changes the current display view.
Params:
number <- int (0 for manga view, 1 for chapter view
Optional:
index <- QModelIndex for chapter view
Note: 0-based indexing
"""
if index is not None:
self.chapter_info_view.display_manga(index)
self.display.setCurrentIndex(number)
else:
self.display.setCurrentIndex(number)
# TODO: Improve this so that it adds to the series dialog,
# so user can edit data before inserting (make it a choice)
def populate(self):
"Populates the database with series from local drive'"
msgbox = QMessageBox()
msgbox.setText("<font color='red'><b>Use with care.</b></font> Choose a folder containing all your series'.")
msgbox.setInformativeText("Oniichan, are you sure you want to do this?")
示例13: ErrorGroupBox
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
class ErrorGroupBox(QGroupBox):
def __init__(self, max_deduction=0):
def tableCellChanged(rowIdx, colIdx):
if colIdx == 2:
err_id = self.table.item(rowIdx, 0).text()
new_val = self.table.item(rowIdx, colIdx).text()
old_val = self.errors[err_id].penalty
if new_val.isdigit():
self.errors[err_id].penalty = int(new_val)
else:
self.table.item(rowIdx, colIdx).setText(str(old_val))
def onMaxEditPoint(line_edit):
self.max_deduction = int(line_edit.text())
super().__init__()
self.max_deduction = max_deduction
self.table = QTableWidget()
self.table.setRowCount(len(get_default_errors()))
self.table.setColumnCount(4)
self.table.setHorizontalHeaderLabels(["ID", "Description", "Penalty", "Enabled"])
self.table.horizontalHeader().setSectionResizeMode(1)
self.table.setShowGrid(False)
self.table.verticalHeader().setVisible(False)
self.table.resizeColumnsToContents()
self.table.setSortingEnabled(False)
self.table.cellChanged.connect(tableCellChanged)
self.setErrors(get_default_errors())
max_point_label = QLabel("Maximum points deduction:")
point_validator = QIntValidator()
self.max_point_edit = QLineEdit()
self.max_point_edit.setMaximumWidth(50)
self.max_point_edit.setText("0")
self.max_point_edit.setValidator(point_validator)
self.max_point_edit.editingFinished.connect(lambda: onEditMax(self.max_point_edit))
gb_grid = QGridLayout()
gb_grid.addWidget(self.table, 0, 0, 4, 6)
gb_grid.addWidget(max_point_label, 5, 4, 1, 1)
gb_grid.addWidget(self.max_point_edit, 5, 5, 1, 1)
self.setLayout(gb_grid)
self.setTitle("Errors")
self.setCheckable(True)
self.setChecked(False)
def chkboxClicked(self, err, state):
self.errors[err.id].is_enabled = state is Qt.Checked
def setErrors(self, errors):
self.errors = errors
for idx, err_key in enumerate(sorted(self.errors)):
err = self.errors[err_key]
id_item = QTableWidgetItem(err.id)
id_item.setFlags(Qt.ItemIsEnabled)
desc_item = QTableWidgetItem(err.check)
desc_item.setFlags(Qt.ItemIsEnabled)
penalty_item = QTableWidgetItem(str(err.penalty))
penalty_item.setTextAlignment(Qt.AlignCenter)
cell_widget = QWidget()
chk_box = QCheckBox()
if err.is_enabled:
chk_box.setCheckState(Qt.Checked)
else:
chk_box.setCheckState(Qt.Unchecked)
chk_box.stateChanged.connect(lambda state, err=err: self.chkboxClicked(err, state))
layout = QHBoxLayout(cell_widget)
layout.addWidget(chk_box)
layout.setAlignment(Qt.AlignCenter)
cell_widget.setLayout(layout)
self.table.setItem(idx, 0, id_item)
self.table.setItem(idx, 1, desc_item)
self.table.setItem(idx, 2, penalty_item)
self.table.setCellWidget(idx, 3, cell_widget)
示例14: View
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
class View(QMainWindow) :
signalAdd = pyqtSignal(QMainWindow)
signalButton = pyqtSignal()
signalWidget = pyqtSignal(QMainWindow)
signalDelete = pyqtSignal(QListWidget,QMainWindow)
signalDisplay = pyqtSignal(QMainWindow)
signalSearch = pyqtSignal(QMainWindow)
signalModify = pyqtSignal(QMainWindow)
signalUnlock = pyqtSignal()
def __init__(self):
QMainWindow.__init__(self)
self.setWindowOpacity(0.98)
self.setWindowIcon(QIcon("Pictures/telephone.png"))
self.resize(700,500)
self.setWindowTitle("Annuaire")
self.setStyleSheet("background-color:pink")
self.activeLayout = 0
self.activeButtonAdd = 0
self.activeButtonEdit = 0
self.activeButtonSave = 0
self.alreadyClicked = 0
self.createWidgets()
self.connectWidgets()
def createWidgets(self):
"""Cette fonction permet la création de tous les widgets de la
mainWindow"""
#Création toolbar
toolBar = self.addToolBar("Tools")
#Création bar recherche
self.lineEditSearch = QLineEdit()
self.lineEditSearch.setPlaceholderText("Recherche")
self.lineEditSearch.setStyleSheet("background-color:white")
toolBar.addWidget(self.lineEditSearch)
self.lineEditSearch.setMaximumWidth(300)
#Création séparateur
toolBar.addSeparator()
#Création icon add contact
self.actionAdd = QAction("Ajouter (Ctrl+P)",self)
toolBar.addAction(self.actionAdd)
self.actionAdd.setShortcut("Ctrl+P")
self.actionAdd.setIcon(QIcon("Pictures/sign.png"))
#Création icon delete contact
self.actionDelete = QAction("supprimer (Ctrl+D)",self)
toolBar.addAction(self.actionDelete)
self.actionDelete.setShortcut("Ctrl+D")
self.actionDelete.setIcon(QIcon("Pictures/contacts.png"))
#Création icon quit
self.actionQuitter = QAction("Quitter (Ctrl+Q)",self)
toolBar.addAction(self.actionQuitter)
self.actionQuitter.setShortcut("Ctrl+Q")
self.actionQuitter.setIcon(QIcon("Pictures/arrows.png"))
#Création widget central
self.centralWidget = QWidget()
self.centralWidget.setStyleSheet("background-color:white")
self.setCentralWidget(self.centralWidget)
#Création dockWidget left
dockDisplay = QDockWidget("Répertoire")
dockDisplay.setStyleSheet("background-color:white")
dockDisplay.setFeatures(QDockWidget.DockWidgetFloatable)
dockDisplay.setAllowedAreas(Qt.LeftDockWidgetArea |
Qt.RightDockWidgetArea)
self.addDockWidget(Qt.LeftDockWidgetArea,dockDisplay)
containDock = QWidget(dockDisplay)
dockDisplay.setWidget(containDock)
dockLayout = QVBoxLayout()
displayWidget = QScrollArea()
displayWidget.setWidgetResizable(1)
dockLayout.addWidget(displayWidget)
containDock.setLayout(dockLayout)
#Ajouter la list au dockwidget
self.listContact = QListWidget()
displayWidget.setWidget(self.listContact)
def widgetFormulaire(self) :
"""Fonction donner à la QAction "Ajouter" de la toolbar"""
self.deleteWidget()
#Label prénom/nom
self.labelPictureContact = QLabel("*")
pictureContact = QPixmap("Pictures/avatar.png")
self.labelPictureContact.setPixmap(pictureContact)
#Ajouter prénom
self.nameEdit = QLineEdit()
self.nameEdit.setToolTip("Entrez un prénom sans espace")
#.........這裏部分代碼省略.........
示例15: request_trezor_init_settings
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMaximumWidth [as 別名]
def request_trezor_init_settings(self, wizard, method, device):
vbox = QVBoxLayout()
next_enabled = True
label = QLabel(_("Enter a label to name your device:"))
name = QLineEdit()
hl = QHBoxLayout()
hl.addWidget(label)
hl.addWidget(name)
hl.addStretch(1)
vbox.addLayout(hl)
def clean_text(widget):
text = widget.toPlainText().strip()
return ' '.join(text.split())
if method in [TIM_NEW, TIM_RECOVER]:
gb = QGroupBox()
hbox1 = QHBoxLayout()
gb.setLayout(hbox1)
# KeepKey recovery doesn't need a word count
if method == TIM_NEW:
vbox.addWidget(gb)
gb.setTitle(_("Select your seed length:"))
bg = QButtonGroup()
for i, count in enumerate([12, 18, 24]):
rb = QRadioButton(gb)
rb.setText(_("{} words").format(count))
bg.addButton(rb)
bg.setId(rb, i)
hbox1.addWidget(rb)
rb.setChecked(True)
cb_pin = QCheckBox(_('Enable PIN protection'))
cb_pin.setChecked(True)
else:
text = QTextEdit()
text.setMaximumHeight(60)
if method == TIM_MNEMONIC:
msg = _("Enter your BIP39 mnemonic:")
else:
msg = _("Enter the master private key beginning with xprv:")
def set_enabled():
from electrum.bip32 import is_xprv
wizard.next_button.setEnabled(is_xprv(clean_text(text)))
text.textChanged.connect(set_enabled)
next_enabled = False
vbox.addWidget(QLabel(msg))
vbox.addWidget(text)
pin = QLineEdit()
pin.setValidator(QRegExpValidator(QRegExp('[1-9]{0,9}')))
pin.setMaximumWidth(100)
hbox_pin = QHBoxLayout()
hbox_pin.addWidget(QLabel(_("Enter your PIN (digits 1-9):")))
hbox_pin.addWidget(pin)
hbox_pin.addStretch(1)
if method in [TIM_NEW, TIM_RECOVER]:
vbox.addWidget(WWLabel(RECOMMEND_PIN))
vbox.addWidget(cb_pin)
else:
vbox.addLayout(hbox_pin)
passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT)
passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
passphrase_warning.setStyleSheet("color: red")
cb_phrase = QCheckBox(_('Enable passphrases'))
cb_phrase.setChecked(False)
vbox.addWidget(passphrase_msg)
vbox.addWidget(passphrase_warning)
vbox.addWidget(cb_phrase)
wizard.exec_layout(vbox, next_enabled=next_enabled)
if method in [TIM_NEW, TIM_RECOVER]:
item = bg.checkedId()
pin = cb_pin.isChecked()
else:
item = ' '.join(str(clean_text(text)).split())
pin = str(pin.text())
return (item, name.text(), pin, cb_phrase.isChecked())