today study_2005.1.25

博客介绍了访问DataTable对象时需注意区分大小写,其包含Constraint对象集合可确保数据完整性,并给出使用示例。还展示了从流读取图片到PictureBox的代码,同时处理了可能出现的异常。
English study
navigate: v. 1.航行 2.驾驶 
A single dimension array
dimension:  n. 1.尺寸,尺度 2.维(数) 3.容积,面积
When accessing DataTable objects, note that they are conditionally case-sensitive.
当访问 DataTable 对象时,注意它们是按条件区分大小写的。
The DataTable contains a collection of Constraint objects that can be used to ensure the integrity of the data.
DataTable 包含可用于确保数据完整性的 Constraint 对象的集合。

DataTable , DataRow, DataColumn  ---------How to use.
        Dim table_user As DataTable
        Dim col_Id As DataColumn
        Dim col_UserName As DataColumn
        Dim row1 As DataRow
        Try
            table_user = New DataTable("userTable")
            col_Id = New DataColumn("id", Type.GetType("System.Int32"))
            col_UserName = New DataColumn("userName", Type.GetType("System.String"))
            table_user.Columns.Add(col_Id)
            table_user.Columns.Add(col_UserName)
            row1 = table_user.NewRow
            row1("id") = 123
            row1("username") = "zhuxinbin"
            table_user.Rows.Add(row1)
            DataGrid1.DataSource = table_user
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
从流读取图片到picturebox.txt
        Dim bin As Stream
        Try
            bin = New FileStream("C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Sunset.jpg", FileMode.Open)
            'PictureBox1.Image = PictureBox1.Image.FromStream(bin)'?里容易出?
      PictureBox1.Image = Image.FromStream(bin)'??方式比?好
            PictureBox1.Refresh()'don't need
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            bin.Close()
        End Try
请先记住这段代码:import tkinter as tk from tkinter import messagebox import time from datetime import date class StudyRecorder: def __init__(self, root): self.root = root self.root.title("学习记录") self.root.geometry("300x300") self.start_time = None self.total_study_time = 0 self.today_study_time = 0 self.today = date.today() self.study_records = [] self.label = tk.Label(root, text="学习记录", font=("Arial", 20)) self.label.pack(pady=10) self.time_label = tk.Label(root, text="0:00", font=("Arial", 24)) self.time_label.pack(pady=10) self.total_time_label = tk.Label(root, text="总学习时长: 0:00", font=("Arial", 14)) self.total_time_label.pack(pady=5) self.today_time_label = tk.Label(root, text="当天学习时长: 0:00", font=("Arial", 14)) self.today_time_label.pack(pady=5) self.start_button = tk.Button(root, text="开始学习", command=self.start_study) self.start_button.pack(pady=5) self.rest_button = tk.Button(root, text="休息一下", command=self.take_rest, state=tk.DISABLED) self.rest_button.pack(pady=5) self.record_button = tk.Button(root, text="学习记录", command=self.show_records) self.record_button.pack(pady=5) self.end_button = tk.Button(root, text="结束学习", command=self.end_study) self.end_button.pack(pady=5) def start_study(self): self.start_time = time.time() self.start_button.config(state=tk.DISABLED) self.rest_button.config(state=tk.NORMAL) self.update_time() def take_rest(self): if self.start_time: end_time = time.time() study_duration = end_time - self.start_time current_date = date.today() if current_date == self.today: self.today_study_time += study_duration else: self.today = current_date self.today_study_time = study_duration self.total_study_time += study_duration self.study_records.append((current_date, study_duration)) self.start_time = None self.start_button.config(state=tk.NORMAL) self.rest_button.config(state=tk.DISABLED) self.time_label.config(text="0:00") self.update_total_time_labels() def show_records(self): record_text = "" for record_date, record in self.study_records: record_text += f"{record_date}: {int(record // 60)} 分 {int(record % 60)} 秒\n" record_text += f"总学习时长: {int(self.total_study_time // 60)} 分 {int(self.total_study_time % 60)} 秒\n" record_text += f"当天学习时长: {int(self.today_study_time // 60)} 分 {int(self.today_study_time % 60)} 秒" messagebox.showinfo("学习记录", record_text) def end_study(self): if self.start_time: self.take_rest() self.root.destroy() def update_time(self): if self.start_time: elapsed_time = time.time() - self.start_time minutes = int(elapsed_time // 60) seconds = int(elapsed_time % 60) time_str = f"{minutes}:{seconds:02d}" self.time_label.config(text=time_str) self.root.after(1000, self.update_time) def update_total_time_labels(self): total_minutes = int(self.total_study_time // 60) total_seconds = int(self.total_study_time % 60) today_minutes = int(self.today_study_time // 60) today_seconds = int(self.today_study_time % 60) self.total_time_label.config(text=f"总学习时长: {total_minutes}:{total_seconds:02d}") self.today_time_label.config(text=f"当天学习时长: {today_minutes}:{today_seconds:02d}") if __name__ == "__main__": root = tk.Tk() app = StudyRecorder(root) root.mainloop()
最新发布
12-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值