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


Python QLineEdit.setClearButtonEnabled方法代碼示例

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


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

示例1: TileStampsDock

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setClearButtonEnabled [as 別名]
class TileStampsDock(QDockWidget):
    setStamp = pyqtSignal(TileStamp)
    
    def __init__(self, stampManager, parent = None):
        super().__init__(parent)
        
        self.mTileStampManager = stampManager
        self.mTileStampModel = stampManager.tileStampModel()
        self.mProxyModel = QSortFilterProxyModel(self.mTileStampModel)
        self.mFilterEdit = QLineEdit(self)
        self.mNewStamp = QAction(self)
        self.mAddVariation = QAction(self)
        self.mDuplicate = QAction(self)
        self.mDelete = QAction(self)
        self.mChooseFolder = QAction(self)

        self.setObjectName("TileStampsDock")
        self.mProxyModel.setSortLocaleAware(True)
        self.mProxyModel.setSortCaseSensitivity(Qt.CaseInsensitive)
        self.mProxyModel.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.mProxyModel.setSourceModel(self.mTileStampModel)
        self.mProxyModel.sort(0)
        self.mTileStampView = TileStampView(self)
        self.mTileStampView.setModel(self.mProxyModel)
        self.mTileStampView.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
        self.mTileStampView.header().setStretchLastSection(False)
        self.mTileStampView.header().setSectionResizeMode(0, QHeaderView.Stretch)
        self.mTileStampView.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
        self.mTileStampView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.mTileStampView.customContextMenuRequested.connect(self.showContextMenu)
        self.mNewStamp.setIcon(QIcon(":images/16x16/document-new.png"))
        self.mAddVariation.setIcon(QIcon(":/images/16x16/add.png"))
        self.mDuplicate.setIcon(QIcon(":/images/16x16/stock-duplicate-16.png"))
        self.mDelete.setIcon(QIcon(":images/16x16/edit-delete.png"))
        self.mChooseFolder.setIcon(QIcon(":images/16x16/document-open.png"))
        Utils.setThemeIcon(self.mNewStamp, "document-new")
        Utils.setThemeIcon(self.mAddVariation, "add")
        Utils.setThemeIcon(self.mDelete, "edit-delete")
        Utils.setThemeIcon(self.mChooseFolder, "document-open")

        self.mFilterEdit.setClearButtonEnabled(True)
        self.mFilterEdit.textChanged.connect(self.mProxyModel.setFilterFixedString)
        self.mTileStampModel.stampRenamed.connect(self.ensureStampVisible)
        self.mNewStamp.triggered.connect(self.newStamp)
        self.mAddVariation.triggered.connect(self.addVariation)
        self.mDuplicate.triggered.connect(self.duplicate)
        self.mDelete.triggered.connect(self.delete_)
        self.mChooseFolder.triggered.connect(self.chooseFolder)
        self.mDuplicate.setEnabled(False)
        self.mDelete.setEnabled(False)
        self.mAddVariation.setEnabled(False)
        widget = QWidget(self)
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(5, 5, 5, 5)
        
        buttonContainer = QToolBar()
        buttonContainer.setFloatable(False)
        buttonContainer.setMovable(False)
        buttonContainer.setIconSize(QSize(16, 16))
        buttonContainer.addAction(self.mNewStamp)
        buttonContainer.addAction(self.mAddVariation)
        buttonContainer.addAction(self.mDuplicate)
        buttonContainer.addAction(self.mDelete)
        stretch = QWidget()
        stretch.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        buttonContainer.addWidget(stretch)
        buttonContainer.addAction(self.mChooseFolder)
        listAndToolBar = QVBoxLayout()
        listAndToolBar.setSpacing(0)
        listAndToolBar.addWidget(self.mFilterEdit)
        listAndToolBar.addWidget(self.mTileStampView)
        listAndToolBar.addWidget(buttonContainer)
        layout.addLayout(listAndToolBar)
        selectionModel = self.mTileStampView.selectionModel()
        selectionModel.currentRowChanged.connect(self.currentRowChanged)
        self.setWidget(widget)
        self.retranslateUi()
        
    def changeEvent(self, e):
        super().changeEvent(e)
        x = e.type()
        if x==QEvent.LanguageChange:
            self.retranslateUi()
        else:
            pass
            
    def keyPressEvent(self, event):
        x = event.key()
        if x==Qt.Key_Delete or x==Qt.Key_Backspace:
            self.delete_()
            return

        super().keyPressEvent(event)

    def currentRowChanged(self, index):
        sourceIndex = self.mProxyModel.mapToSource(index)
        isStamp = self.mTileStampModel.isStamp(sourceIndex)
        self.mDuplicate.setEnabled(isStamp)
        self.mDelete.setEnabled(sourceIndex.isValid())
        self.mAddVariation.setEnabled(isStamp)
#.........這裏部分代碼省略.........
開發者ID:theall,項目名稱:Python-Tiled,代碼行數:103,代碼來源:tilestampsdock.py

示例2: Layout

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

#.........這裏部分代碼省略.........
        self.setDisabled(False)

    def infoClear(self):
            self.downloadBtn.setDisabled(True)
            self.quality.clear()
            self.quality.hide()
            self.info.clear()
            self.downloadBtn.setDisabled(True)
            self.downloadBtn.hide()

    def searchChange(self):
        searchTerm = self.searchBox.text()
        if len(searchTerm) == 0 :
            self.infoClear()
            self.searchBtn.setDisabled(True)
            self.searchBtn.setDisabled(True)
            self.statusBar().showMessage(self.statusText)
        elif len(searchTerm) != 0 :
            self.statusBar().showMessage('Kullanıma Hazır !')
            self.searchBtn.setDisabled(False)


    def toolBarButtons(self):
        # Search Button
        self.searchBtn = QPushButton(conf.app.toolBar.searchBtn.title,self)
        self.searchBtn.clicked.connect(self.getSearch)
        self.searchBtn.setDisabled(True)
        self.searchBtn.move(conf.app.toolBar.searchBtn.pos.x,conf.app.toolBar.searchBtn.pos.y)
        # Download Button
        # downloadBtn = QPushButton(conf.app.toolBar.downloadBtn.title,self)
        # downloadBtn.move(conf.app.toolBar.downloadBtn.pos.x,conf.app.toolBar.downloadBtn.pos.y)

    def toolBar(self):
        self.toolBarButtons()
        self.searchBox = QLineEdit(self)
        self.searchBox.setFocus(True)
        self.searchBox.setFixedSize(conf.app.toolBar.searchBox.size.w,conf.app.toolBar.searchBox.size.h)
        self.searchBox.setClearButtonEnabled(True)
        self.searchBox.returnPressed.connect(self.searchChange)
        self.searchBox.textEdited.connect(self.searchChange)
        self.searchBox.setPlaceholderText(conf.app.toolBar.searchBox.placeholder)
        self.searchBox.move(conf.app.toolBar.searchBox.pos.x,conf.app.toolBar.searchBox.pos.y)


    def setStatusBar(self):
        self.statusBar().showMessage(self.statusText)
        # self.downloadBtn.setDisabled(False)


    def selectedQuality(self,text):
        infoText = self.filename
        self.info.setText(infoText + ' ' + text)
        self.downloadBtn.setDisabled(False)

    def disabledAll(self):
        self.setDisabled(True)

    def enableAll(self):
        self.setEnabled(True)

    def completed(self,path):
        self.enableAll()
        self.statusBar().showMessage(conf.app.download_dir + self.filename + '.mp4 indirildi !')
        self.infoClear()
        self.searchBtn.setDisabled(True)
        self.searchBox.clear()
        self.searchBox.setFocus(True)

    def downloadVideo(self):
        self.disabledAll()
        self.statusBar().showMessage('İndiriliyor...!')
        if self.isEnabled() == False :
            video = self.yt.get(conf.app.video.type,self.quality.currentText())
            sleep(5)
            video.download(path=conf.app.download_dir,force_overwrite=True,on_finish=self.completed)


    def initUI(self):
        self.toolBar()
        self.setStatusBar()
        self.info = QLabel(self)
        self.info.move(120,50)
        self.info.setMinimumWidth(450)

        self.quality = QComboBox(self)
        self.quality.move(120,80)
        self.quality.hide()
        self.quality.activated[str].connect(self.selectedQuality)

        self.downloadBtn = QPushButton('İndir',self)
        self.downloadBtn.move(250,80)
        self.downloadBtn.setDisabled(True)
        self.downloadBtn.hide()
        self.downloadBtn.clicked.connect(self.downloadVideo)

        self.setGeometry(self.pos.x,self.pos.y,self.res.w,self.res.h)
        self.setMaximumSize(self.res.w,self.res.h)
        self.setMinimumSize(self.res.w,self.res.h)
        self.setWindowTitle(conf.app.title + " - " + conf.app.version)
        self.show()
開發者ID:ferdiunal,項目名稱:Youtube-Downloader,代碼行數:104,代碼來源:layout.py

示例3: MainWindow

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

#.........這裏部分代碼省略.........
        self.calculationMenu.addAction(self.calculationExport)
        self.calculationMenu.addSeparator()

        #self.calculationMenu.addAction(self.calculationPrint)
        #self.calculationMenu.addSeparator()

        self.calculationMenu.addAction(self.calculationQuit)

        self.menu.addMenu(self.calculationMenu)

        # create language menu
        self.languageMenu = QMenu(self)
        self.languageMenu.addAction(self.languageGerman)
        self.languageMenu.addAction(self.languageEnglish)
        self.menu.addMenu(self.languageMenu)

        # create help menu
        self.helpMenu = QMenu(self)
        self.helpMenu.addAction(self.helpContents)
        self.helpMenu.addAction(self.scientificBasis)
        self.helpMenu.addSeparator()
        self.helpMenu.addAction(self.helpAbout)
        self.menu.addMenu(self.helpMenu)

    def createEditBox(self):
        # create group box
        self.editBox = QGroupBox()
        self.editBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
        gridLayout = QGridLayout(self.editBox)

        # create input fields
        self.operationInput = QLineEdit(self.model.projectData("operation"))
        self.operationInput.setFixedWidth(self._INPUTS_FIXED_WIDTH)
        self.operationInput.setClearButtonEnabled(True)
        self.operationLabel = QLabel()
        self.operationLabel.setBuddy(self.operationInput)
        gridLayout.addWidget(self.operationLabel, 0, 0)
        gridLayout.addWidget(self.operationInput, 0, 1)

        self.districtInput = QLineEdit(self.model.projectData("district"))
        self.districtInput.setFixedWidth(self._INPUTS_FIXED_WIDTH)
        self.districtInput.setClearButtonEnabled(True)
        self.districtLabel = QLabel()
        self.districtLabel.setBuddy(self.districtInput)
        gridLayout.addWidget(self.districtLabel, 0, 2)
        gridLayout.addWidget(self.districtInput, 0, 3)

        self.managerInput = QLineEdit(self.model.projectData("manager"))
        self.managerInput.setFixedWidth(self._INPUTS_FIXED_WIDTH)
        self.managerInput.setClearButtonEnabled(True)
        self.managerLabel = QLabel()
        self.managerLabel.setBuddy(self.managerInput)
        gridLayout.addWidget(self.managerLabel, 1, 0)
        gridLayout.addWidget(self.managerInput, 1, 1)

        self.locationInput = QLineEdit(self.model.projectData("location"))
        self.locationInput.setFixedWidth(self._INPUTS_FIXED_WIDTH)
        self.locationInput.setClearButtonEnabled(True)
        self.locationLabel = QLabel()
        self.locationLabel.setBuddy(self.locationInput)
        gridLayout.addWidget(self.locationLabel, 1, 2)
        gridLayout.addWidget(self.locationInput, 1, 3)

        lineFrame = QFrame(frameShadow=QFrame.Sunken, frameShape=QFrame.VLine)
        gridLayout.addWidget(lineFrame, 0, 4, 2, 1)
開發者ID:tobiashelfenstein,項目名稱:wuchshuellenrechner,代碼行數:69,代碼來源:window_main.py


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