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

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

氣輕PyQt5 14 單選按鈕(QRadioButton) , 按鈕組

2023-03-14 07:54 作者:氣輕  | 我要投稿

?

增加了六個(gè)單選按鈕,形成了一個(gè)按鈕組。點(diǎn)擊單選按鈕后,選擇的結(jié)果會(huì)顯示在標(biāo)簽控件。

?

from PyQt5.QtWidgets import *

from PyQt5.QtGui import QFont, QIcon, QPixmap

from PyQt5.QtCore import Qt, QDate, pyqtSignal

import sys

import datetime

import numpy as np

?

timeLabel = ['早飯前', '早飯后', '午飯前', '午飯后', '晚飯前', '晚飯后']

?

class PyQt514(QWidget):

??? def __init__(self):

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

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

??? def initUI(self):

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

??????? self.resize(420, 120)?????????????????????????? # 設(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)

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

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

?

??????? self.stage = QLabel(self)?????????????????????? #設(shè)置label信息

??????? self.stage.setGeometry(290, 0,120, 40)????????? # 設(shè)置位置和大小

??????? self.stage.setText(timeLabel[0])

??????? self.stage.setObjectName('label')

??????? self.stage.setToolTip('時(shí)段')?????????????????? # 設(shè)置label提示

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

??????? self.stage.setStyleSheet('background-color:yellow;color : #6495ED; \

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

?

??????? self.rg = QButtonGroup(self)

???????

??????? rdict = dict.fromkeys(timeLabel)

??????? x, y=np.meshgrid([80, 180, 280], [60, 80])

??????? xdict = dict(zip(timeLabel, x.ravel()))

??????? ydict = dict(zip(timeLabel, y.ravel()))

?

?

??????? for i, s in enumerate(timeLabel):

??????????? rdict[s] = QRadioButton(self)

??????????? rdict[s].setText(s)

??????????? rdict[s].move(xdict[s], ydict[s])

??????????? self.rg.addButton(rdict[s],i)

??????? rdict[timeLabel[0]].setChecked(True)??????? # 設(shè)置第一個(gè)單選框被選中

??????? self.rg.buttonClicked.connect(self.updateStage)

?

??????? 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)與槽

?

??? def updateStage(self,val):

??????? self.stage.setText(timeLabel[self.rg.checkedId()])

?

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,180)

??????? 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 = PyQt514()

??? sys.exit(app.exec_())

?

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


氣輕PyQt5 14 單選按鈕(QRadioButton) , 按鈕組的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
温泉县| 辽中县| 万源市| 马尔康县| 翁牛特旗| 义乌市| 商城县| 板桥市| 女性| 桐庐县| 平阴县| 阳山县| 浮山县| 田阳县| 阿拉善盟| 丹阳市| 鹤峰县| 大足县| 扎鲁特旗| 稷山县| 嫩江县| 兰溪市| 梁山县| 南昌市| 紫阳县| 莲花县| 福州市| 喀什市| 桐梓县| 鄂尔多斯市| 托里县| 黄龙县| 武平县| 上蔡县| 莫力| 墨竹工卡县| 工布江达县| 木兰县| 江陵县| 西青区| 沾化县|