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


Python QLineEdit.setAcceptDrops方法代碼示例

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


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

示例1: SafeB

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setAcceptDrops [as 別名]
class SafeB(QWidget):
    def __init__(self):
        super().__init__()
        self.setAcceptDrops(True)
        self.initUI()

    def initUI(self):
        self.center()
        self.setFixedSize(435, 400)
        self.setWindowTitle('SafeB')
        self.setWindowIcon(QIcon('logo.png'))

        # Add LineEdit for Puth
        self.line_edit = QLineEdit(self)
        self.line_edit.setReadOnly(True)
        self.line_edit.resize(250, 23)
        self.line_edit.move(5, 5)
        self.line_edit.setText('Path to file')
        self.line_edit.setStyleSheet("color: rgb(167, 167, 167);")
        self.line_edit.setAcceptDrops(True)
        self.line_edit.textChanged.connect(self.onChangedPath)

        self.radio1 = QRadioButton(self)
        self.radio1.setText('one image')
        self.radio1.move(262, 37)
        self.radio1.setChecked(True)
        config.rad1 = self.radio1

        self.radio2 = QRadioButton(self)
        self.radio2.setText('few images')
        self.radio2.move(340, 37)
        config.rad2 = self.radio2

        # Add LineEdit for Username
        self.username = QLineEdit(self)
        self.username.resize(250, 23)
        self.username.move(5, 33)
        self.username.setText('Username')
        self.username.setStyleSheet("color: rgb(167, 167, 167);")
        self.username.textChanged.connect(self.onChanged2)
        self.username.mousePressEvent = lambda _: \
            self.username.selectAll()
        config.usern = self.username

        # Add LineEdit for Password
        self.password = QLineEdit(self)
        self.password.resize(250, 23)
        self.password.move(5, 61)
        self.password.setText('Password')
        self.password.setStyleSheet("color: rgb(167, 167, 167);")
        self.password.textChanged.connect(self.onChanged)
        self.password.mousePressEvent = lambda _: \
            self.password.selectAll()
        config.pwd = self.password

        # Add result textline
        self.resultText = QLabel(self)
        self.resultText.move(262, 50) #262
        self.resultText.resize(200, 46)
        self.resultText.setText('Score: ')
        self.resultText.setStyleSheet("color: rgb(167, 167, 167);")
        config.res = self.resultText


        # Add LineEdit for classifier_ids
        self.classifier_ids = QLineEdit(self)
        self.classifier_ids.resize(250, 23)
        self.classifier_ids.move(5, 89)
        self.classifier_ids.setText('Classifier_ids')
        self.classifier_ids.setStyleSheet("color: rgb(167, 167, 167);")
        self.classifier_ids.textChanged.connect(self.onChanged3)
        self.classifier_ids.mousePressEvent = lambda _: \
            self.classifier_ids.selectAll()
        config.c_id = self.classifier_ids

        # image for send
        self.pic = QLabel(self)
        self.pic.resize(567, 278)
        self.pic.move(5, 117)
        config.pic = self.pic

        # Add AddButton to type the Puth
        self.btn_add = QPushButton('Add', self)
        self.btn_add.resize(self.btn_add.sizeHint())
        self.btn_add.move(260, 5)
        self.btn_add.clicked.connect(self.showDialog)
        config.addB = self.btn_add

        # Add SendButton to send a picture
        self.btn_send = QPushButton('Send', self)
        self.btn_send.resize(self.btn_send.sizeHint())
        self.btn_send.move(340, 5)
        self.btn_send.clicked.connect(self.sendPic)
        config.sendB = self.btn_send

        self.show()

    def showDialog(self):
        if self.radio1.isChecked():
            path = QFileDialog.getOpenFileName()
#.........這裏部分代碼省略.........
開發者ID:lebik,項目名稱:SafeB,代碼行數:103,代碼來源:SafeB.py

示例2: EditView

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

#.........這裏部分代碼省略.........
    # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    #            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)
        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)
開發者ID:B-Rich,項目名稱:PPQT2,代碼行數:70,代碼來源:editview.py

示例3: EditView

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

#.........這裏部分代碼省略.........
    # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    #            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)
        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("")
        self.norm_style = 'color:Black;font-weight:normal;'
        self.mod_style = 'color:Red;font-weight:bold;'
開發者ID:tallforasmurf,項目名稱:PPQT2,代碼行數:70,代碼來源:editview.py


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