国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

氣輕PyQt6 13 不同窗口間的槽機(jī)制

2023-03-09 06:53 作者:氣輕  | 我要投稿

?

點(diǎn)擊按鈕后在新窗口中顯示日歷控件,在日歷控件中選擇日期后,新窗口關(guān)閉。通過槽機(jī)制將選擇的日期顯示在主窗口中的文本框里。

?

from PyQt6.QtWidgets import *

from PyQt6.QtGui import QFont, QIcon, QPixmap

from PyQt6.QtCore import Qt, QDate, pyqtSignal

import sys

import datetime

?

class PyQt613(QWidget):

??? def __init__(self):

??????? super().__init__()

??????? self.initUI()

??? def initUI(self):

??????? self.setWindowTitle('氣輕PyQt6')??????????????? # 設(shè)置窗口標(biāo)題

??????? self.resize(300, 60)??????????????????????????? # 設(shè)置窗口大小

?

??????? dateData = datetime.datetime.now().date()

??????? dateLabel = dateData.strftime('%Y-%m-%d')

??????? self.edit = QLineEdit(self)???????????????????? # 輸入框

??????? self.edit.setGeometry(10, 0,230, 40)??????? ????# 設(shè)置位置和大小

??????? self.edit.setReadOnly(True)???????????????????? # 只讀

??????? self.edit.setText(dateLabel)

??????? self.edit.setAlignment(Qt.AlignmentFlag.AlignHCenter)# 居中設(shè)置

??????? self.edit.setStyleSheet('background-color:#FFE4B5;color : #32CD32; \

??????????????????? font: bold italic large /"Times New Roman/";font-size:25px')

?

??????? self.btn = QPushButton('', self)

??????? self.btn.setGeometry(250,0,40,40)?????????????? # 設(shè)置位置和大小

??????? self.btn.setIcon(QIcon(QPixmap('Date.png')))

??????? self.btn.clicked.connect(self.calendarOn)

?

??????? self.show()

?

??? def updateEdit(self,t):

??????? self.edit.setText(t)

?

??? def calendarOn( self ):

??????? self.calWin = CalendarWin(self.edit)

??????? self.calWin.show()

??????? self.calWin.move(900,700)

???? ???self.calWin.signal.connect(self.updateEdit)??? # 連接信號(hào)與槽

?

class CalendarWin(QWidget):

??? signal = pyqtSignal( str )????????????????????????? #定義一個(gè)信號(hào)

??? def __init__(self,t):

??????? super().__init__()

??????? self.t = t

??????? self.setWindowTitle('日期')

??????? self.resize(440, 220)

??????? cal = QCalendarWidget(self)

??????? cal.setGridVisible(True)

??????? cal.resize(400,160)

??????? cal.move(10,10)

??????? cal.clicked[QDate].connect(self.emitDate)??? # 按下按鈕時(shí)發(fā)送信號(hào)

?

??? def emitDate(self,date):

?? ?????self.signal.emit(date.toString("yyyy-MM-dd"))

??????? self.close()

?

if __name__ == '__main__':

??? app = QApplication(sys.argv)

??? window = PyQt613()

??? sys.exit(app.exec())

?

執(zhí)行結(jié)果


氣輕PyQt6 13 不同窗口間的槽機(jī)制的評論 (共 條)

分享到微博請遵守國家法律
通州市| 寻乌县| 夏津县| 隆化县| 绥芬河市| 苏尼特左旗| 玉林市| 广州市| 鱼台县| 武城县| 海林市| 台安县| 兴海县| 玉林市| 陵水| 祁阳县| 温州市| 大城县| 黑水县| 仙桃市| 瓦房店市| 六盘水市| 滨州市| 平远县| 二连浩特市| 和田市| 苍南县| 达尔| 龙南县| 余干县| 错那县| 临沭县| 曲阜市| 临颍县| 万山特区| 武威市| 临汾市| 云梦县| 墨竹工卡县| 绍兴市| 方山县|