本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.font方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.font方法的具體用法?Python QLineEdit.font怎麽用?Python QLineEdit.font使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.font方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: box
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import font [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
示例2: TabSearch
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import font [as 別名]
class TabSearch(_ScrollGroup):
"""Custom tab widget."""
def __init__(self, parent=None, *args, **kwargs):
"""Init class custom tab widget."""
super(TabSearch, self).__init__(self, *args, **kwargs)
self.parent = parent
self.setParent(parent)
list1 = [_ for _ in UNICODEMOTICONS.values() if isinstance(_, str)]
list2 = [_[1] for _ in entities.html5.items()]
self.emos = tuple(sorted(set(list1 + list2)))
# Timer to start
self.timer = QTimer(self)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self._make_search_unicode)
self.search, layout = QLineEdit(self), self.layout()
self.search.setPlaceholderText(" Search Unicode . . .")
font = self.search.font()
font.setPixelSize(25)
font.setBold(True)
self.search.setFont(font)
self.search.setFocus()
self.search.textChanged.connect(self._go)
layout.addWidget(self.search)
self.container, self.searchbutons, row, index = QWidget(self), [], 0, 0
self.container.setLayout(QGridLayout())
layout.addWidget(self.container)
for i in range(50):
button = QPushButton("?", self)
button.released.connect(self.hide)
button.setFlat(True)
button.setDisabled(True)
font = button.font()
font.setPixelSize(25)
button.setFont(font)
index = index + 1 # cant use enumerate()
row = row + 1 if not index % 8 else row
self.searchbutons.append(button)
self.container.layout().addWidget(button, row, index % 8)
def _go(self):
"""Run/Stop the QTimer."""
if self.timer.isActive():
self.timer.stop()
return self.timer.start(1000)
def _make_search_unicode(self):
"""Make a search for Unicode Emoticons."""
search = str(self.search.text()).lower().strip()
if search and len(search):
found_exact = [_ for _ in self.emos if search in _]
found_by_name = []
for emoticons_list in self.emos:
for emote in emoticons_list:
emojiname = str(self.parent.get_description(emote)).lower()
if search in emojiname and len(emojiname):
found_by_name += emote
results = tuple(sorted(set(found_exact + found_by_name)))[:50]
for emoji, button in zip(results, self.searchbutons):
button.setText(emoji)
button.pressed.connect(lambda ch=emoji:
self.parent.make_preview(ch))
button.clicked.connect(
lambda _, ch=emoji: QApplication.clipboard().setText(ch))
button.setToolTip("<center><h1>{0}<br>{1}".format(
emoji, self.parent.get_description(emoji)))
button.setDisabled(False)
return results
示例3: Calculator
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import font [as 別名]
class Calculator(QWidget):
NumDigitButtons = 10
def __init__(self, parent=None):
super(Calculator, self).__init__(parent)
self.pendingAdditiveOperator = ''
self.pendingMultiplicativeOperator = ''
self.sumInMemory = 0.0
self.sumSoFar = 0.0
self.factorSoFar = 0.0
self.waitingForOperand = True
self.display = QLineEdit('0')
self.display.setReadOnly(True)
self.display.setAlignment(Qt.AlignRight)
self.display.setMaxLength(15)
font = self.display.font()
font.setPointSize(font.pointSize() + 8)
self.display.setFont(font)
self.digitButtons = []
for i in range(Calculator.NumDigitButtons):
self.digitButtons.append(self.createButton(str(i),
self.digitClicked))
self.pointButton = self.createButton(".", self.pointClicked)
self.changeSignButton = self.createButton(u"\N{PLUS-MINUS SIGN}",
self.changeSignClicked)
self.backspaceButton = self.createButton("Backspace",
self.backspaceClicked)
self.clearButton = self.createButton("Clear", self.clear)
self.clearAllButton = self.createButton("Clear All", self.clearAll)
self.clearMemoryButton = self.createButton("MC", self.clearMemory)
self.readMemoryButton = self.createButton("MR", self.readMemory)
self.setMemoryButton = self.createButton("MS", self.setMemory)
self.addToMemoryButton = self.createButton("M+", self.addToMemory)
self.divisionButton = self.createButton(u"\N{DIVISION SIGN}",
self.multiplicativeOperatorClicked)
self.timesButton = self.createButton(u"\N{MULTIPLICATION SIGN}",
self.multiplicativeOperatorClicked)
self.minusButton = self.createButton("-", self.additiveOperatorClicked)
self.plusButton = self.createButton("+", self.additiveOperatorClicked)
self.squareRootButton = self.createButton("Sqrt",
self.unaryOperatorClicked)
self.powerButton = self.createButton(u"x\N{SUPERSCRIPT TWO}",
self.unaryOperatorClicked)
self.reciprocalButton = self.createButton("1/x",
self.unaryOperatorClicked)
self.equalButton = self.createButton("=", self.equalClicked)
mainLayout = QGridLayout()
mainLayout.setSizeConstraint(QLayout.SetFixedSize)
mainLayout.addWidget(self.display, 0, 0, 1, 6)
mainLayout.addWidget(self.backspaceButton, 1, 0, 1, 2)
mainLayout.addWidget(self.clearButton, 1, 2, 1, 2)
mainLayout.addWidget(self.clearAllButton, 1, 4, 1, 2)
mainLayout.addWidget(self.clearMemoryButton, 2, 0)
mainLayout.addWidget(self.readMemoryButton, 3, 0)
mainLayout.addWidget(self.setMemoryButton, 4, 0)
mainLayout.addWidget(self.addToMemoryButton, 5, 0)
for i in range(1, Calculator.NumDigitButtons):
row = ((9 - i) / 3) + 2
column = ((i - 1) % 3) + 1
mainLayout.addWidget(self.digitButtons[i], row, column)
mainLayout.addWidget(self.digitButtons[0], 5, 1)
mainLayout.addWidget(self.pointButton, 5, 2)
mainLayout.addWidget(self.changeSignButton, 5, 3)
mainLayout.addWidget(self.divisionButton, 2, 4)
mainLayout.addWidget(self.timesButton, 3, 4)
mainLayout.addWidget(self.minusButton, 4, 4)
mainLayout.addWidget(self.plusButton, 5, 4)
mainLayout.addWidget(self.squareRootButton, 2, 5)
mainLayout.addWidget(self.powerButton, 3, 5)
mainLayout.addWidget(self.reciprocalButton, 4, 5)
mainLayout.addWidget(self.equalButton, 5, 5)
self.setLayout(mainLayout)
self.setWindowTitle("Calculator")
def digitClicked(self):
clickedButton = self.sender()
digitValue = int(clickedButton.text())
if self.display.text() == '0' and digitValue == 0.0:
return
#.........這裏部分代碼省略.........
示例4: Main
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import font [as 別名]
class Main(QWidget):
countlength = 0
wordslist = []
typing = ''
typeracermode = False
error = 'errorsound.mp3'
success = 'success.wav'
running = True
length = 0
threads = []
count = 0
counter = 0
errorcount = 0
name = None
password = None
trycount = 0
before = ''
def __init__(self):
super().__init__()
self.disp = QPushButton()
self.disp.hide()
self.disp.clicked.connect(self.displayall)
self.initUI()
def initUI(self):
self.label = QLabel(self)
pixmap = QPixmap('logo.png')
pixmap = pixmap.scaledToWidth(200)
self.label.setPixmap(pixmap)
self.lay = QVBoxLayout()
self.label.setAlignment(Qt.AlignCenter)
self.hor = QHBoxLayout()
# self.lay.setContentsMargins(-1,-1,-1,0)
self.Hbox = QHBoxLayout()
# self.Hbox.addStretch(1)
# self.hor.setAlignment(Qt.AlignCenter)
# self.lay.addLayout(self.hor)
self.setStyleSheet('QWidget {background-color:white;border:none}')
# self.label.setStyleSheet('Q {width:50px;height:auto}')
self.height = 60
self.trycount = 0
self.setGeometry(300, 150, 400, 600)
self.setWindowTitle('Welcome')
self.nameline = QLineEdit()
self.passwordline = QLineEdit()
self.nameline.setPlaceholderText("Username...")
self.passwordline.setPlaceholderText("Password...")
self.passwordline.setEchoMode(QLineEdit.Password)
self.nameline.setStyleSheet('QLineEdit {background-color:#EEE;height:40;border-radius:3px;font-family:Arial;padding:6px}')
self.passwordline.setStyleSheet('QLineEdit {background-color:#EEE;height:40;border-radius:3px;font-family:Arial;padding:6px;}')
self.status = QLabel()
self.status.setStyleSheet("color:red")
self.lay.addStretch(1)
self.lay.addWidget(self.label)
self.lay.addStretch(1)
self.lay.addWidget(self.nameline)
self.lay.addWidget(self.passwordline)
self.lay.addWidget(self.status)
self.lay.setAlignment(self.nameline, Qt.AlignBottom)
self.lay.addLayout(self.Hbox)
# self.lay.addStretch(1)
self.signin = QPushButton('Sign in')
self.signup = QPushButton('Sign up')
self.signin.setStyleSheet('QPushButton {background-color:#4990E2;color:white;height:50;font-size:20px;border-radius:3px;font-family:Arial;}')
self.signup.setStyleSheet('QPushButton {background-color:#7FDC89;color:white;height:50;font-size:20px;border-radius:3px;font-family:Arial;}')
self.signin.clicked.connect(self.authentification)
self.signup.clicked.connect(self.authentification)
self.Hbox.addWidget(self.signin)
self.Hbox.addWidget(self.signup)
self.setLayout(self.lay)
self.show()
def authentification(self):
sender = self.sender()
self.name = self.nameline.text()
password = self.passwordline.text()
if self.name == "" and password == "":
self.status.setText('Type something')
else:
self.password = hashlib.md5(password.encode('utf-8')).hexdigest()
if self.trycount == 0:
self.socket = socket()
global SERVER_ADDRESS
self.socket.connect((SERVER_ADDRESS, 9090))
self.trycount += 1
sendlist = [sender.text(), self.name, self.password]
req = pickle.dumps(sendlist)
self.socket.send(req)
response = self.socket.recv(2048)
#.........這裏部分代碼省略.........