當前位置: 首頁>>代碼示例>>Python>>正文


Python QLineEdit.setFont方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setFont方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setFont方法的具體用法?Python QLineEdit.setFont怎麽用?Python QLineEdit.setFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QLineEdit的用法示例。


在下文中一共展示了QLineEdit.setFont方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [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例子")
開發者ID:kiorry,項目名稱:PYQT,代碼行數:29,代碼來源:qt04_lineEdit04.py

示例2: initUI

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]
	def initUI(self):

		# self.setStyleSheet( "background-color : grey")
		researchLabel = QLabel('Player Name')
		researchLabel.setFont( QFont("Fira Mono Bold", 11))
		researchLabel.adjustSize()
		resultsLabel = QLabel('Search results')
		resultsLabel.setFont( QFont("Fira Mono Bold", 11))
		resultsLabel.adjustSize()

		researchEdit = QLineEdit()
		researchEdit.setStyleSheet( "border : 2px solid #75FF6961; border-radius : 5px; background-color : #cbcbcb")
		researchEdit.setFont( QFont("Fira Mono Bold",12))
		researchEdit.returnPressed.connect(self.newResearch)

		grid = QGridLayout()
		grid.setSpacing(4)
		grid.addWidget(researchLabel, 1, 0)
		grid.addWidget(researchEdit, 1, 1)
		grid.addWidget(resultsLabel, 2, 0)
		self.setLayout(grid)
		# self.setGeometry(100, 100, 1000, 400)
		self.setWindowTitle('Player Searcher')
		self.show()

		self.researchEdit = researchEdit
		self.grid = grid
開發者ID:vnherdeiro,項目名稱:transfermarkt-api,代碼行數:29,代碼來源:guiSearch.py

示例3: LibrariesDialog

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]
class LibrariesDialog(QDialog):
    librariesChanged = pyqtSignal(list)

    def __init__(self, name, libraries):
        super(QDialog, self).__init__()
        self.setWindowTitle(name)
        self.resize(300, 100)
        self.libraries = libraries
        self.libraryNameEdit = None
        self.addButton = None

        self.drawWindow()

    def drawWindow(self):
        if self.layout() is not None:
            tempWidget = QWidget()
            tempWidget.setLayout(self.layout())

        gridLayout = QGridLayout()

        # add header
        gridLayout.addWidget(QLabel('Libraries'), 0, 0)
        gridLayout.addWidget(QLabel(''), 0, 1)

        # add new library edit box
        self.libraryNameEdit = QLineEdit()
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.libraryNameEdit.setFont(fixedWidthFont)
        gridLayout.addWidget(self.libraryNameEdit, 1, 0)
        self.addButton = QPushButton('Add')
        self.addButton.clicked.connect(self.addClicked)
        gridLayout.addWidget(self.addButton, 1, 1)

        self.buttons = {}

        row = 2
        for lib in self.libraries:
            gridLayout.addWidget(QLabel(lib), row, 0)
            deleteButton = QPushButton()
            deleteButton.setObjectName(lib)
            deleteButton.setText('Delete')
            deleteButton.clicked.connect(self.deleteButtonClicked)
            gridLayout.addWidget(deleteButton, row, 1)
            row += 1
            self.buttons[deleteButton] = lib

        self.resize(300, 100)
        self.setLayout(gridLayout)


    def deleteButtonClicked(self):
        self.libraries.remove(self.sender().objectName())
        self.drawWindow()
        self.librariesChanged.emit(self.libraries)

    def addClicked(self):
        self.libraries.append(self.libraryNameEdit.text())
        self.drawWindow()
        self.librariesChanged.emit(self.libraries)
開發者ID:Diegojnb,項目名稱:JdeRobot,代碼行數:61,代碼來源:librariesdialog.py

示例4: init_ui

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]
	def init_ui(self):
		grid = QGridLayout() # 創建網格布局

		label01 = QLabel('=標識位=')
		label02 = QLabel('頭:消息ID')
		label03 = QLabel('頭:消息體屬性(長度)')
		label04 = QLabel('頭:終端手機號')
		label05 = QLabel('頭:消息流水號')
		label06 = QLabel('頭:消息包封裝項(默認空)')
		label07 = QLabel('校驗碼')
		label08 = QLabel('=標識位=')
		self.labels = [label01, label02, label03, label04, label05, label06, label07, label08]

		edit01 = QLineEdit('7E') # '標識位'
		edit01.setEnabled(False)
		edit02 = QLineEdit('00 02') # '消息ID'
		edit02.setEnabled(False)
		edit03 = QLineEdit('00 00') # '消息體屬性(長度)'
		edit03.setEnabled(False)
		edit04 = QLineEdit('01 20 00 18 71 48') # '終端手機號'
		edit05 = QLineEdit('00 03') # '消息流水號'
		edit05.setFont(QFont("宋體",9,QFont.Bold))
		edit06 = QLineEdit() # '消息包封裝項'
		edit07 = QLineEdit() # '校驗碼'
		edit08 = QLineEdit('7E') # '標識位'
		self.edits = [edit01, edit02, edit03, edit04, edit05, edit06, edit07, edit08]

		# 添加labels和edits
		i = 0
		while i < 8:
			grid.addWidget(self.labels[i],i,0)
			grid.addWidget(self.edits[i],i,1)
			i = i + 1

		flow_button = QPushButton('加1')
		grid.addWidget(flow_button,4,2)

		cs_button = QPushButton('計算(1)')
		grid.addWidget(cs_button,6,2)

		flow_button.clicked.connect(self.flowButtonClicked)
		cs_button.clicked.connect(self.csButtonClicked)

		# '完整消息'
		result_label = QLabel('完整消息')
		self.result_text = QTextEdit()
		self.result_text.setFixedHeight(80)
		result_button = QPushButton('轉義(2)')
		grid.addWidget(result_label,8,0)
		grid.addWidget(self.result_text,8,1)
		grid.addWidget(result_button,8,2)
		result_button.clicked.connect(self.resultButtonClicked)

		self.setLayout(grid)
		self.setWindowTitle('心跳')
		self.move(100,600)
		self.show()
開發者ID:fiso0,項目名稱:MxPython,代碼行數:59,代碼來源:singleWindow.py

示例5: box

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [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
開發者ID:learningendless,項目名稱:gui_tool,代碼行數:13,代碼來源:value_extractor_views.py

示例6: createEditor

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [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
開發者ID:olivierkes,項目名稱:manuskript,代碼行數:54,代碼來源:corkDelegate.py

示例7: TimerDialog

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]
class TimerDialog(QDialog):
    timeChanged = pyqtSignal('int')

    def __init__(self, name, timeValue):
        super(QDialog, self).__init__()
        self.resize(300, 150)

        timeContainer = QGroupBox()
        timeContainer.setTitle('Time (ms)')

        self.lineEdit = QLineEdit()
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.lineEdit.setFont(fixedWidthFont)
        self.lineEdit.setText(str(timeValue))
        vLayout = QVBoxLayout()
        vLayout.addWidget(self.lineEdit)

        self.cancelButton = QPushButton()
        self.cancelButton.setText('Cancel')
        self.cancelButton.clicked.connect(self.cancelClicked)

        self.acceptButton = QPushButton()
        self.acceptButton.setText('Accept')
        self.acceptButton.clicked.connect(self.acceptClicked)

        buttonContainer = QWidget()
        hLayout = QHBoxLayout()
        hLayout.addWidget(self.cancelButton)
        hLayout.addWidget(self.acceptButton)
        buttonContainer.setLayout(hLayout)
        vLayout.addWidget(buttonContainer)
        timeContainer.setLayout(vLayout)

        vLayout2 = QVBoxLayout()
        vLayout2.addWidget(timeContainer)
        self.setLayout(vLayout2)

    def cancelClicked(self):
        self.close()

    def acceptClicked(self):
        #todo: make sure that provided value is integer
        self.timeChanged.emit(int(self.lineEdit.text()))
        self.close()
        pass
開發者ID:Diegojnb,項目名稱:JdeRobot,代碼行數:47,代碼來源:timerdialog.py

示例8: createEditor

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [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
開發者ID:TenKeyAngle,項目名稱:manuskript,代碼行數:44,代碼來源:corkDelegate.py

示例9: HeaderDisplay

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]
class HeaderDisplay(QDialog):

    def __init__(self, header):
        super().__init__()
        self.layout = QVBoxLayout(self)
        self.setMinimumWidth(680)
        self.resize(680, 500)
        self.setWindowTitle('Header display')

        self.cards = header.split('\n')

        self.display = QPlainTextEdit('\n'.join(self.cards))
        self.layout.addWidget(self.display)
        self.display.setReadOnly(True)
        self.display.setFocusPolicy(Qt.NoFocus)
        self.display.setFont(QFont("Courier New", 10))
        self.display.setPlaceholderText('No results found')

        self.input_box = QLineEdit()
        self.layout.addWidget(self.input_box)
        self.input_box.setPlaceholderText('Enter search term')
        self.input_box.textChanged[str].connect(self.onChanged)
        self.input_box.setFont(QFont("Courier New", 10))

    def keyPressEvent(self, event):
        if event.key() in (Qt.Key_Up, Qt.Key_Down):
            self.display.keyPressEvent(event)
        if event.key() == Qt.Key_Escape:
            self.close()
        else:
            self.input_box.keyPressEvent(event)

    def onChanged(self, term):
        if term == '':
            search_results = self.cards
        else:
            search_results = [card for card in self.cards if term.lower() in card.lower()]

        self.display.setPlainText('\n'.join(search_results))
開發者ID:saethlin,項目名稱:qtfits,代碼行數:41,代碼來源:headerdisplay.py

示例10: HyperLprWindow

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]

#.........這裏部分代碼省略.........

        self.update_file_path_layout = QHBoxLayout()
        self.update_file_path_layout.addWidget(self.check_box)
        self.update_file_path_layout.addWidget(self.update_file_path_button)
        self.update_file_path_layout.addStretch()

        self.save_as_e2e_filename_button = QPushButton("保存e2e文件名")
        self.save_as_e2e_filename_button.setEnabled(False)
        self.save_as_e2e_filename_button.clicked.connect(self.rename_current_image_with_info)
        self.save_layout = QHBoxLayout()
        self.save_layout.addWidget(self.save_as_e2e_filename_button)
        self.save_layout.addStretch()

        self.top_layout = QVBoxLayout()
        self.top_layout.addLayout(left_right_layout)
        self.top_layout.addLayout(self.location_layout)
        self.top_layout.addLayout(self.update_file_path_layout)
        self.top_layout.addLayout(self.save_layout)

        function_groupbox = QGroupBox("功能區")
        function_groupbox.setLayout(self.top_layout)

        license_plate_image_label = QLabel("車牌圖")
        self.license_plate_widget = QLabel("")

        block_image_label = QLabel("分割圖")
        self.block_plate_widget = QLabel("")

        filename_label = QLabel("文件名:")
        self.filename_edit = QLineEdit()

        segmentation_recognition_label = QLabel("分割識別:")
        self.segmentation_recognition_edit = QLineEdit()
        self.segmentation_recognition_edit.setFont(QFont("黑體", 24, QFont.Bold))
        # self.segmentation_recognition_edit.setStyleSheet("color:red")

        confidence_label = QLabel("分割識別\n置信度")
        self.confidence_edit = QLineEdit()
        #self.confidence_edit.setFont(QFont("黑體", 24, QFont.Bold))
        # self.confidence_edit.setStyleSheet("color:red")

        plate_color_label = QLabel("車牌顏色")
        self.plate_color_edit = QLineEdit()
        self.plate_color_edit.setFont(QFont("黑體", 24, QFont.Bold))
        # self.plate_color_edit.setStyleSheet("color:red")

        e2e_recognization_label = QLabel("e2e識別:")
        self.e2e_recognization_edit = QLineEdit()
        self.e2e_recognization_edit.setFont(QFont("黑體", 24, QFont.Bold))
        # self.e2e_recognization_edit.setStyleSheet("color:red")

        e2e_confidence_label = QLabel("e2e置信度")
        self.e2e_confidence_edit = QLineEdit()
        #self.e2e_confidence_edit.setFont(QFont("黑體", 24, QFont.Bold))
        # self.e2e_confidence_edit.setStyleSheet("color:red")

        info_gridlayout = QGridLayout()
        line_index = 0
        info_gridlayout.addWidget(filename_label, line_index, 0)
        info_gridlayout.addWidget(self.filename_edit, line_index, 1)
        line_index += 1
        info_gridlayout.addWidget(license_plate_image_label, line_index, 0)
        info_gridlayout.addWidget(self.license_plate_widget, line_index, 1)
        line_index += 1
        info_gridlayout.addWidget(e2e_recognization_label, line_index, 0)
        info_gridlayout.addWidget(self.e2e_recognization_edit, line_index, 1)
開發者ID:han1157,項目名稱:HyperLPR,代碼行數:70,代碼來源:HyperLprGUI.py

示例11: Calculator

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [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

#.........這裏部分代碼省略.........
開發者ID:death-finger,項目名稱:Scripts,代碼行數:103,代碼來源:calculator.py

示例12: run_iface_config_window

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]
def run_iface_config_window(icon):
    win = QDialog()
    win.setWindowTitle('CAN Interface Configuration')
    win.setWindowIcon(icon)
    win.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint)

    combo = QComboBox(win)
    combo.setEditable(True)
    combo.setInsertPolicy(QComboBox.NoInsert)
    combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
    combo.setFont(get_monospace_font())

    combo_completer = QCompleter()
    combo_completer.setCaseSensitivity(Qt.CaseSensitive)
    combo_completer.setModel(combo.model())
    combo.setCompleter(combo_completer)

    bitrate = QSpinBox()
    bitrate.setMaximum(1000000)
    bitrate.setMinimum(10000)
    bitrate.setValue(1000000)

    extra_args = QLineEdit()
    extra_args.setFont(get_monospace_font())

    ok = QPushButton('OK', win)

    ifaces = None

    def update_iface_list():
        nonlocal ifaces
        ifaces = iface_lister.get_list()
        known_keys = set()
        remove_indices = []
        was_empty = combo.count() == 0
        # Marking known and scheduling for removal
        for idx in count():
            tx = combo.itemText(idx)
            if not tx:
                break
            known_keys.add(tx)
            if tx not in ifaces:
                logger.debug('Removing iface %r', tx)
                remove_indices.append(idx)
        # Removing - starting from the last item in order to retain indexes
        for idx in remove_indices[::-1]:
            combo.removeItem(idx)
        # Adding new items - starting from the last item in order to retain the final order
        for key in list(ifaces.keys())[::-1]:
            if key not in known_keys:
                logger.debug('Adding iface %r', key)
                combo.insertItem(0, key)
        # Updating selection
        if was_empty:
            combo.setCurrentIndex(0)

    result = None
    kwargs = {}

    def on_ok():
        nonlocal result, kwargs
        a = str(extra_args.text())
        if a:
            try:
                kwargs = dict(eval(a))
            except Exception as ex:
                show_error('Invalid parameters', 'Could not parse optional arguments', ex, parent=win)
                return
        kwargs['bitrate'] = int(bitrate.value())
        result_key = str(combo.currentText()).strip()
        if not result_key:
            show_error('Invalid parameters', 'Interface name cannot be empty', 'Please select a valid interface',
                       parent=win)
            return
        try:
            result = ifaces[result_key]
        except KeyError:
            result = result_key
        win.close()

    ok.clicked.connect(on_ok)

    layout = QVBoxLayout()
    layout.addWidget(QLabel('Select CAN interface or serial port for SLCAN:'))
    layout.addWidget(combo)
    layout.addWidget(QLabel('Interface bitrate (SLCAN only):'))
    layout.addWidget(bitrate)
    layout.addWidget(QLabel('Optional arguments (refer to PyUAVCAN for info):'))
    layout.addWidget(extra_args)
    layout.addWidget(ok)
    layout.setSizeConstraint(layout.SetFixedSize)
    win.setLayout(layout)

    with BackgroundIfaceListUpdater() as iface_lister:
        update_iface_list()
        timer = QTimer(win)
        timer.setSingleShot(False)
        timer.timeout.connect(update_iface_list)
        timer.start(int(BackgroundIfaceListUpdater.UPDATE_INTERVAL / 2 * 1000))
        win.exec()
#.........這裏部分代碼省略.........
開發者ID:learningendless,項目名稱:gui_tool,代碼行數:103,代碼來源:iface_configurator.py

示例13: TabSearch

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [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
開發者ID:juancarlospaco,項目名稱:unicodemoticon,代碼行數:74,代碼來源:tab_search.py

示例14: JdeRobotCommConfigDialog

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]
class JdeRobotCommConfigDialog(QDialog):
    configChanged = pyqtSignal()

    def __init__(self, name):
        super(QDialog, self).__init__()
        self.setWindowTitle(name)
        self.config = None

        self.gridLayout = QGridLayout()

        # add header
        self.gridLayout.addWidget(QLabel('Server Type'), 0, 0)
        self.gridLayout.addWidget(QLabel('Name'), 0, 1)
        self.gridLayout.addWidget(QLabel('Topic'), 0, 2)
        self.gridLayout.addWidget(QLabel('Proxy Name'), 0, 3)
        self.gridLayout.addWidget(QLabel('IP'), 0, 4)
        self.gridLayout.addWidget(QLabel('Port'), 0, 5)
        self.gridLayout.addWidget(QLabel('Interface'), 0, 6)
        self.gridLayout.addWidget(QLabel(''), 0, 7)

        # add new config input fields
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.serverTypeCombo = QComboBox()
        self.serverTypeCombo.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.serverTypeCombo, 1, 0)
        self.nameEdit = QLineEdit()
        self.nameEdit.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.nameEdit, 1, 1)
        self.topicEdit = QLineEdit()
        self.topicEdit.setFont(fixedWidthFont)
        self.topicEdit.setEnabled(False)
        self.gridLayout.addWidget(self.topicEdit, 1, 2)
        self.proxyNameEdit = QLineEdit()
        self.proxyNameEdit.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.proxyNameEdit, 1, 3)
        self.ipEdit = QLineEdit()
        self.ipEdit.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.ipEdit, 1, 4)
        self.portEdit = QLineEdit()
        self.portEdit.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.portEdit, 1, 5)
        self.interfaceCombo = QComboBox()
        self.gridLayout.addWidget(self.interfaceCombo, 1, 6)
        self.addButton = QPushButton('Add')
        self.gridLayout.addWidget(self.addButton, 1, 7)
        self.addButton.clicked.connect(self.addClicked)

        self.rowCount = 2

        # add server types to the combobox
        self.serverTypeCombo.addItem('ICE', 'ice')
        self.serverTypeCombo.addItem('ROS', 'ros')
        self.serverTypeCombo.currentIndexChanged.connect(self.serverTypeChanged)

        # add interfaces to the combobox
        interfaces = Interfaces.getInterfaces()
        for interfaceName in interfaces:
            self.interfaceCombo.addItem(interfaceName, interfaceName)

        self.resize(700, 100)
        self.setLayout(self.gridLayout)

    def clearAll(self):
        deleteList = []
        for i in range(self.rowCount):
            if i == 0 or i == 1:
                continue
            else:
                for j in range(8):
                    item = self.gridLayout.itemAtPosition(i, j)
                    deleteList.append(item)

        for item in deleteList:
            self.gridLayout.removeItem(item)
            item.widget().setParent(None)

        self.rowCount = 2


    def setConfig(self, config):
        self.config = config
        self.clearAll()
        if self.config is not None:
            for interface in self.config.getInterfaces():
                interface['id'] = self.rowCount
                self.addConfigRow(interface)


    def addConfigRow(self, configData):
        self.gridLayout.addWidget(QLabel(configData['serverType']), self.rowCount, 0)
        self.gridLayout.addWidget(QLabel(configData['name']), self.rowCount, 1)
        self.gridLayout.addWidget(QLabel(configData['topic']), self.rowCount, 2)
        self.gridLayout.addWidget(QLabel(configData['proxyName']), self.rowCount, 3)
        self.gridLayout.addWidget(QLabel(configData['ip']), self.rowCount, 4)
        self.gridLayout.addWidget(QLabel(configData['port']), self.rowCount, 5)
        self.gridLayout.addWidget(QLabel(configData['interface']), self.rowCount, 6)
        deleteButton = QPushButton('Delete')
        deleteButton.clicked.connect(self.deleteClicked)
        # we will find the item to be deleted based on the index on the config list
        deleteButton.setObjectName(str(self.rowCount))
#.........這裏部分代碼省略.........
開發者ID:Diegojnb,項目名稱:JdeRobot,代碼行數:103,代碼來源:jderobotcommconfigdialog.py

示例15: QtChronophoreUI

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setFont [as 別名]
class QtChronophoreUI(QWidget):
    """The Qt5 gui for chronophore.

        - List of currently signed in users
        - Entry for user id input
        - Feedback label that temporarily appears
        - Sign in/out button
    """

    def __init__(self):
        super().__init__()

        # Variables
        self.signed_in = ''
        self.feedback_label_timer = QTimer()

        # Fonts
        medium_font = QFont('SansSerif', CONFIG['MEDIUM_FONT_SIZE'])
        small_font = QFont('SansSerif', CONFIG['SMALL_FONT_SIZE'])
        tiny_font = QFont('SansSerif', CONFIG['TINY_FONT_SIZE'])
        large_header = QFont('SansSerif', CONFIG['LARGE_FONT_SIZE'], QFont.Bold)
        tiny_header = QFont('SansSerif', CONFIG['TINY_FONT_SIZE'], QFont.Bold)

        # Widgets
        lbl_signedin = QLabel('Currently Signed In:', self)
        lbl_signedin.setFont(tiny_header)

        frm_signed_in = QFrame(self)
        frm_signed_in.setFrameShape(QFrame.StyledPanel)

        self.lbl_signedin_list = QLabel(self.signed_in, frm_signed_in)
        self.lbl_signedin_list.setFont(tiny_font)
        self.lbl_signedin_list.setContentsMargins(10, 10, 10, 10)

        lbl_welcome = QLabel(CONFIG['GUI_WELCOME_LABLE'], self)
        lbl_welcome.setFont(large_header)

        lbl_id = QLabel('Enter Student ID:', self)
        lbl_id.setFont(small_font)

        self.ent_id = QLineEdit(self)
        self.ent_id.setFont(small_font)
        self.ent_id.setMaxLength(CONFIG['MAX_INPUT_LENGTH'])

        self.lbl_feedback = QLabel(self)
        self.lbl_feedback.setFont(medium_font)

        btn_sign = QPushButton('Sign In/Out', self)
        btn_sign.setFont(medium_font)
        btn_sign.setToolTip('Sign in or out from the tutoring center')
        btn_sign.resize(btn_sign.sizeHint())
        btn_sign.clicked.connect(self._sign_button_press)
        btn_sign.setAutoDefault(True)

        grid = QGridLayout()
        grid.setSpacing(10)

        # Grid
        grid.addWidget(lbl_signedin, 0, 0, Qt.AlignTop)
        grid.addWidget(frm_signed_in, 1, 0, 6, 1)
        grid.addWidget(self.lbl_signedin_list, 1, 0, 6, 1, Qt.AlignTop)

        grid.addWidget(lbl_welcome, 1, 1, 1, -1, Qt.AlignTop | Qt.AlignCenter)
        grid.addWidget(lbl_id, 2, 3, Qt.AlignBottom | Qt.AlignCenter)
        grid.addWidget(self.ent_id, 3, 3, Qt.AlignCenter)
        grid.addWidget(self.lbl_feedback, 4, 3, Qt.AlignTop | Qt.AlignCenter)
        grid.addWidget(btn_sign, 5, 3, Qt.AlignTop | Qt.AlignCenter)

        # Stretch weights
        grid.setColumnStretch(0, 10)
        grid.setColumnStretch(1, 10)
        grid.setColumnStretch(2, 10)
        grid.setColumnStretch(3, 30)
        grid.setColumnStretch(4, 10)
        grid.setColumnStretch(5, 10)
        grid.setRowStretch(0, 0)
        grid.setRowStretch(1, 2)
        grid.setRowStretch(2, 0)
        grid.setRowStretch(3, 0)
        grid.setRowStretch(4, 0)
        grid.setRowStretch(5, 1)
        grid.setRowStretch(6, 1)

        self.setWindowTitle('{} {}'.format(__title__, __version__))
        self.setLayout(grid)
        self._center()
        self._set_signed_in()
        self.ent_id.setFocus()

    def keyPressEvent(self, e):
        if e.key() == Qt.Key_Escape:
            self.close()
        if e.key() == Qt.Key_Return or e.key() == Qt.Key_Enter:
            self._sign_button_press()

    def _center(self):
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())
#.........這裏部分代碼省略.........
開發者ID:mesbahamin,項目名稱:timebook,代碼行數:103,代碼來源:qtview.py


注:本文中的PyQt5.QtWidgets.QLineEdit.setFont方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。