11
11
12
12
from module .article_parser import DCArticleParser
13
13
from module .headers import search_type
14
- from module .resource import resource_path
14
+
15
+ # from module.resource import resource_path
15
16
16
17
# Global --------------------------------------------
17
18
@@ -34,7 +35,8 @@ class SearchThread(QThread):
34
35
# 메인폼에서 상속받기
35
36
def __init__ (self , parent ): # parent는 WindowClass에서 전달하는 self이다.(WidnowClass의 인스턴스)
36
37
super ().__init__ (parent )
37
- self .parent = parent # self.parent를 사용하여 부모의 메서드나 데이터에 접근 가능하다. (단 Thread-safe 를 위해 UI는 시그널 - 슬롯으로 접근해야 한다.)
38
+ # self.parent를 사용하여 부모의 메서드나 데이터에 접근 가능하다. (단 Thread-safe 를 위해 UI는 시그널 - 슬롯으로 접근해야 한다.)
39
+ self .parent = parent
38
40
39
41
def run (self ):
40
42
global running , parser
@@ -67,8 +69,10 @@ def run(self):
67
69
if not running :
68
70
return
69
71
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 )
72
76
self .QTableWidgetUpdate .emit (article )
73
77
74
78
idx += 1 # 글을 하나 탐색하면 + 1
@@ -87,6 +91,11 @@ def stop(self):
87
91
self .quit ()
88
92
self .wait (3000 )
89
93
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
+
90
99
91
100
# Main UI Load
92
101
main_ui = resource_path ('main.ui' )
@@ -115,7 +124,8 @@ def closeEvent(self, QCloseEvent):
115
124
keyword = self .txt_keyword .text ()
116
125
comboBox = self .comboBox .currentText ()
117
126
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 }
119
129
self .save_data (data , 'user_save.dat' )
120
130
121
131
self .deleteLater ()
@@ -143,15 +153,16 @@ def set_only_int(self):
143
153
self .txt_repeat .setValidator (self .onlyInt )
144
154
145
155
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 ) # 댓글수
150
161
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 ) # 추천
155
166
156
167
def setTableAutoSize (self ):
157
168
header = self .articleView .horizontalHeader ()
@@ -196,7 +207,8 @@ def search(self): # 글검색
196
207
# 쓰레드 작업 시작
197
208
self .thread .start ()
198
209
else :
199
- QMessageBox .information (self , '알림' , '값을 전부 입력해주세요.' , QMessageBox .Yes )
210
+ QMessageBox .information (
211
+ self , '알림' , '값을 전부 입력해주세요.' , QMessageBox .Yes )
200
212
201
213
# 리스트뷰 아이템 더블클릭
202
214
def item_dbl_click (self ):
@@ -233,24 +245,31 @@ def QTableWidgetUpdate(self, article):
233
245
self .articleView .insertRow (row_position )
234
246
235
247
item_num = QTableWidgetItem ()
236
- item_num .setData (Qt .DisplayRole , int (data ['num' ])) # 숫자로 설정 (정렬을 위해)
248
+ item_num .setData (Qt .DisplayRole , int (
249
+ data ['num' ])) # 숫자로 설정 (정렬을 위해)
237
250
self .articleView .setItem (row_position , 0 , item_num )
238
251
239
- self .articleView .setItem (row_position , 1 , QTableWidgetItem (data ['title' ]))
252
+ self .articleView .setItem (
253
+ row_position , 1 , QTableWidgetItem (data ['title' ]))
240
254
241
255
item_reply = QTableWidgetItem ()
242
- item_reply .setData (Qt .DisplayRole , int (data ['reply' ])) # 숫자로 설정 (정렬을 위해)
256
+ item_reply .setData (Qt .DisplayRole , int (
257
+ data ['reply' ])) # 숫자로 설정 (정렬을 위해)
243
258
self .articleView .setItem (row_position , 2 , item_reply )
244
259
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' ]))
247
264
248
265
item_refresh = QTableWidgetItem ()
249
- item_refresh .setData (Qt .DisplayRole , int (data ['refresh' ])) # 숫자로 설정 (정렬을 위해)
266
+ item_refresh .setData (Qt .DisplayRole , int (
267
+ data ['refresh' ])) # 숫자로 설정 (정렬을 위해)
250
268
self .articleView .setItem (row_position , 5 , item_refresh )
251
269
252
270
item_recommend = QTableWidgetItem ()
253
- item_recommend .setData (Qt .DisplayRole , int (data ['recommend' ])) # 숫자로 설정 (정렬을 위해)
271
+ item_recommend .setData (Qt .DisplayRole , int (
272
+ data ['recommend' ])) # 숫자로 설정 (정렬을 위해)
254
273
self .articleView .setItem (row_position , 6 , item_recommend )
255
274
256
275
@pyqtSlot (str )
0 commit comments