Update UI.py, UtilPack.py, and ui_Tki.py
This commit is contained in:
52
UI.py
52
UI.py
@@ -129,10 +129,29 @@ class MyApp(QMainWindow):
|
||||
# 소스 폴더 목록에 추가
|
||||
self.list_SrcPath.addItem(folder_path)
|
||||
|
||||
#캘리버 서재 폴더인가?
|
||||
pathCalDB = os.path.join( folder_path, "metadata.db")
|
||||
if True == os.path.exists(pathCalDB):
|
||||
db = calDB.MgrCalibreDB(pathCalDB)
|
||||
db.init()
|
||||
listBooks = db.GetBookListforUI_ArcList()
|
||||
for book in listBooks:
|
||||
# 이름은 폴더/DB 파일이름
|
||||
FolderName = util.GetParentDirName(folder_path, 0)
|
||||
item = QListWidgetItem(f"{FolderName}/{book[0]}")
|
||||
|
||||
bookpath = os.path.join(folder_path, book[1])
|
||||
listfiles = util.FindFileFromExt(bookpath, "cbz")
|
||||
if 0 < len(listfiles):
|
||||
bookpath = os.path.join(bookpath, listfiles[0])
|
||||
|
||||
item.setData(Qt.UserRole, bookpath)
|
||||
self.list_ArcList.addItem(item)
|
||||
|
||||
return
|
||||
|
||||
# 폴더 내의 자식 폴더 목록을 가져온다.
|
||||
listFolders = util.ListSubDirectories(folder_path)
|
||||
|
||||
# 선택한 폴더도 리스트에 추가한다.
|
||||
listFolders.append(folder_path)
|
||||
|
||||
for folder in listFolders:
|
||||
@@ -140,8 +159,7 @@ class MyApp(QMainWindow):
|
||||
listFiles = util.ListContainFiles(folder)
|
||||
|
||||
# 파일 목록을 훑어서 내용을 판단
|
||||
# 1. 압축파일이 들어있나?
|
||||
# 2. 이미지 파일이 들어있나?
|
||||
# 1. 압축파일이 들어있나? 2. 이미지 파일이 들어있나?
|
||||
isImgIn = False
|
||||
for pathFile in listFiles:
|
||||
filename = util.GetParentDirName(pathFile, 0)
|
||||
@@ -157,25 +175,6 @@ class MyApp(QMainWindow):
|
||||
item.setData(Qt.UserRole, pathFile)
|
||||
self.list_ArcList.addItem(item)
|
||||
|
||||
|
||||
# 데이터베이스 파일이 들어 있다면...
|
||||
if fileExt.lower() in [".db"]:
|
||||
# 이름은 폴더/DB 파일이름
|
||||
FolderName = util.GetParentDirName(pathFile, 1)
|
||||
ItemName = os.path.join(FolderName, filename)
|
||||
item = QListWidgetItem(ItemName)
|
||||
# 전체 경로를 따로 저장
|
||||
#item.setData(Qt.UserRole, pathFile)
|
||||
#self.list_ArcList.addItem(item)
|
||||
print(pathFile)
|
||||
db = calDB.MgrCalibreDB(pathFile)
|
||||
db.init()
|
||||
listBooks = db.GetBookListforUI_ArcList()
|
||||
for book in listBooks:
|
||||
item.setData(Qt.UserRole, book[1])
|
||||
self.list_ArcList.addItem(book[0])
|
||||
|
||||
|
||||
# 이미지 파일이 들어있다면...
|
||||
if fileExt.lower() in [".jpg", ".webp", ".jpeg", ".png", ".gif"]:
|
||||
isImgIn = True
|
||||
@@ -187,7 +186,8 @@ class MyApp(QMainWindow):
|
||||
# 폴더 경로를 따로 저장
|
||||
item.setData(Qt.UserRole, folder)
|
||||
self.list_ArcList.addItem(item)
|
||||
|
||||
|
||||
return
|
||||
|
||||
def on_click_SrcDel(self):
|
||||
items = self.list_SrcPath.selectedItems()
|
||||
@@ -215,8 +215,8 @@ class MyApp(QMainWindow):
|
||||
for item in items:
|
||||
pathTarget = item.data(Qt.UserRole)
|
||||
|
||||
print(f"arc : {pathTarget}")
|
||||
if False == os.path.exists(pathTarget):
|
||||
print(pathTarget)
|
||||
if None == pathTarget or False == os.path.exists(pathTarget):
|
||||
return
|
||||
|
||||
# 압축파일일 경우...
|
||||
|
||||
13
UtilPack.py
13
UtilPack.py
@@ -13,10 +13,12 @@ from pathlib import Path
|
||||
m_dbgLevel = 0
|
||||
listDbgStr = []
|
||||
|
||||
|
||||
#
|
||||
def IsEmptyStr(string):
|
||||
return 0 == len(string.strip())
|
||||
|
||||
|
||||
#
|
||||
def GetCurrentTime():
|
||||
# 현재 시간을 구하고 구조체로 변환
|
||||
@@ -34,6 +36,7 @@ def GetCurrentTime():
|
||||
|
||||
return strRet
|
||||
|
||||
|
||||
#for debug
|
||||
def DbgOut(strInput, bPrint = False):
|
||||
strMsg = (f"{GetCurrentTime()} : {strInput}")
|
||||
@@ -63,6 +66,7 @@ def ListSubDirectories(root_dir):
|
||||
|
||||
return subdirectories
|
||||
|
||||
|
||||
# 자식 폴더를 구해온다. 직계 자식만
|
||||
def ListChildDirectories(pathDir):
|
||||
listRet = []
|
||||
@@ -73,6 +77,7 @@ def ListChildDirectories(pathDir):
|
||||
|
||||
return listRet
|
||||
|
||||
|
||||
# 파일목록만 구해온다. 자식 폴더에 있는건 무시.
|
||||
def ListContainFiles(pathDir):
|
||||
listRet = []
|
||||
@@ -83,6 +88,7 @@ def ListContainFiles(pathDir):
|
||||
|
||||
return listRet
|
||||
|
||||
|
||||
def ListFileExtRcr(pathTrg, listExt):
|
||||
listRet= []
|
||||
|
||||
@@ -128,6 +134,7 @@ def IsFinalFolder(path):
|
||||
|
||||
return bRet;
|
||||
|
||||
|
||||
# 어떤 경로 안에서 특정 확장자의 파일을 뽑아내어 그 리스트를 반환한다.
|
||||
def FindFileFromExt(path, ext):
|
||||
bDot = False
|
||||
@@ -148,7 +155,8 @@ def FindFileFromExt(path, ext):
|
||||
listRet.append(item)
|
||||
|
||||
return listRet
|
||||
|
||||
|
||||
|
||||
# 파일 이름에서 확장자를 뽑아낸다. True : '.' 을 포함한다.
|
||||
def GetExtStr(file_path, bDot = True):
|
||||
retStr = ""
|
||||
@@ -164,6 +172,7 @@ def GetExtStr(file_path, bDot = True):
|
||||
|
||||
return retStr
|
||||
|
||||
|
||||
# 문자열에 포함된 단어를 지운다.
|
||||
def RmvSubString(mainString, subString):
|
||||
# 문자열에서 부분 문자열의 인덱스를 찾습니다.
|
||||
@@ -176,10 +185,12 @@ def RmvSubString(mainString, subString):
|
||||
# 부분 문자열을 제거하고 새로운 문자열을 반환합니다.
|
||||
return mainString[:strIdx] + mainString[endIdx:]
|
||||
|
||||
|
||||
def ExtractZIP(zip_file, extract_to):
|
||||
with zipfile.ZipFile(zip_file, 'r') as zf:
|
||||
zf.extractall(extract_to)
|
||||
|
||||
|
||||
#
|
||||
def CreateZIP(output_zip, *files):
|
||||
with zipfile.ZipFile(output_zip, 'w') as zf:
|
||||
|
||||
26
ui_Tki.py
Normal file
26
ui_Tki.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
import sys
|
||||
import tkinter as tk
|
||||
|
||||
def sayhello():
|
||||
print("Hello")
|
||||
|
||||
def main(argc, argv):
|
||||
# 기본 창 설정
|
||||
root = tk.Tk()
|
||||
root.title("Hello World App") # 창 제목 설정
|
||||
root.geometry("300x200") # 창 크기 설정
|
||||
|
||||
# 버튼 생성
|
||||
button = tk.Button(root, text="Click Me", command=sayhello)
|
||||
|
||||
# 버튼을 창에 배치
|
||||
button.pack(pady=20)
|
||||
|
||||
# 이벤트 루프 실행
|
||||
root.mainloop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
argc = len(sys.argv)
|
||||
argv = sys.argv
|
||||
main(argc, argv)
|
||||
Reference in New Issue
Block a user