先创建窗口
class QtDraw(QMainWindow):
flag_btn_start = True
def __init__(self):
super(QtDraw, self).__init__()
self.init_ui()
def init_ui(self):
global selected_date
self.resize(1024, 768)
self.setWindowTitle('PyQt5 Draw')
# 添加窗口组件
self.fig = plt.Figure()
self.canvas = FC(self.fig)
self.text_box = QLineEdit(self)
self.cal = QCalendarWidget(self)
self.button = QPushButton('Submit', self)
#按钮标签的两种写法
self.btn_start = QPushButton(self)
self.btn_start.setText('draw')
# Connecting the button to the function
self.button.clicked.connect(self.submit_code)
self.btn_start.clicked.connect(self.submit_code)
time.sleep(1)
self.btn_start.clicked.connect(self.slot_btn_start)
# 添加Widgets
widget = QWidget()
layout =