sds011_pylab.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:sds011 作者: luetzel 项目源码 文件源码
def __init__(self, master):
            frame = Frame(master)
            frame.pack()
            Label(frame, text="PM 2.5: ").grid(row=0, columnspan=2)
            Label(frame, text="µg/m^3: ").grid(row=0, column=3)
            Label(frame, text="PM  10: ").grid(row=1, columnspan=2)
            Label(frame, text="µg/m^3: ").grid(row=1, column=3)

            self.result_pm25 = DoubleVar()
            Label(frame, textvariable=self.result_pm25).grid(row=0, column=2)

            self.result_pm10 = DoubleVar()
            Label(frame, textvariable=self.result_pm10).grid(row=1, column=2)

            button0 = Button(frame, text="Start", command=self.sensor_wake)
            button0.grid(row=2, column=0)

            button1 = Button(frame, text="Stop", command=self.sensor_sleep)
            button1.grid(row=2, column=1)

            button2 = Button(frame, text="Read", command=self.sensor_read)
            button2.grid(row=2, column=2)

            button3 = Button(frame, text="Record", command=self.sensor_live)
            button3.grid(row=2, column=3)

            button4 = Button(frame, text="Quit", command=self.quit)
            button4.grid(row=2, column=4)

            #Label(frame, text="").grid(row=3, column=3)

            fig = pylab.Figure()
            self.canvas = FigureCanvasTkAgg(fig, master=master)
            self.canvas.show()
            self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)

            self.ax = fig.add_subplot(111)
            self.ax.grid(True)
            self.ax.set_title("PM2.5 and PM10")
            self.ax.set_xlabel("Time (seconds)")
            self.ax.set_ylabel("PM (ug/m^3)")
            self.ax.axis([0,300,0,60])

        # 0xAA, 0xB4, 0x06, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x06, 0xAB
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号