Exemple #1
0
    def __init__(self, parent=None):
        super(MsgInput, self).__init__(parent)
        self.setContentsMargins(3, 3, 3, 3)

        self.textEdit = TextEdit()
        self.textEdit.setMaximumHeight(self.teditHeight)
        self.setMaximumHeight(self.teditHeight + self.btnSize)
        self.textEdit.setFont(QFont("Times", 20, QFont.Normal))
        self.textEdit.entered.connect(self.sendText)

        sendImg = QPushButton()
        sendImg.setStyleSheet(
            "QPushButton{border-image:url(icons/img.png);}"  #这个参数可以让图片随大小缩放
            "QPushButton:hover{border: 2px groove blue;}"
            "QPushButton:pressed{border-style: inset;}")
        sendImg.setFixedSize(self.btnSize, self.btnSize)
        sendImg.clicked.connect(self.sendImage)

        sendTxt = QPushButton(u'发送')
        sendTxt.setFont(QFont("Microsoft YaHei", 15, QFont.Bold))
        sendTxt.setFixedHeight(self.btnSize)
        sendTxt.clicked.connect(self.sendText)

        hl = FlowLayout()
        hl.addWidget(sendImg)
        hl.addWidget(sendTxt)
        hl.setMargin(0)

        vl = QVBoxLayout()
        vl.addLayout(hl)
        vl.addWidget(self.textEdit)
        vl.setMargin(0)
        self.setLayout(vl)
Exemple #2
0
    def __init__(self, parent=None):
        super(MsgInput, self).__init__(parent)
        self.setContentsMargins(3, 3, 3, 3)

        self.textEdit = TextEdit()
        self.textEdit.setMaximumHeight(self.teditHeight)
        self.setMaximumHeight(self.teditHeight + self.btnSize)
        self.textEdit.setFont(QFont("Times", 15, QFont.Normal))
        self.textEdit.entered.connect(self.sendText)

        sendTxt = QPushButton(u'发送')
        sendTxt.setFont(QFont("Microsoft YaHei", 15, QFont.Bold))
        sendTxt.setFixedHeight(self.btnSize)
        sendTxt.clicked.connect(self.sendText)

        sendSound = QPushButton(u'录音')
        sendSound.setFont(QFont("Microsoft YaHei", 15, QFont.Bold))
        sendSound.setFixedHeight(self.btnSize)
        sendSound.clicked.connect(self.sendSound)

        hl = FlowLayout()
        hl.addWidget(sendTxt)
        hl.addWidget(sendSound)
        hl.setMargin(0)

        vl = QVBoxLayout()
        vl.addWidget(self.textEdit)
        vl.addLayout(hl)
        vl.setMargin(0)
        self.setLayout(vl)
Exemple #3
0
    def __init__(self, parent=None):
        super(MsgInput, self).__init__(parent)
        self.setContentsMargins(3, 3, 3, 3)

        self.textEdit = TextEdit()
        self.textEdit.setMaximumHeight(self.teditHeight)
        self.setMaximumHeight(self.teditHeight + self.btnSize)
        self.textEdit.setFont(QFont("Times", 15, QFont.Normal))
        self.textEdit.entered.connect(self.sendText)

        sendImg = QPushButton()
        sendImg.setStyleSheet(
            "margin:0px;padding:1px;border:0px;background-image:url(img/file.png);"
        )
        sendImg.setFixedSize(22, 22)
        sendImg.clicked.connect(self.sendImage)

        sendEmoji = QPushButton()
        sendEmoji.setFixedSize(22, 22)
        sendEmoji.setStyleSheet(
            "margin:0px;padding:1px;border:0px;background-image:url(img/emoji.png);"
        )
        sendEmoji.clicked.connect(self.toInsertEmoji)

        sendTxt = QPushButton(u'发送')
        sendTxt.setStyleSheet(
            "QPushButton{border:1px solid #cccccc;color:cccccc}"
            "QPushButton:hover{background-color:#129611;color:while}"
            "QPushButton:pressed{background-color:#129611;;color:while}")
        sendTxt.setFixedHeight(self.btnSize)
        sendTxt.clicked.connect(self.sendText)

        hl = FlowLayout()
        hl.addWidget(sendTxt)

        hl.setMargin(2)

        h2 = FlowLayout()
        h2.addWidget(sendImg)
        h2.addWidget(sendEmoji)
        h2.setMargin(2)

        vl = QVBoxLayout()
        vl.addLayout(h2)
        vl.addWidget(self.textEdit)
        vl.addLayout(hl)

        vl.setMargin(0)
        self.setLayout(vl)