|
|
@ -1,6 +1,7 @@
|
|
|
|
import csv
|
|
|
|
import csv
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import random
|
|
|
|
|
|
|
|
import shutil
|
|
|
|
import tempfile
|
|
|
|
import tempfile
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import tkinter as tk
|
|
|
|
import tkinter as tk
|
|
|
@ -81,9 +82,9 @@ class Mainpage:
|
|
|
|
|
|
|
|
|
|
|
|
self.btn_liked = tk.Button(self.page, text='收藏攻略', bg='#D7EFFF',font=('SimHei',15,'bold'),command=self.func_collect)
|
|
|
|
self.btn_liked = tk.Button(self.page, text='收藏攻略', bg='#D7EFFF',font=('SimHei',15,'bold'),command=self.func_collect)
|
|
|
|
self.btn_liked.place(relx=0.9, rely=0.2, relheight=0.05, relwidth=0.1)
|
|
|
|
self.btn_liked.place(relx=0.9, rely=0.2, relheight=0.05, relwidth=0.1)
|
|
|
|
|
|
|
|
#
|
|
|
|
self.btn_dis_liked = tk.Button(self.page, text='取消收藏', bg='#D7EFFF',font=('SimHei',15,'bold'),command=self.func_discollect)
|
|
|
|
# self.btn_dis_liked = tk.Button(self.page, text='取消收藏', bg='#D7EFFF',font=('SimHei',15,'bold'),command=self.re)
|
|
|
|
self.btn_dis_liked.place(relx=0.9, rely=0.3, relheight=0.05, relwidth=0.1)
|
|
|
|
# self.btn_dis_liked.place(relx=0.9, rely=0.3, relheight=0.05, relwidth=0.1)
|
|
|
|
|
|
|
|
|
|
|
|
self.lable_like=tk.Label(self.page,text='喜欢人数:'+self.likes,font=('SimHei',15,'bold'))
|
|
|
|
self.lable_like=tk.Label(self.page,text='喜欢人数:'+self.likes,font=('SimHei',15,'bold'))
|
|
|
|
self.lable_like.place(relx=0.05, rely=0.93)
|
|
|
|
self.lable_like.place(relx=0.05, rely=0.93)
|
|
|
@ -234,7 +235,7 @@ class Mainpage:
|
|
|
|
self.btn_pre = tk.Button(self.page2, text='上一篇', bg='#D7EFFF',font=('SimHei',15,'bold'),command=self.c_pre_data)
|
|
|
|
self.btn_pre = tk.Button(self.page2, text='上一篇', bg='#D7EFFF',font=('SimHei',15,'bold'),command=self.c_pre_data)
|
|
|
|
self.btn_pre.place(relx=0.45, rely=0.35, relheight=0.08, relwidth=0.09)
|
|
|
|
self.btn_pre.place(relx=0.45, rely=0.35, relheight=0.08, relwidth=0.09)
|
|
|
|
|
|
|
|
|
|
|
|
self.btn_dis_liked = tk.Button(self.page2, text='取消收藏', bg='#D7EFFF',font=('SimHei',15,'bold'),command=self.func_discollect)
|
|
|
|
self.btn_dis_liked = tk.Button(self.page2, text='取消收藏', bg='#D7EFFF',font=('SimHei',15,'bold'),command=self.remove_rows_with_content)
|
|
|
|
self.btn_dis_liked.place(relx=0.9, rely=0.3, relheight=0.05, relwidth=0.1)
|
|
|
|
self.btn_dis_liked.place(relx=0.9, rely=0.3, relheight=0.05, relwidth=0.1)
|
|
|
|
|
|
|
|
|
|
|
|
def notes_request(self,next_back):
|
|
|
|
def notes_request(self,next_back):
|
|
|
@ -528,6 +529,7 @@ class Mainpage:
|
|
|
|
for row in reader:
|
|
|
|
for row in reader:
|
|
|
|
if i==self.current_data_index:
|
|
|
|
if i==self.current_data_index:
|
|
|
|
dic['文章内容']=row[1]
|
|
|
|
dic['文章内容']=row[1]
|
|
|
|
|
|
|
|
i+=1
|
|
|
|
|
|
|
|
|
|
|
|
with open('collections/{}.csv'.format(self.user),'a+',encoding='utf-8',newline='') as f:
|
|
|
|
with open('collections/{}.csv'.format(self.user),'a+',encoding='utf-8',newline='') as f:
|
|
|
|
writer = csv.DictWriter(f, fieldnames=['文章ID','文章标题','图片资源','文章内容'])
|
|
|
|
writer = csv.DictWriter(f, fieldnames=['文章ID','文章标题','图片资源','文章内容'])
|
|
|
@ -560,7 +562,26 @@ class Mainpage:
|
|
|
|
# 将临时文件重命名为原始文件名
|
|
|
|
# 将临时文件重命名为原始文件名
|
|
|
|
os.rename(temp.name, 'collections/{}.csv'.format(self.user))
|
|
|
|
os.rename(temp.name, 'collections/{}.csv'.format(self.user))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_rows_with_content(self):
|
|
|
|
|
|
|
|
dis_collect.dis_collec(self.user, self.c_data_index)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 创建一个临时文件
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile(mode='w', delete=False,encoding='utf-8',newline='') as tmpfile:
|
|
|
|
|
|
|
|
# 打开原始文件并读取内容
|
|
|
|
|
|
|
|
with open('collections/{}.csv'.format(self.user), 'r', newline='',encoding='utf-8') as infile:
|
|
|
|
|
|
|
|
reader = csv.reader(infile)
|
|
|
|
|
|
|
|
writer = csv.writer(tmpfile)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 遍历每一行,如果不包含指定内容则写入临时文件
|
|
|
|
|
|
|
|
i=0
|
|
|
|
|
|
|
|
for row in reader:
|
|
|
|
|
|
|
|
if self.c_data_index != i:
|
|
|
|
|
|
|
|
writer.writerow(row)
|
|
|
|
|
|
|
|
i+=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 替换原始文件为临时文件
|
|
|
|
|
|
|
|
tmpfile.close()
|
|
|
|
|
|
|
|
shutil.move(tmpfile.name, 'collections/{}.csv'.format(self.user))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
root = tk.Tk()
|
|
|
|
root = tk.Tk()
|
|
|
|