本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setMinimumSize方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setMinimumSize方法的具體用法?Python QLineEdit.setMinimumSize怎麽用?Python QLineEdit.setMinimumSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setMinimumSize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: EditView
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumSize [as 別名]
#.........這裏部分代碼省略.........
# Return the essence of the cursor as a tuple (pos,anc)
def get_cursor_val(self):
return (self.Editor.textCursor().position(), self.Editor.textCursor.anchor())
# Some other code likes to reposition the edit selection:
def set_cursor(self, tc):
self.Editor.setTextCursor(tc)
# Make a valid cursor based on position and anchor values possibly
# input by the user.
def make_cursor(self, position, anchor):
mx = self.document.characterCount()
tc = QTextCursor(self.Editor.textCursor())
anchor = min( max(0,anchor), mx )
position = min ( max(0,position), mx )
tc.setPosition(anchor)
tc.setPosition(position,QTextCursor.KeepAnchor)
return tc
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# INITIALIZE UI
#
# First we built the Edit panel using Qt Creator which produced a large
# and somewhat opaque block of code that had to be mixed in by
# multiple inheritance. This had several drawbacks, so the following
# is a "manual" UI setup using code drawn from the generated code.
#
def _uic(self):
# First set up the properties of "self", a QWidget.
self.setObjectName("EditViewWidget")
sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(False) # don't care to bind height to width
self.setSizePolicy(sizePolicy)
self.setMinimumSize(QSize(250, 250))
self.setFocusPolicy(Qt.StrongFocus)
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.setWindowTitle("")
self.setToolTip("")
self.setStatusTip("")
self.setWhatsThis("")
# Set up our primary widget, the editor
self.Editor = PTEditor(self,self.my_book)
self.Editor.setObjectName("Editor")
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(2) # Edit deserves all available space
sizePolicy.setVerticalStretch(2)
sizePolicy.setHeightForWidth(False)
self.Editor.setSizePolicy(sizePolicy)
self.Editor.setFocusPolicy(Qt.StrongFocus)
self.Editor.setContextMenuPolicy(Qt.NoContextMenu)
self.Editor.setAcceptDrops(True)
self.Editor.setLineWidth(2)
self.Editor.setDocumentTitle("")
self.Editor.setLineWrapMode(QPlainTextEdit.NoWrap)
# Set up the frame that will contain the bottom row of widgets
# It doesn't need a parent and doesn't need to be a class member
# because it will be added to a layout, which parents it.
bot_frame = QFrame()
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(False)
bot_frame.setSizePolicy(sizePolicy)
bot_frame.setMinimumSize(QSize(0, 24))
bot_frame.setContextMenuPolicy(Qt.NoContextMenu)
示例2: EditView
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumSize [as 別名]
#.........這裏部分代碼省略.........
# Return the essence of the cursor as a tuple (pos,anc)
def get_cursor_val(self):
return (self.Editor.textCursor().position(), self.Editor.textCursor().anchor())
# Some other code likes to reposition the edit selection:
def set_cursor(self, tc):
self.Editor.setTextCursor(tc)
# Make a valid cursor based on position and anchor values possibly
# input by the user.
def make_cursor(self, position, anchor):
mx = self.document.characterCount()
tc = QTextCursor(self.Editor.textCursor())
anchor = min( max(0,anchor), mx )
position = min ( max(0,position), mx )
tc.setPosition(anchor)
tc.setPosition(position,QTextCursor.KeepAnchor)
return tc
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# INITIALIZE UI
#
# First we built the Edit panel using Qt Creator which produced a large
# and somewhat opaque block of code that had to be mixed in by
# multiple inheritance. This had several drawbacks, so the following
# is a "manual" UI setup using code drawn from the generated code.
#
def _uic(self):
# First set up the properties of "self", a QWidget.
self.setObjectName("EditViewWidget")
sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(False) # don't care to bind height to width
self.setSizePolicy(sizePolicy)
self.setMinimumSize(QSize(250, 250))
self.setFocusPolicy(Qt.StrongFocus)
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.setWindowTitle("")
self.setToolTip("")
self.setStatusTip("")
self.setWhatsThis("")
# Set up our primary widget, the editor
self.Editor = PTEditor(self,self.my_book)
self.Editor.setObjectName("Editor")
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(2) # Edit deserves all available space
sizePolicy.setVerticalStretch(2)
sizePolicy.setHeightForWidth(False)
self.Editor.setSizePolicy(sizePolicy)
self.Editor.setFocusPolicy(Qt.StrongFocus)
self.Editor.setContextMenuPolicy(Qt.NoContextMenu)
self.Editor.setAcceptDrops(True)
self.Editor.setLineWidth(2)
self.Editor.setDocumentTitle("")
self.Editor.setLineWrapMode(QPlainTextEdit.NoWrap)
# Set up the frame that will contain the bottom row of widgets
# It doesn't need a parent and doesn't need to be a class member
# because it will be added to a layout, which parents it.
bot_frame = QFrame()
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(False)
bot_frame.setSizePolicy(sizePolicy)
bot_frame.setMinimumSize(QSize(0, 24))
bot_frame.setContextMenuPolicy(Qt.NoContextMenu)
示例3: setup_ui
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumSize [as 別名]
def setup_ui(self):
self.setObjectName("MainWindow")
self.resize(820, 760)
self.setMinimumSize(QSize(720, 560))
self.setWindowTitle("Yugioh Duelist of Roses - Deck Edit")
self.centralwidget = QWidget(self)
self.centralwidget.setObjectName("centralwidget")
self.setCentralWidget(self.centralwidget)
self.horizontalLayout = QHBoxLayout(self.centralwidget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.deck_list = QListWidget(self.centralwidget)
self.horizontalLayout.addWidget(self.deck_list)
self.vertLayoutWidget = QWidget(self.centralwidget)
self.verticalLayout = QVBoxLayout(self.vertLayoutWidget)
self.button_set_deck = QPushButton(self.centralwidget)
self.button_set_deck.setText("Set Deck")
self.leader_layoutwidget = QWidget(self.centralwidget)
self.leader_layout = QHBoxLayout(self.leader_layoutwidget)
self.leader_layoutwidget.setLayout(self.leader_layout)
self.lineedit_leader = QLineEdit(self.centralwidget)
self.leader_label = QLabel(self.centralwidget)
self.leader_layout.addWidget(self.lineedit_leader)
self.leader_layout.addWidget(self.leader_label)
self.lineedit_leader_rank = QLineEdit(self.centralwidget)
for widget in (self.button_set_deck, self.leader_layoutwidget, self.lineedit_leader_rank):
self.verticalLayout.addWidget(widget)
self.cards_scroll = QScrollArea(self.centralwidget)
self.cards_scroll.setWidgetResizable(True)
self.card_slots = []
self.cards_verticalWidget = QWidget(self.centralwidget)
self.cards_vertical = QVBoxLayout(self.centralwidget)
self.cards_verticalWidget.setLayout(self.cards_vertical)
self.cards_scroll.setWidget(self.cards_verticalWidget)
for i in range(40):
layoutwidget = QWidget(self.centralwidget)
layout = QHBoxLayout(layoutwidget)
layoutwidget.setLayout(layout)
index_text = QLabel(self.centralwidget)
index_text.setText("{0:>2}".format(i))
textedit = QLineEdit(self.centralwidget)
textedit.setMinimumSize(20, 20)
textedit.setMaximumSize(100, 5000)
card_name_text = QLabel(self.centralwidget)
card_name_text.setText("---")
card_name_text.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
layout.addWidget(index_text)
layout.addWidget(textedit)
layout.addWidget(card_name_text)
self.card_slots.append((textedit, index_text, card_name_text, layout, layoutwidget))
self.cards_vertical.addWidget(layoutwidget)
self.verticalLayout.addWidget(self.cards_scroll)
self.horizontalLayout.addWidget(self.vertLayoutWidget)
self.menubar = self.menuBar()
self.file_menu = self.menubar.addMenu("File")
self.file_menu.setObjectName("menuLoad")
self.file_load_action = QAction("Load", self)
self.file_load_action.triggered.connect(self.button_load_decks)
self.file_menu.addAction(self.file_load_action)
self.file_save_action = QAction("Save", self)
self.file_save_action.triggered.connect(self.button_save_decks)
self.file_menu.addAction(self.file_save_action)
self.statusbar = QStatusBar(self)
self.statusbar.setObjectName("statusbar")
self.setStatusBar(self.statusbar)
print("done")
示例4: PasswordDialog
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumSize [as 別名]
class PasswordDialog(QDialog):
""" Basic dialog with a textbox input field for the password/-phrase and OK/Cancel buttons """
def __init__(self, parent, message, title='Enter Password'):
"""
:param parent: The parent window/dialog used to enable modal behaviour
:type parent: :class:`gtk.Widget`
:param message: The message that gets displayed above the textbox
:type message: str
:param title: Displayed in the dialogs titlebar
:type title: str or None
"""
super(PasswordDialog, self).__init__(parent, Qt.WindowCloseButtonHint | Qt.WindowTitleHint)
self.setWindowTitle(title)
self.layout = QVBoxLayout()
self.layout.setSizeConstraint(QLayout.SetFixedSize)
self.layout.setSpacing(10)
# create icon and label
self.header_box = QHBoxLayout()
self.header_box.setSpacing(10)
self.header_box.setAlignment(Qt.AlignLeft)
self.header_text = QLabel(message)
icon = QLabel()
icon.setPixmap(QIcon.fromTheme('dialog-password', QApplication.style().standardIcon(QStyle.SP_DriveHDIcon)).pixmap(32))
self.header_box.addWidget(icon)
self.header_box.addWidget(self.header_text)
self.layout.addLayout(self.header_box)
# create the text input field
self.pw_box = QLineEdit()
self.pw_box.setMinimumSize(0, 25)
# password will not be shown on screen
self.pw_box.setEchoMode(QLineEdit.Password)
self.layout.addWidget(self.pw_box)
self.layout.addSpacing(10)
# OK and Cancel buttons
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, parent=self)
self.buttons.accepted.connect(self.on_accepted)
self.buttons.rejected.connect(self.reject)
self.layout.addWidget(self.buttons)
self.setLayout(self.layout)
self.pw_box.setFocus()
def on_accepted(self):
""" Event handler for accept signal: block when input field empty """
if self.pw_box.text() != '':
self.accept()
else:
self.pw_box.setFocus()
def get_pw(self):
""" Get pw inputfiled value, returns python unicode instead of QString in py2"""
try:
return str(self.pw_box.text())
except UnicodeEncodeError:
return unicode(self.pw_box.text().toUtf8(), encoding="UTF-8")
def get_password(self):
""" Dialog runs itself and returns the password/-phrase entered
or throws an exception if the user cancelled/closed the dialog
:returns: The entered password/-phrase
:rtype: str
:raises: UserInputError
"""
try:
if self.exec_():
return self.get_pw()
else:
raise UserInputError()
finally:
self.destroy()
示例5: EjournalApp
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setMinimumSize [as 別名]
class EjournalApp(QWidget):
"""
This app facilitates the markup of journal articles.
There are two options: Generate the markdown file and Push to Jekyll.
The first takes user input and formats a markdown file for the user to
then add additional markup to.
The second takes a directory and pushes that directory to Jekyll for
HTML generation.
"""
'''
=========Variables for journals==========
Title of Journal: journal_title
Title of Article: art_title
Journal Volume: j_vol
Journal Issue: j_issue
Season: j_ssn
Year: j_year
Filename: j_filename
Dictionary of Authors: author_dict
Article Content: content
Article References: references
'''
def __init__(self):
"""
General layout is established and the create_ui method is invoked
to initialize the app's UI
"""
super().__init__()
self.container = QVBoxLayout(self)
self.form_widget = QWidget(self)
self.form_layout = QFormLayout()
self.layout = QVBoxLayout(self.form_widget)
self.init_gui = 0
self.setWindowTitle("Ejournal Editor")
self.create_ui()
def clear_layout_except(self, opt_removal=""):
"""
Clears the UI of every object except for the object passed in as
a param.
If no object is passed in, it clears everything.
"""
# clear the widgets that may be on the form_layout and btn_container
if opt_removal == '':
for i in reversed(range(self.form_layout.count())):
self.form_layout.itemAt(i).widget().deleteLater()
for i in reversed(range(self.btn_container.count())):
if self.btn_container.itemAt(i).widget() is None:
continue
else:
self.btn_container.itemAt(i).widget().deleteLater()
else:
for i in reversed(range(self.form_layout.count())):
if self.form_layout.itemAt(i).widget().whatsThis() == \
opt_removal:
continue
else:
self.form_layout.itemAt(i).widget().deleteLater()
def generate_md(self):
"""
This method is invoked after the user has entered the references.
It creates a MDGenerator Class object and invokes its
generate_md_file method, which creates the Markdown
file.
"""
self.references = self.ref_tb.toPlainText()
j_file_generator = MdGenerator(self.journal_title, self.art_title,
self.j_vol, self.j_issue, self.j_ssn, self.j_year, self.j_filename,
self.author_dict, self.content, self.references)
j_file_generator.generate_md_file()
notice = QMessageBox.information(self,
'Notice', "{}.md was created".format(self.j_filename.lower()),
QMessageBox.Ok)
def add_ref(self):
"""
This method generates a text area in which the user will input the
article's references
"""
# Sets the content to a global variable
self.content = self.content_tb.toPlainText()
self.clear_layout_except("back_btn")
# instructions for the user on signifiers for the MDGenerator class
ref_lb = QLabel("""Copy and paste references below.\n\n
Formatting Key:\n\n
Reference:\t\tr[*]]
""")
self.ref_tb = QTextEdit()
self.ref_tb.setAcceptRichText(True)
self.ref_tb.setMinimumSize(400, 400)
submit_btn = QPushButton("Submit and Generate MD File")
submit_btn.clicked.connect(self.generate_md)
#.........這裏部分代碼省略.........