【发布时间】:2020-02-17 18:12:07
【问题描述】:
我试过点击。当我单击继续时,连接函数打开一个新窗口,但代码没有产生任何结果。 我正在尝试打开一个允许我选择时间的新窗口...
请帮助... :)
class Window(QDialog):
def __init__(self):
super().__init__()
self.label = QLabel()
self.calendar = QCalendarWidget()
self.title="PyQt5 Calendar"
self.left = 600
self.top = 300
self.width = 500
self.height = 480
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.Calendar()
self.show()
def Calendar(self):
CalendarVbox = QVBoxLayout()
self.calendar.setGridVisible(True)
self.label.setFont(QtGui.QFont("Sanserif", 10))
self.label.setStyleSheet('color:black')
CalendarVbox.addWidget(self.calendar)
CalendarVbox.addWidget(self.label)
self.setLayout(CalendarVbox)
self.proceedbutton = QPushButton("Proceed to select time", self)
self.proceedbutton.setGeometry(290,430,190,40)
self.proceedbutton.setToolTip("<h3>Start the Session</h3>")
self.proceedbutton.clicked.connect(self.window2)
self.calendar.selectionChanged.connect(self.onSelectionChanged)
def onSelectionChanged(self):
ca = self.calendar.selectedDate()
self.label.setText(ca.toString())
def window2(self):
self.setGeometry(self.left, self.top, self.width, self.height)
self.show()
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
【问题讨论】:
标签: python time pyqt5 new-window