kindle manager
This commit is contained in:
80
kmanapp.py
80
kmanapp.py
@@ -36,12 +36,23 @@ notes_temp = """<br><span style='font-size:18pt;color:maroon'>《{bookname}》</
|
||||
<span style='font-size:18pt;color:#31849B'>{content}</span>
|
||||
<span style='font-size:11pt;color:maroon'>【P{position}】</span><br>"""
|
||||
|
||||
infos_temp = """<br><span style='font-size:18pt;color:maroon'>
|
||||
<a href="3school.com.cn/" target="_blank">《{bookname}》</a></span>
|
||||
<span style='font-size:18pt;color:maroon'> {author} </span>
|
||||
<span style='font-size:18pt;color:maroon'> ({time}) </span>
|
||||
<span style='font-size:18pt;color:#31849B'>{rate}★ ☆</span>
|
||||
<span style='font-size:11pt;color:maroon'>{img}</span><br>"""
|
||||
infos_temp = """<table border="0">
|
||||
<tr>
|
||||
<td width = 20> </td>
|
||||
<td valign="top">
|
||||
<font size="4" color="black"></font><br>
|
||||
<a href={link}><font size="8" color="darkred">{bookname}</font></a><br><br>
|
||||
<font size="4" color="black">作者 : {author}</font><br><br>
|
||||
<font size="4" color="yellow">评论数 : {ratenum}</font> <br><br>
|
||||
<font size="4" color="black">评分 : {score}</font> <br><br>
|
||||
<font size="4" color="green">出版社 : {publisher}</font><br><br>
|
||||
<font size="4">出版时间 : {publishing}</font> <br><br>
|
||||
</td>
|
||||
<td style="border-left:1px solid lightgray;"> </td>
|
||||
<td width=100> </td>
|
||||
<td> <img style="max-width:220px;" src="/Users/mark/kman/downimg/{img}" > </td>
|
||||
</tr>
|
||||
</table>"""
|
||||
|
||||
words_temp = """<br><span style='font-size:18pt;color:#31849B'>{usage}</span><br><br>
|
||||
<span style='font-size:14pt;color:#2F4F4F'> {bookname} </span>
|
||||
@@ -187,6 +198,7 @@ class kmanWindow(QMainWindow):
|
||||
2 - textedit , note table view clicked
|
||||
3 - tablevew + textedit , word tree view clicked
|
||||
4 - textedit , word table view clicked
|
||||
5 - textedit , info tree view clicked
|
||||
"""
|
||||
# refresh tableview click note tree
|
||||
if comp in [1,2]:
|
||||
@@ -213,6 +225,8 @@ class kmanWindow(QMainWindow):
|
||||
self.ui.textEdit.setHtml(tt)
|
||||
elif comp in [3,4]:
|
||||
self.render_textedit_words(self.words_data)
|
||||
elif comp == 5:
|
||||
self.render_textedit_infos(self.books_info)
|
||||
|
||||
self.show_status_info()
|
||||
|
||||
@@ -239,6 +253,35 @@ class kmanWindow(QMainWindow):
|
||||
|
||||
self.ui.textEdit.setHtml(txt)
|
||||
|
||||
'''
|
||||
{
|
||||
"金融的本质": {
|
||||
"link": "https://book.douban.com/subject/25843334",
|
||||
"bookname": "金融的本质",
|
||||
"img": "https://img9.doubanio.com/view/subject/s/public/s27246465.jpg",
|
||||
"score": "8.2",
|
||||
"ratenum": "893",
|
||||
"publisher": "中信出版社",
|
||||
"publishing": "2014",
|
||||
"author": "【美】伯南克/巴曙松"
|
||||
}
|
||||
'''
|
||||
def render_textedit_infos(self, idata, selectitem):
|
||||
""" render textedit for book information
|
||||
Args:
|
||||
idata - books_info
|
||||
selectitem - text of treeitem selected
|
||||
"""
|
||||
|
||||
if selectitem in list(idata.keys()):
|
||||
vv = idata[selectitem]
|
||||
self.ui.textEdit.setHtml(infos_temp.format(link=vv['link'],bookname=vv['bookname'],
|
||||
author=vv['author'], ratenum=vv['ratenum'],
|
||||
score=vv['score'], publisher=vv['publisher'],
|
||||
publishing=vv['publishing'],img=vv['img'].split('/')[-1]))
|
||||
else: pass
|
||||
|
||||
|
||||
def convert_to_panda(self, mlist, tp=0):
|
||||
if tp==0:
|
||||
pdframe = pd.DataFrame(mlist, \
|
||||
@@ -264,18 +307,26 @@ class kmanWindow(QMainWindow):
|
||||
self.filter_list = None
|
||||
info = re.split(r'\s+',item.text())[0]
|
||||
comp = 0
|
||||
if self.tree_selected.split('_')[0] == 'info':
|
||||
self.ui.tableView.setVisible(False)
|
||||
self.render_textedit_infos(self.books_info, item.text())
|
||||
comp = 5
|
||||
else:
|
||||
self.ui.tableView.setVisible(True)
|
||||
|
||||
# refresh filter clips(tableview) after tree item clicked
|
||||
if self.tree_selected in ['note_root', 'note_bookname', 'note_author']:
|
||||
[self.filter_books, self.filter_list] = self.km.filter_clips(self.books_data)
|
||||
comp = 1
|
||||
elif self.tree_selected in ['word_root', 'word_bookname']:
|
||||
self.filter_list = self.km.filter_words(self.words_data)
|
||||
comp = 3
|
||||
elif self.tree_selected == 'note_bleaf': # bookname leaf
|
||||
comp = 1
|
||||
[self.filter_books, self.filter_list] = self.km.filter_clips(self.books_data, info, 1)
|
||||
elif self.tree_selected == 'note_aleaf': # author leaf
|
||||
comp = 1
|
||||
[self.filter_books, self.filter_list] = self.km.filter_clips(self.books_data, info, 2)
|
||||
elif self.tree_selected in ['word_root', 'word_bookname']:
|
||||
self.filter_list = self.km.filter_words(self.words_data)
|
||||
comp = 3
|
||||
elif self.tree_selected == 'word_leaf': # word bookname leaf
|
||||
comp = 3
|
||||
self.filter_list = self.km.filter_words(self.words_data, info)
|
||||
@@ -304,7 +355,8 @@ class kmanWindow(QMainWindow):
|
||||
"""
|
||||
if not index.isValid(): return
|
||||
|
||||
if self.tree_selected.split('_')[0]=='note':
|
||||
ss = self.tree_selected.split('_')[0]
|
||||
if ss=='note':
|
||||
row = index.row()
|
||||
stype = index.sibling(row, 0).data()
|
||||
sbookname = index.sibling(row, 1).data()
|
||||
@@ -316,7 +368,7 @@ class kmanWindow(QMainWindow):
|
||||
self.ui.textEdit.setHtml(notes_temp.format(
|
||||
bookname=sbookname, author=sauthor, time=stime,
|
||||
note=stype, content=scontent, position=sposition))
|
||||
else:
|
||||
elif ss=='note':
|
||||
self.render_textedit_words(self.words_data)
|
||||
|
||||
def search_button_clicked(self):
|
||||
@@ -486,7 +538,7 @@ class kmanWindow(QMainWindow):
|
||||
word_bookname_item.appendRow(item)
|
||||
|
||||
# add infos root
|
||||
self.ui.tableView.hide()
|
||||
self.ui.tableView.setVisible(True)
|
||||
info_rootItem = self.ui.model.invisibleRootItem()
|
||||
item = QStandardItem('All Books({})'.format(len(self.books_info.keys())))
|
||||
icon = QIcon()
|
||||
@@ -507,7 +559,7 @@ class kmanWindow(QMainWindow):
|
||||
for k in self.books_info.keys():
|
||||
item = QStandardItem('{}'.format(k))
|
||||
icon = QIcon()
|
||||
icon.addFile(u":/icons/book.png", QSize(), QIcon.Normal, QIcon.Off)
|
||||
icon.addFile(u":/icons/list.png", QSize(), QIcon.Normal, QIcon.Off)
|
||||
item.setIcon(icon)
|
||||
item.setAccessibleDescription('info_leaf')
|
||||
info_bookname_item.appendRow(item)
|
||||
@@ -651,7 +703,7 @@ if __name__ == "__main__":
|
||||
icon.addFile(u":/icons/Cbb20.png", QSize(), QIcon.Normal, QIcon.Off)
|
||||
kmw.setWindowIcon(icon)
|
||||
kmw.setWindowTitle("kindle management")
|
||||
kmw.resize(900, 600)
|
||||
kmw.resize(1200, 800)
|
||||
#kmw.showFullScreen()
|
||||
kmw.show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user