本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.addAction方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.addAction方法的具體用法?Python QLineEdit.addAction怎麽用?Python QLineEdit.addAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.addAction方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FirstPage
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import addAction [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')
示例2: Page
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import addAction [as 別名]
class Page(QWizardPage):
def __init__(self):
super().__init__()
vbox = QVBoxLayout(self)
self.setTitle("Python Project")
frame = QFrame()
frame.setLineWidth(2)
vbox.addStretch(1)
frame.setFrameShape(QFrame.StyledPanel)
vbox.addWidget(frame)
box = QGridLayout(frame)
box.addWidget(QLabel("Project Name:"), 0, 0)
self._line_project_name = QLineEdit()
self.registerField("name*", self._line_project_name)
box.addWidget(self._line_project_name, 0, 1)
box.addWidget(QLabel("Create in:"), 1, 0)
self.line = QLineEdit()
self.registerField("path", self.line)
choose_dir_action = self.line.addAction(
QIcon(self.style().standardPixmap(
self.style().SP_DirIcon)), QLineEdit.TrailingPosition)
box.addWidget(self.line, 1, 1)
box.addWidget(QLabel("Interpreter:"), 2, 0)
line_interpreter = QComboBox()
line_interpreter.setEditable(True)
line_interpreter.addItems(utils.get_python())
box.addWidget(line_interpreter, 2, 1)
# from ninja_ide.utils import utils
choose_dir_action.triggered.connect(self._choose_dir)
self.line.setText(utils.get_home_dir())
def _choose_dir(self):
directory = QFileDialog.getExistingDirectory(
self, "Choose Directory", "~")
if directory:
self.line.setText(directory)
示例3: RenameDialog
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import addAction [as 別名]
class RenameDialog(QDialog):
def __init__(self, parent: QWidget) -> None:
super().__init__(parent)
self._basename: str = ""
self._build_gui()
def _build_gui(self) -> None:
self.resize(600, 100)
self.setWindowTitle("RenameDialog")
self.setWindowModality(Qt.WindowModal)
# Widgets
icon_label = QLabel()
icon_label.setPixmap(QIcon.fromTheme("accessories-text-editor").pixmap(48))
icon_label.setAlignment(Qt.AlignTop)
self.label = QLabel("Rename ...")
self.label.setTextInteractionFlags(Qt.TextSelectableByMouse)
self.name_edit = QLineEdit(self)
self.name_reload = self.name_edit.addAction(QIcon.fromTheme("reload"), QLineEdit.TrailingPosition)
self.name_reload.setShortcut("F5")
self.name_reload.setToolTip("Reset the filename to it's original name")
self.button_box = QDialogButtonBox(self)
self.btn_rename = QPushButton(QIcon.fromTheme("document-save-as"), "Rename")
self.button_box.addButton(self.btn_rename, QDialogButtonBox.AcceptRole)
self.btn_cancel = self.button_box.addButton(QDialogButtonBox.Cancel)
self.btn_rename.setDefault(True)
# layout
self.vbox = QVBoxLayout()
self.vbox.addWidget(self.label)
self.vbox.addWidget(self.name_edit)
self.vbox.addStretch()
self.vbox.addWidget(self.button_box)
hbox = QHBoxLayout()
hbox.addWidget(icon_label)
hbox.addLayout(self.vbox)
self.setLayout(hbox)
# signals
self.name_edit.returnPressed.connect(self.accept)
self.btn_rename.clicked.connect(self._on_rename_clicked)
self.btn_cancel.clicked.connect(self._on_cancel_clicked)
self.name_reload.triggered.connect(self._on_name_reload)
def _on_rename_clicked(self) -> None:
self.accept()
def _on_cancel_clicked(self) -> None:
self.reject()
def _on_name_reload(self) -> None:
self.name_edit.setText(self._basename)
root, ext = os.path.splitext(self._basename)
self.name_edit.setSelection(0, len(root))
def get_old_basename(self) -> str:
return self._basename
def get_new_basename(self) -> str:
return cast(str, self.name_edit.text())
def set_basename(self, basename: str) -> None:
self._basename = basename
self.setWindowTitle("Rename \"{}\"".format(basename))
self.label.setText("Rename \"{}\" to:".format(basename))
self.name_edit.setText(basename)
root, ext = os.path.splitext(basename)
self.name_edit.setSelection(0, len(root))
示例4: ProjectExecution
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import addAction [as 別名]
class ProjectExecution(QWidget):
"""Project Execution widget class"""
def __init__(self, parent):
super(ProjectExecution, self).__init__()
self._parent = parent
grid = QGridLayout(self)
grid.addWidget(QLabel(translations.TR_PROJECT_MAIN_FILE), 0, 0)
# Main file
self.path = QLineEdit()
choose_main_file_action = QAction(self)
choose_main_file_action.setIcon(
self.style().standardIcon(self.style().SP_FileIcon))
choose_main_file_action.setToolTip(
translations.TR_PROJECT_SELECT_MAIN_FILE)
self.path.addAction(
choose_main_file_action, QLineEdit.TrailingPosition)
clear_main_file_action = self.path.addAction(
self.style().standardIcon(self.style().SP_LineEditClearButton),
QLineEdit.TrailingPosition)
clear_main_file_action.triggered.connect(self.path.clear)
self.path.setPlaceholderText(
os.path.join(os.path.expanduser("~"), 'path', 'to', 'main.py'))
self.path.setText(self._parent.project.main_file)
grid.addWidget(self.path, 0, 1)
# this should be changed, and ALL pythonPath names to
# python_custom_interpreter or something like that. this is NOT the
# PYTHONPATH
self.line_interpreter = QLineEdit()
choose_interpreter = self.line_interpreter.addAction(
self.style().standardIcon(self.style().SP_DirIcon),
QLineEdit.TrailingPosition)
self.line_interpreter.setText(self._parent.project.python_exec)
completer = QCompleter(utils.get_python())
completer.setCaseSensitivity(Qt.CaseInsensitive)
completer.setFilterMode(Qt.MatchContains)
self.line_interpreter.setCompleter(completer)
self.line_interpreter.setPlaceholderText("python")
grid.addWidget(QLabel(
translations.TR_PROJECT_PYTHON_INTERPRETER), 1, 0)
grid.addWidget(self.line_interpreter, 1, 1)
# PYTHONPATH
grid.addWidget(QLabel(translations.TR_PROJECT_PYTHON_PATH), 2, 0)
self.txt_python_path = QPlainTextEdit() # TODO : better widget
self.txt_python_path.setPlainText(self._parent.project.python_path)
self.txt_python_path.setToolTip(translations.TR_PROJECT_PATH_PER_LINE)
grid.addWidget(self.txt_python_path, 2, 1)
# Additional builtins/globals for pyflakes
grid.addWidget(QLabel(translations.TR_PROJECT_BUILTINS), 3, 0)
self.additional_builtins = QLineEdit()
self.additional_builtins.setText(
' '.join(self._parent.project.additional_builtins))
self.additional_builtins.setToolTip(
translations.TR_PROJECT_BUILTINS_TOOLTIP)
grid.addWidget(self.additional_builtins, 3, 1)
# Pre script
self._line_pre_exec = QLineEdit()
choose_pre_exec = QAction(self)
choose_pre_exec.setToolTip(
"Choose Script to execute before run project")
choose_pre_exec.setIcon(
self.style().standardIcon(self.style().SP_FileIcon))
self._line_pre_exec.addAction(
choose_pre_exec, QLineEdit.TrailingPosition)
clear_pre_action = self._line_pre_exec.addAction(
self.style().standardIcon(self.style().SP_LineEditClearButton),
QLineEdit.TrailingPosition)
clear_pre_action.triggered.connect(self._line_pre_exec.clear)
self._line_pre_exec.setReadOnly(True)
self._line_pre_exec.setText(self._parent.project.pre_exec_script)
self._line_pre_exec.setPlaceholderText(
os.path.join(os.path.expanduser("~"), 'path', 'to', 'script.sh'))
grid.addWidget(QLabel(translations.TR_PROJECT_PRE_EXEC), 4, 0)
grid.addWidget(self._line_pre_exec, 4, 1)
# Post script
self._line_post_exec = QLineEdit()
choose_post_exec = QAction(self)
choose_post_exec.setToolTip(
"Choose script to execute after run project")
choose_post_exec.setIcon(
self.style().standardIcon(self.style().SP_FileIcon))
self._line_post_exec.addAction(
choose_post_exec, QLineEdit.TrailingPosition)
clear_post_action = self._line_post_exec.addAction(
self.style().standardIcon(self.style().SP_LineEditClearButton),
QLineEdit.TrailingPosition)
clear_post_action.triggered.connect(self._line_post_exec.clear)
self._line_post_exec.setReadOnly(True)
self._line_post_exec.setText(self._parent.project.post_exec_script)
self._line_post_exec.setPlaceholderText(
os.path.join(os.path.expanduser("~"), 'path', 'to', 'script.sh'))
grid.addWidget(QLabel(translations.TR_PROJECT_POST_EXEC), 5, 0)
grid.addWidget(self._line_post_exec, 5, 1)
# grid.addItem(QSpacerItem(5, 10, QSizePolicy.Expanding,
# QSizePolicy.Expanding), 6, 0)
# Properties
#.........這裏部分代碼省略.........
示例5: InitialPage
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import addAction [as 別名]
class InitialPage(QWizardPage):
def __init__(self):
super().__init__()
vbox = QVBoxLayout(self)
frame = QFrame(self)
vbox.addStretch(1)
frame.setFrameShape(QFrame.StyledPanel)
vbox.addWidget(frame)
# Fields
fields_box = QGridLayout(frame)
# Project name
fields_box.addWidget(QLabel(translations.TR_WIZARD_PROJECT_NAME), 0, 0)
self._line_project_name = QLineEdit("untitled")
self.registerField("name*", self._line_project_name)
fields_box.addWidget(self._line_project_name, 0, 1)
# Project location
fields_box.addWidget(
QLabel(translations.TR_WIZARD_PROJECT_LOCATION), 1, 0)
self._line_location = QLineEdit()
self._line_location.setReadOnly(True)
self._line_location.setText(utils.get_home_dir())
self.registerField("path", self._line_location)
choose_dir_act = self._line_location.addAction(
self.style().standardIcon(
self.style().SP_DirIcon), QLineEdit.TrailingPosition)
fields_box.addWidget(self._line_location, 1, 1)
# Project description
fields_box.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION), 2, 0)
self._txt_desciption = QPlainTextEdit()
fields_box.addWidget(self._txt_desciption, 2, 1)
self.registerField("description", self._txt_desciption)
# Project license
fields_box.addWidget(QLabel(translations.TR_PROJECT_LICENSE), 3, 0)
combo_license = QComboBox()
combo_license.addItems(LICENSES)
combo_license.setCurrentIndex(12)
fields_box.addWidget(combo_license, 3, 1)
self.registerField("license", combo_license, property="currentText")
# Project interpreter
fields_box.addWidget(
QLabel(translations.TR_WIZARD_PROJECT_INTERPRETER), 4, 0)
combo_interpreter = QComboBox()
combo_interpreter.addItems(utils.get_python())
combo_interpreter.setCurrentText(sys.executable)
fields_box.addWidget(combo_interpreter, 4, 1)
self.registerField("interpreter", combo_interpreter)
# Connections
self._line_project_name.textChanged.connect(self._on_text_changed)
choose_dir_act.triggered.connect(self._choose_dir)
def _choose_dir(self):
dirname = QFileDialog.getExistingDirectory(
self, translations.TR_WIZARD_CHOOSE_DIR, utils.get_home_dir())
if dirname:
self._line_location.setText(dirname)
@property
def location(self):
return self._line_location.text()
@property
def project_name(self):
return self._line_project_name.text()
def _on_text_changed(self):
ok = self.validate()
if not ok:
self._line_project_name.setStyleSheet("background-color: red")
else:
self._line_project_name.setStyleSheet("background-color: none;")
def validate(self):
ok = True
project_path = os.path.join(self.location, self.project_name)
if file_manager.folder_exists(project_path):
ok = False
return ok
def isComplete(self):
val = super().isComplete()
return val and self.validate()
示例6: RDBPDBTool
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import addAction [as 別名]
class RDBPDBTool(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle(self.tr("WinRDBI DB File to PDB"))
self.setModal(True)
self.setMinimumWidth(600)
self._process = QProcess(self)
self._process.setProgram("python")
self._process.finished.connect(self._on_finished)
vbox = QVBoxLayout(self)
hbox = QHBoxLayout()
hbox.addWidget(QLabel(self.tr("Ubicación del .rdb:")))
self._line_location = QLineEdit()
self._line_location.setReadOnly(True)
choose_location = self._line_location.addAction(
self.style().standardIcon(
self.style().SP_DirIcon), QLineEdit.TrailingPosition)
hbox.addWidget(self._line_location)
vbox.addLayout(hbox)
aviso = QLabel(
self.tr(
"<b><i>El archivo será guardado en el mismo directorio "
"que el original.</i></b>"))
f = aviso.font()
f.setPointSize(10)
aviso.setFont(f)
vbox.addWidget(aviso)
self._check_open = QCheckBox(self.tr("Abrir la BD al finalizar"))
vbox.addWidget(self._check_open)
hbox = QHBoxLayout()
hbox.addStretch(1)
start_btn = QPushButton(self.tr("Convertir!"))
hbox.addWidget(start_btn)
cancel_btn = QPushButton(self.tr("Salir"))
hbox.addWidget(cancel_btn)
vbox.addLayout(hbox)
choose_location.triggered.connect(self._select_rdb_file)
start_btn.clicked.connect(self._start_convertion)
cancel_btn.clicked.connect(self.close)
def _start_convertion(self):
rdb_filename = self._line_location.text()
tool = os.path.join(settings.ROOT_DIR, "rdb_to_pdb")
args = [tool, rdb_filename]
self._process.setArguments(args)
self._process.start()
def _on_finished(self, code, status):
if status == QProcess.NormalExit == code:
QMessageBox.information(
self, self.tr("Completado!"),
self.tr("Todo ha salido muy bien!"))
if self._check_open.isChecked():
central = Pireal.get_service("central")
rdb = os.path.splitext(self._line_location.text())[0]
pdb = rdb + ".pdb"
central.open_database(pdb)
self.close()
else:
QMessageBox.critical(
self, "Error", "El proceso no se ha completado")
def _select_rdb_file(self):
filename = QFileDialog.getOpenFileName(
self, self.tr("Selecciona el arhico RDB"),
"~", "RDB Files (*.rdb)")[0]
if filename:
self._line_location.setText(filename)
示例7: View
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import addAction [as 別名]
class View(QWidget):
send_data = pyqtSignal(object)
baudrate_src_changed = pyqtSignal(object)
baudrate_pump_changed = pyqtSignal(object)
baudrate_temp_changed = pyqtSignal(object)
#eol_changed = pyqtSignal(object)
port_changed = pyqtSignal(object)
seedPulseChanged = pyqtSignal(object)
seedFreValueChanged = pyqtSignal(object)
seedPulseFreChanged = pyqtSignal(object)
firstPumpChanged = pyqtSignal(object)
secondPumpChanged = pyqtSignal(object)
startSrcModel = pyqtSignal(object)
startPumpModel = pyqtSignal(object)
startTempModel = pyqtSignal(object)
beginTime = pyqtSignal(object)
emitUsername = pyqtSignal(object)
def __init__(self):
super(QWidget,self).__init__()
QWidget.__init__(self)
self.queue = Queue()
self.end_cmd = None
self.autoscroll = True
self.msg_sent = False
self.timer = QTimer()
self.timer.timeout.connect(self.update_gui)
self.timer.start(100)
self.srcModelstarted = False
self.pumpModelstarted = False
self.tempModelstarted = False
self.currentValueList =list()
self.currentTimeList = list()
self.buttonMinimumWidth = 100
# self.topSeedCurrent = 700
# self.topPumpCurrent = 1000
self.canClosePort = True
self.initSeedPulse = 0
self.initSeedFre = 0
self.init1stCurrent = 0
self.init2stCurrent = 0
self.initSeedCurrent =0
# get the lastsave record
self.last = LastLog()
self.lastpick = self.last.loadLast()
uslast = self.lastpick.get('user',False)
print('uslast',uslast)
if uslast is False:
self.user = User()
else:
self.user = uslast
#init down machine status
self.__init__slaveStatus()
self.__initUI()
def __init__slaveStatus(self):
self.isSeedOpen = False
self.seedcurrentre = False
self.seedpulsere = False
self.seedfrequecere = False
self.seedcurrent = 0
self.seedpulse = 0
self.seedfrequece = 0
self.firstcurrent = 0
self.secondcurrent = 0
self.isFirstPumpOpen = False
self.isSecondPumpOpen = False
self.isLEDOpen = False
def __initUI(self):
'''main window box'''
self.mainBox = QVBoxLayout(self)#使用垂直布局類
self.showBox = QHBoxLayout()
self.setWindowState(Qt.WindowMaximized)
###
#command area: push button, plain text edit and line edit
###
cmd_btn = QPushButton('Send Command (ctrl+Q)')
cmd_btn.setMinimumWidth(self.buttonMinimumWidth)
cmd_btn.clicked.connect(self.emit_send_data)
#import cmd strl+enter
cmdEnterAction = QAction(self)
cmdEnterAction.setShortcut('ctrl+Q')
cmdEnterAction.setStatusTip(' press ctrl+Q to send command')
cmdEnterAction.triggered.connect(self.emit_send_data)
self.cmd_edit = QLineEdit()
self.cmd_edit.addAction(cmdEnterAction)
cmdBox = QVBoxLayout()
#message box
self.editer = QPlainTextEdit()
#.........這裏部分代碼省略.........