Skip to content

Commit ae42778

Browse files
committed
- Build issue resolve
1 parent 39e02d0 commit ae42778

File tree

3 files changed

+54
-43
lines changed

3 files changed

+54
-43
lines changed

build.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
{
2121
"optionDest": "icon_file",
22-
"value": "C:/Users/pgh26/PycharmProjects/DCINSIDE_SEARCH/main.ico"
22+
"value": "C:/Users/pgh26/PycharmProjects/DCINSIDE_SEARCH/resource/main.ico"
2323
},
2424
{
2525
"optionDest": "ascii",
@@ -65,21 +65,13 @@
6565
"optionDest": "bootloader_ignore_signals",
6666
"value": false
6767
},
68-
{
69-
"optionDest": "datas",
70-
"value": "C:/Users/pgh26/PycharmProjects/DCINSIDE_SEARCH/main.ico;."
71-
},
72-
{
73-
"optionDest": "datas",
74-
"value": "C:/Users/pgh26/PycharmProjects/DCINSIDE_SEARCH/git.png;."
75-
},
7668
{
7769
"optionDest": "datas",
7870
"value": "C:/Users/pgh26/PycharmProjects/DCINSIDE_SEARCH/main.ui;."
7971
}
8072
],
8173
"nonPyinstallerOptions": {
82-
"increaseRecursionLimit": false,
74+
"increaseRecursionLimit": true,
8375
"manualArguments": ""
8476
}
8577
}

main.py

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
from module.article_parser import DCArticleParser
1313
from module.headers import search_type
14-
from module.resource import resource_path
14+
15+
# from module.resource import resource_path
1516

1617
# Global --------------------------------------------
1718

@@ -34,7 +35,8 @@ class SearchThread(QThread):
3435
# 메인폼에서 상속받기
3536
def __init__(self, parent): # parent는 WindowClass에서 전달하는 self이다.(WidnowClass의 인스턴스)
3637
super().__init__(parent)
37-
self.parent = parent # self.parent를 사용하여 부모의 메서드나 데이터에 접근 가능하다. (단 Thread-safe 를 위해 UI는 시그널 - 슬롯으로 접근해야 한다.)
38+
# self.parent를 사용하여 부모의 메서드나 데이터에 접근 가능하다. (단 Thread-safe 를 위해 UI는 시그널 - 슬롯으로 접근해야 한다.)
39+
self.parent = parent
3840

3941
def run(self):
4042
global running, parser
@@ -67,8 +69,10 @@ def run(self):
6769
if not running:
6870
return
6971

70-
self.QLabelWidgetUpdate.emit(f'상태 : {idx}/{loop_count} 탐색중...')
71-
article = parser.article_parse(keyword, s_type, page=i, search_pos=search_pos)
72+
self.QLabelWidgetUpdate.emit(
73+
f'상태 : {idx}/{loop_count} 탐색중...')
74+
article = parser.article_parse(
75+
keyword, s_type, page=i, search_pos=search_pos)
7276
self.QTableWidgetUpdate.emit(article)
7377

7478
idx += 1 # 글을 하나 탐색하면 + 1
@@ -87,6 +91,11 @@ def stop(self):
8791
self.quit()
8892
self.wait(3000)
8993

94+
# 모듈화에 문제가 생겨서 우선 하드 코딩
95+
def resource_path(relative_path):
96+
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
97+
return os.path.join(base_path, relative_path)
98+
9099

91100
# Main UI Load
92101
main_ui = resource_path('main.ui')
@@ -115,7 +124,8 @@ def closeEvent(self, QCloseEvent):
115124
keyword = self.txt_keyword.text()
116125
comboBox = self.comboBox.currentText()
117126

118-
data = {'repeat': repeat, 'gallary_id': gallary_id, 'keyword': keyword, 'search_type': comboBox}
127+
data = {'repeat': repeat, 'gallary_id': gallary_id,
128+
'keyword': keyword, 'search_type': comboBox}
119129
self.save_data(data, 'user_save.dat')
120130

121131
self.deleteLater()
@@ -143,15 +153,16 @@ def set_only_int(self):
143153
self.txt_repeat.setValidator(self.onlyInt)
144154

145155
def setTableWidget(self):
146-
self.articleView.setEditTriggers(QAbstractItemView.NoEditTriggers) # TableWidget 읽기 전용 설정
147-
self.articleView.setColumnWidth(0, 60); # 글 번호
148-
self.articleView.setColumnWidth(1, 430); # 제목
149-
self.articleView.setColumnWidth(2, 50); # 댓글수
156+
self.articleView.setEditTriggers(
157+
QAbstractItemView.NoEditTriggers) # TableWidget 읽기 전용 설정
158+
self.articleView.setColumnWidth(0, 60) # 글 번호
159+
self.articleView.setColumnWidth(1, 430) # 제목
160+
self.articleView.setColumnWidth(2, 50) # 댓글수
150161

151-
self.articleView.setColumnWidth(3, 100); # 글쓴이
152-
self.articleView.setColumnWidth(4, 60); # 작성일
153-
self.articleView.setColumnWidth(5, 40); # 조회
154-
self.articleView.setColumnWidth(6, 40); # 추천
162+
self.articleView.setColumnWidth(3, 100) # 글쓴이
163+
self.articleView.setColumnWidth(4, 60) # 작성일
164+
self.articleView.setColumnWidth(5, 40) # 조회
165+
self.articleView.setColumnWidth(6, 40) # 추천
155166

156167
def setTableAutoSize(self):
157168
header = self.articleView.horizontalHeader()
@@ -196,7 +207,8 @@ def search(self): # 글검색
196207
# 쓰레드 작업 시작
197208
self.thread.start()
198209
else:
199-
QMessageBox.information(self, '알림', '값을 전부 입력해주세요.', QMessageBox.Yes)
210+
QMessageBox.information(
211+
self, '알림', '값을 전부 입력해주세요.', QMessageBox.Yes)
200212

201213
# 리스트뷰 아이템 더블클릭
202214
def item_dbl_click(self):
@@ -233,24 +245,31 @@ def QTableWidgetUpdate(self, article):
233245
self.articleView.insertRow(row_position)
234246

235247
item_num = QTableWidgetItem()
236-
item_num.setData(Qt.DisplayRole, int(data['num'])) # 숫자로 설정 (정렬을 위해)
248+
item_num.setData(Qt.DisplayRole, int(
249+
data['num'])) # 숫자로 설정 (정렬을 위해)
237250
self.articleView.setItem(row_position, 0, item_num)
238251

239-
self.articleView.setItem(row_position, 1, QTableWidgetItem(data['title']))
252+
self.articleView.setItem(
253+
row_position, 1, QTableWidgetItem(data['title']))
240254

241255
item_reply = QTableWidgetItem()
242-
item_reply.setData(Qt.DisplayRole, int(data['reply'])) # 숫자로 설정 (정렬을 위해)
256+
item_reply.setData(Qt.DisplayRole, int(
257+
data['reply'])) # 숫자로 설정 (정렬을 위해)
243258
self.articleView.setItem(row_position, 2, item_reply)
244259

245-
self.articleView.setItem(row_position, 3, QTableWidgetItem(data['nickname']))
246-
self.articleView.setItem(row_position, 4, QTableWidgetItem(data['timestamp']))
260+
self.articleView.setItem(
261+
row_position, 3, QTableWidgetItem(data['nickname']))
262+
self.articleView.setItem(
263+
row_position, 4, QTableWidgetItem(data['timestamp']))
247264

248265
item_refresh = QTableWidgetItem()
249-
item_refresh.setData(Qt.DisplayRole, int(data['refresh'])) # 숫자로 설정 (정렬을 위해)
266+
item_refresh.setData(Qt.DisplayRole, int(
267+
data['refresh'])) # 숫자로 설정 (정렬을 위해)
250268
self.articleView.setItem(row_position, 5, item_refresh)
251269

252270
item_recommend = QTableWidgetItem()
253-
item_recommend.setData(Qt.DisplayRole, int(data['recommend'])) # 숫자로 설정 (정렬을 위해)
271+
item_recommend.setData(Qt.DisplayRole, int(
272+
data['recommend'])) # 숫자로 설정 (정렬을 위해)
254273
self.articleView.setItem(row_position, 6, item_recommend)
255274

256275
@pyqtSlot(str)

module/resource.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import os, sys
22

3-
# def resource_path(relative_path):
4-
# """
5-
#
6-
# :param relative_path: 상대 경로
7-
# 상대 경로를 절대 경로로 바꿔주는 함수
8-
#
9-
# pyinstaller 파일 포함시 UI 파일이나 리소스 파일을 절대 경로로 포함시켜야 exe 빌드후에도 파일을 잘 찾아낼 수 있다.
10-
#
11-
# """
12-
#
13-
# base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
14-
# return os.path.join(base_path, relative_path)
3+
def resource_path(relative_path):
4+
"""
5+
6+
:param relative_path: 상대 경로
7+
상대 경로를 절대 경로로 바꿔주는 함수
8+
9+
pyinstaller 파일 포함시 UI 파일이나 리소스 파일을 절대 경로로 포함시켜야 exe 빌드후에도 파일을 잘 찾아낼 수 있다.
10+
11+
"""
12+
13+
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
14+
return os.path.join(base_path, relative_path)
1515

1616
def resource_path(relative_path):
1717
"""

0 commit comments

Comments
 (0)