本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setAlignment方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setAlignment方法的具體用法?Python QLineEdit.setAlignment怎麽用?Python QLineEdit.setAlignment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setAlignment方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: LoggingToolbar
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [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: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [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例子")
示例3: addStatControl
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
def addStatControl(self,i,label=None):
statbox = QHBoxLayout()
statbox.addSpacing(1)
statbox.setSpacing(0)
statbox.setAlignment(Qt.AlignCenter)
statlabel = QLabel(self.stats[i] if label is None else label)
statlabel.setContentsMargins(0,0,0,0)
statlabel.setAlignment(Qt.AlignCenter)
statlabel.setFixedWidth(20)
statbox.addWidget(statlabel)
statcontrol = QLineEdit()
statcontrol.setAlignment(Qt.AlignCenter)
statcontrol.setFixedWidth(40)
statcontrol.setText(str(self.skill.multipliers[i]))
v = QDoubleValidator(0,99,3,statcontrol)
v.setNotation(QDoubleValidator.StandardNotation)
#v.setRange(0,100,decimals=3)
statcontrol.setValidator(v)
#print(v.top())
def statFuncMaker(j):
def statFunc(newValue):
self.skill.multipliers[j] = float(newValue)
self.skillsChanged.emit()
return statFunc
statcontrol.textChanged[str].connect(statFuncMaker(i))
statbox.addWidget(statcontrol)
statbox.addSpacing(1)
self.layout.addLayout(statbox)
示例4: NetworkToolbar
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [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()
示例5: _create_text_edit
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [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
示例6: createEditor
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
def createEditor(self, parent, option, index):
self.updateRects(option, index)
bgColor = self.bgColors.get(index, "white")
if self.mainLineRect.contains(self.lastPos):
# One line summary
self.editing = Outline.summarySentence
edt = QLineEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrame(False)
f = QFont(option.font)
if self.newStyle():
f.setBold(True)
else:
f.setItalic(True)
edt.setAlignment(Qt.AlignCenter)
edt.setPlaceholderText(self.tr("One line summary"))
edt.setFont(f)
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
return edt
elif self.titleRect.contains(self.lastPos):
# Title
self.editing = Outline.title
edt = QLineEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrame(False)
f = QFont(option.font)
if self.newStyle():
f.setPointSize(f.pointSize() + 4)
else:
edt.setAlignment(Qt.AlignCenter)
f.setBold(True)
edt.setFont(f)
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
# edt.setGeometry(self.titleRect)
return edt
else: # self.mainTextRect.contains(self.lastPos):
# Summary
self.editing = Outline.summaryFull
edt = QPlainTextEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrameShape(QFrame.NoFrame)
try:
# QPlainTextEdit.setPlaceholderText was introduced in Qt 5.3
edt.setPlaceholderText(self.tr("Full summary"))
except AttributeError:
pass
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
return edt
示例7: Header
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
class Header(QHeaderView):
def __init__(self, orientation=Qt.Horizontal, parent=None):
super(Header, self).__init__(orientation, parent)
self.editable = True
self.setSectionsClickable(True)
self.setSectionResizeMode(QHeaderView.ResizeToContents)
self.line = QLineEdit(parent=self.viewport())
self.line.setAlignment(Qt.AlignTop)
self.line.setHidden(True)
self.line.blockSignals(True)
self.col = 0
# Connections
self.sectionDoubleClicked[int].connect(self.__edit)
self.line.editingFinished.connect(self.__done_editing)
def __edit(self, index):
if not self.editable:
return
geo = self.line.geometry()
geo.setWidth(self.sectionSize(index))
geo.moveLeft(self.sectionViewportPosition(index))
current_text = self.model().headerData(index, Qt.Horizontal,
Qt.DisplayRole)
self.line.setGeometry(geo)
self.line.setHidden(False)
self.line.blockSignals(False)
self.line.setText(str(current_text))
self.line.setFocus()
self.line.selectAll()
self.col = index
def __done_editing(self):
text = self.line.text()
if not text.strip():
# No debe ser vacío
QMessageBox.critical(self, "Error",
self.tr("El campo no debe ser vacío"))
self.line.hide()
return
self.line.blockSignals(True)
self.line.setHidden(False)
self.model().setHeaderData(self.col, Qt.Horizontal, text,
Qt.DisplayRole)
self.line.setText("")
self.line.hide()
self.setCurrentIndex(QModelIndex())
示例8: createEditor
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
def createEditor(self, parent, option, index):
self.updateRects(option, index)
if self.mainLineRect.contains(self.lastPos):
# One line summary
self.editing = Outline.summarySentence
edt = QLineEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrame(False)
edt.setAlignment(Qt.AlignCenter)
edt.setPlaceholderText(self.tr("One line summary"))
f = QFont(option.font)
f.setItalic(True)
edt.setFont(f)
return edt
elif self.titleRect.contains(self.lastPos):
# Title
self.editing = Outline.title
edt = QLineEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrame(False)
f = QFont(option.font)
# f.setPointSize(f.pointSize() + 1)
f.setBold(True)
edt.setFont(f)
edt.setAlignment(Qt.AlignCenter)
# edt.setGeometry(self.titleRect)
return edt
else: # self.mainTextRect.contains(self.lastPos):
# Summary
self.editing = Outline.summaryFull
edt = QPlainTextEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrameShape(QFrame.NoFrame)
try:
# QPlainTextEdit.setPlaceholderText was introduced in Qt 5.3
edt.setPlaceholderText(self.tr("Full summary"))
except AttributeError:
pass
return edt
示例9: InputWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
class InputWidget(QFrame):
"""
Input contains QLabel and QLineEdit.
Represents single attribute in CalculableObject object.
Does not show private attributes that starts from '_'
"""
def __init__(self, parent, main_window, label_text):
super().__init__()
# if label_text.startswith('_'):
# return
self.label_text = label_text
self.input = QLineEdit()
main_window.communication.clean_items.connect(self.clean)
hbox = QHBoxLayout()
self.setLayout(hbox)
hbox.addWidget(QLabel(_(label_text)))
hbox.addStretch()
self.input.setAlignment(Qt.AlignRight)
# self.input.setFixedWidth(190)
self.input.textEdited.connect(functools.partial(parent.input_changed, label_text))
self.setGraphicsEffect(utils.get_shadow())
hbox.addWidget(self.input)
def set_value(self, value):
if value:
self.input.setText(str(value))
def clean(self):
self.input.setText('')
def mousePressEvent(self, event):
self.input.setFocus()
示例10: createEditor
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
def createEditor(self, parent_qw: QWidget,
option: QStyleOptionViewItem,
model_index: QModelIndex):
column = model_index.column()
if column == NAME_COL: # Model name
item = self.parent().itemFromIndex(model_index)
if item.CAN_NAME_EDIT:
editor = QLineEdit(parent_qw)
editor.setAlignment(Qt.AlignVCenter)
return editor
elif column == 1: # Visibility checkbox
# editor = QCheckBox(parent_qw)
# setAlignment doesn't work https://bugreports.qt-project.org/browse/QTBUG-5368
# return editor
return None
elif column == COLOR_COL: # Color Picker
editor = QColorDialog(parent_qw)
return editor
else:
return QStyledItemDelegate.createEditor(self,
parent_qw,
option,
model_index)
示例11: Header
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
class Header(QHeaderView):
def __init__(self, orientation=Qt.Horizontal, parent=None):
super(Header, self).__init__(orientation, parent)
self.setSectionsClickable(True)
self.setSectionResizeMode(QHeaderView.ResizeToContents)
self.line = QLineEdit(parent=self.viewport())
self.line.setAlignment(Qt.AlignTop)
self.line.setHidden(True)
self.line.blockSignals(True)
self.col = 0
# Connections
self.sectionDoubleClicked[int].connect(self.__edit)
self.line.editingFinished.connect(self.__done_editing)
def __edit(self, index):
geo = self.line.geometry()
geo.setWidth(self.sectionSize(index))
geo.moveLeft(self.sectionViewportPosition(index))
current_text = self.model().headerData(index, Qt.Horizontal)
self.line.setGeometry(geo)
self.line.setHidden(False)
self.line.blockSignals(False)
self.line.setText(str(current_text))
self.line.setFocus()
self.line.selectAll()
self.col = index
def __done_editing(self):
self.line.blockSignals(True)
self.line.setHidden(False)
text = self.line.text()
self.model().setHeaderData(self.col, Qt.Horizontal, text)
self.line.setText("")
self.line.hide()
self.setCurrentIndex(QModelIndex())
示例12: AimAssist
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
class AimAssist(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
# Buttons:
BTN_H = 20
BTN_W = 80
BUTTON_COL = 0
LABEL_COL1 = 1
DATA_COL = 2
RADIO_COL = 3
grid = QGridLayout()
self.setLayout(grid)
# Buttons:
acq = QPushButton("&ACK", self)
acq.clicked.connect(self.drawRect)
grid.addWidget(acq, 0, BUTTON_COL)
calc = QPushButton("&Calc", self)
calc.clicked.connect(self.solve_tank)
grid.addWidget(calc, 1, BUTTON_COL)
# Radio buttons:
settings = QLabel("Shot Type:")
grid.addWidget(settings, 0, RADIO_COL)
# settings.setAlignment(Qt.AlignBottom)
self.radNorm = QRadioButton("&Normal")
self.radNorm.setChecked(True)
grid.addWidget(self.radNorm, 1, RADIO_COL)
self.radHover = QRadioButton("&Hover (Post hang only)")
grid.addWidget(self.radHover, 2, RADIO_COL)
self.radDig = QRadioButton("&Digger")
grid.addWidget(self.radDig, 3, RADIO_COL)
# Text areas (with labels):
# Width
self.wbox = QSpinBox(self)
grid.addWidget(self.wbox, 0, DATA_COL)
self.wbox.setMaximum(1000)
self.wbox.setMinimum(-1000)
wlabel = QLabel("Width:")
grid.addWidget(wlabel, 0, LABEL_COL1)
wlabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
# Height
self.hbox = QSpinBox(self)
grid.addWidget(self.hbox, 1, DATA_COL)
self.hbox.setMaximum(1000)
self.hbox.setMinimum(-1000)
hlabel = QLabel("Height:")
grid.addWidget(hlabel, 1, LABEL_COL1)
hlabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
# Wind
self.windbox = QSpinBox(self)
grid.addWidget(self.windbox, 2, DATA_COL)
self.windbox.setMaximum(30)
self.windbox.setMinimum(-30)
windlabel = QLabel("Wind:")
grid.addWidget(windlabel, 2, LABEL_COL1)
windlabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
# Angle
self.anglebox = QSpinBox(self)
grid.addWidget(self.anglebox, 3, DATA_COL)
self.anglebox.setMaximum(359)
self.anglebox.setMinimum(0)
self.anglebox.setValue(45)
self.anglebox.setWrapping(True)
angleLabel = QLabel("<i>θ</i>(0-259):")
grid.addWidget(angleLabel, 3, LABEL_COL1)
angleLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
# Power out:
self.vbox = QLineEdit("Power")
self.vbox.setStyleSheet("color: #ff0000")
grid.addWidget(self.vbox, 2, BUTTON_COL)
self.vbox.setAlignment(Qt.AlignRight)
self.vbox.setReadOnly(True)
self.move(50, 50)
self.setWindowTitle('Aim Assistant')
self.show()
# self.setWindowFlags(Qt.WindowStaysOnTopHint)
def setWH(self, rectw, recth):
self.wbox.setValue(int(rectw))
self.hbox.setValue(int(recth))
self.solve_tank()
def drawRect(self):
self.lower()
pair = Popen(["./deathmeasure"], stdout=PIPE).communicate()[0].decode('utf-8').split()
self.setWH(pair[0], pair[1])
# self.show()
# self.setWindowFlags(Qt.WindowStaysOnTopHint)
def keyPressEvent(self, e):
if e.key() == Qt.Key_Escape or e.key() == Qt.Key_Q:
self.close()
#.........這裏部分代碼省略.........
示例13: EditView
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
#.........這裏部分代碼省略.........
bot_frame.setContextMenuPolicy(Qt.NoContextMenu)
bot_frame.setFrameShape(QFrame.Panel)
bot_frame.setFrameShadow(QFrame.Sunken)
bot_frame.setLineWidth(3)
# Set up the horizontal layout that will contain the following
# objects. Its parent is the frame, which gives it a look?
HBL = QHBoxLayout(bot_frame)
HBL.setContentsMargins(4,2,4,2)
# Set up DocName, the document name widget. It is parented
# to the bot_frame and positioned by the layout.
self.DocName = QLabel(bot_frame)
self.DocName.setText("")
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(2)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(False)
self.DocName.setSizePolicy(sizePolicy)
self.DocName.setMinimumSize(QSize(60, 12))
self.DocName.setContextMenuPolicy(Qt.NoContextMenu)
self.DocName.setFrameShape(QFrame.StyledPanel)
self.DocName.setObjectName("DocName")
self.DocName.setToolTip(_TR("EditViewWidget", "Document filename", "tool tip"))
self.DocName.setWhatsThis(_TR("EditViewWidget", "The filename of the document being edited. It changes color when the document has been modified."))
HBL.addWidget(self.DocName)
spacerItem = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
HBL.addItem(spacerItem)
# Set up the label "Folio:" and the Folio display label
FolioLabel = QLabel(bot_frame)
FolioLabel.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
FolioLabel.setText(_TR("EditViewWidget", "Folio", "label of folio display"))
HBL.addWidget(FolioLabel)
self.Folio = QLabel(bot_frame)
sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(False)
self.Folio.setSizePolicy(sizePolicy)
self.Folio.setMinimumSize(QSize(30, 12))
self.Folio.setContextMenuPolicy(Qt.NoContextMenu)
self.Folio.setFrameShape(QFrame.StyledPanel)
self.Folio.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter )
self.Folio.setObjectName("Folio display")
self.Folio.setToolTip(_TR("EditViewWidget", "Folio value for current page", "tooltip"))
self.Folio.setStatusTip(_TR("EditViewWidget", "Folio value for the page under the edit cursor", "statustip"))
self.Folio.setWhatsThis(_TR("EditViewWidget", "The Folio (page number) value for the page under the edit cursor. Use the Pages panel to adjust folios to agree with the printed book.","whats this"))
HBL.addWidget(self.Folio)
spacerItem = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
HBL.addItem(spacerItem)
FolioLabel.setBuddy(self.Folio)
# Set up the image filename lineedit and its buddy label.
ImageFilenameLabel = QLabel(bot_frame)
ImageFilenameLabel.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter )
ImageFilenameLabel.setText(_TR("EditViewWidget", "Image", "Image field label"))
HBL.addWidget(ImageFilenameLabel)
self.ImageFilename = QLineEdit(bot_frame)
sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Fixed )
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(False)
示例14: MetadataDialog
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
class MetadataDialog(QDialog):
METADATA_INFO = ['artist', 'title', 'album', 'albumartist', 'composer',
'grouping', 'genre', 'comment', 'track_number',
'disc_number', 'date']
def __init__(self, available_metadata, parent=None):
super(MetadataDialog, self).__init__(parent)
self.available_metadata = available_metadata
self.setLabels()
self.setEdits(self.available_metadata)
self.initUi()
def setLabels(self):
self.artistLabel = QLabel()
self.artistLabel.setText("Artist Name:")
self.artistLabel.setAlignment(QtCore.Qt.AlignLeft)
self.titleLabel = QLabel()
self.titleLabel.setText("Song Title:")
self.titleLabel.setAlignment(QtCore.Qt.AlignLeft)
self.albumLabel = QLabel()
self.albumLabel.setText("Album Name:")
self.albumLabel.setAlignment(QtCore.Qt.AlignLeft)
self.albumArtistLabel = QLabel()
self.albumArtistLabel.setText("Album Artist:")
self.albumArtistLabel.setAlignment(QtCore.Qt.AlignLeft)
self.composerLabel = QLabel()
self.composerLabel.setText("Composer:")
self.composerLabel.setAlignment(QtCore.Qt.AlignLeft)
self.groupingLabel = QLabel()
self.groupingLabel.setText("Grouping:")
self.groupingLabel.setAlignment(QtCore.Qt.AlignLeft)
self.genreLabel = QLabel()
self.genreLabel.setText("Genre:")
self.genreLabel.setAlignment(QtCore.Qt.AlignLeft)
self.commentLabel = QLabel()
self.commentLabel.setText("Comment:")
self.commentLabel.setAlignment(QtCore.Qt.AlignLeft)
self.trackNumberLabel = QLabel()
self.trackNumberLabel.setText("Track Number:")
self.trackNumberLabel.setAlignment(QtCore.Qt.AlignLeft)
self.discNumberLabel = QLabel()
self.discNumberLabel.setText("Disc number:")
self.discNumberLabel.setAlignment(QtCore.Qt.AlignLeft)
self.yearLabel = QLabel()
self.yearLabel.setText("Year:")
self.yearLabel.setAlignment(QtCore.Qt.AlignLeft)
def setEdits(self, info_dict):
self.artistLineEdit = QLineEdit()
self.artistLineEdit.setText(
self.__safeMetadataCall(info_dict, 'artist', 0))
self.artistLineEdit.setAlignment(QtCore.Qt.AlignLeft)
self.titleLineEdit = QLineEdit()
self.titleLineEdit.setText(
self.__safeMetadataCall(info_dict, 'title', 0))
self.titleLineEdit.setAlignment(QtCore.Qt.AlignLeft)
self.albumLineEdit = QLineEdit()
self.albumLineEdit.setText(
self.__safeMetadataCall(info_dict, 'album', 0))
self.albumLineEdit.setAlignment(QtCore.Qt.AlignLeft)
self.albumArtistLineEdit = QLineEdit()
self.albumArtistLineEdit.setText(
self.__safeMetadataCall(info_dict, 'albumartist', 0))
self.albumArtistLineEdit.setAlignment(QtCore.Qt.AlignLeft)
self.composerLineEdit = QLineEdit()
self.composerLineEdit.setText(
self.__safeMetadataCall(info_dict, 'composer', 0))
self.composerLineEdit.setAlignment(QtCore.Qt.AlignLeft)
self.groupingLineEdit = QLineEdit()
self.groupingLineEdit.setText(
self.__safeMetadataCall(info_dict, 'grouping', 0))
self.groupingLineEdit.setAlignment(QtCore.Qt.AlignLeft)
self.genreLineEdit = QLineEdit()
self.genreLineEdit.setText(
self.__safeMetadataCall(info_dict, 'genre', 0))
self.genreLineEdit.setAlignment(QtCore.Qt.AlignLeft)
self.trackNumberLineEdit = QLineEdit()
self.trackNumberLineEdit.setText(
self.__safeMetadataCall(info_dict, 'track_number', 0))
self.trackNumberLineEdit.setAlignment(QtCore.Qt.AlignLeft)
self.discNumberLineEdit = QLineEdit()
#.........這裏部分代碼省略.........
示例15: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAlignment [as 別名]
#.........這裏部分代碼省略.........
if status_tip is not None:
action.setStatusTip(status_tip)
if whats_this is not None:
action.setWhatsThis(whats_this)
if add_to_toolbar:
self.toolbar.addAction(action)
if add_to_menu:
self.iface.addPluginToMenu(
self.menu,
action)
self.actions.append(action)
return action
def initGui(self):
"""Create the menu entries and toolbar icons inside the QGIS GUI."""
icon_path = ':/plugins/zoom_to_postcode/icon.png'
self.add_action(
icon_path,
text=self.tr(u'Zoom to postcode'),
callback=self.run,
parent=self.iface.mainWindow())
# Configure toolbar widget
self.toolbar = self.iface.addToolBar("Zoom To Postcode Toolbar")
self.toolbar.setObjectName("Zoom To Postcode Toolbar")
self.toolbar_search = QLineEdit()
self.toolbar_search.setMaximumWidth(100)
self.toolbar_search.setAlignment(Qt.AlignLeft)
self.toolbar_search.setPlaceholderText("Enter postcode...")
self.toolbar.addWidget(self.toolbar_search)
self.toolbar_search.returnPressed.connect(self.check_pkl)
self.search_btn = QAction(QIcon(":/plugins/zoomtopostcode/zoomicon.png"), "Search", self.iface.mainWindow())
self.search_btn.triggered.connect(self.check_pkl)
self.toolbar.addActions([self.search_btn])
# Create action that will start plugin configuration
self.action = QAction(QIcon(":/plugins/zoomtopostcode/zoomicon.png"), u"Zoom to Postcode",
self.iface.mainWindow())
self.action.triggered.connect(self.toolbar.show)
self.licence = QAction(u"OS Licence", self.iface.mainWindow())
self.licence.triggered.connect(self.licence_dlg.show)
# Add toolbar button and menu item
self.iface.addPluginToMenu(u"&Zoom to Postcode", self.action)
self.iface.addPluginToMenu(u"&Zoom to Postcode", self.licence)
def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
for action in self.actions:
self.iface.removePluginMenu(
self.tr(u'&Zoom To Postcode'),
action)
self.iface.removeToolBarIcon(action)
# remove the toolbar
del self.toolbar
def run(self):