@@ -78,9 +78,9 @@ def set_rcp(self, row, column, pixSize):
7878 self .importCellPic (pixSize )
7979 # self.resize(QtCore.QSize(pixSize * column + 8, pixSize * row + 8))
8080 self .setMinimumSize (QtCore .QSize (
81- pixSize * column + 8 , pixSize * row + 8 ))
81+ pixSize * column , pixSize * row ))
8282 self .setMaximumSize (QtCore .QSize (
83- pixSize * column + 8 , pixSize * row + 8 ))
83+ pixSize * column , pixSize * row ))
8484 # self.current_x = self.row # 鼠标坐标,和高亮的展示有关
8585 # self.current_y = self.column
8686
@@ -97,8 +97,9 @@ def set_rcp(self, row, column, pixSize):
9797
9898 def mousePressEvent (self , e ):
9999 # 重载一下鼠标点击事件
100- xx = int (e .localPos ().x () - 4 )
101- yy = int (e .localPos ().y () - 4 )
100+ xx = int (e .localPos ().x ())
101+ yy = int (e .localPos ().y ())
102+ # print("press: ", xx, yy)
102103 if yy < 0 or xx < 0 or yy >= self .row * self .pixSize or \
103104 xx >= self .column * self .pixSize :
104105 self .current_x = self .row * self .pixSize
@@ -119,8 +120,9 @@ def mousePressEvent(self, e):
119120 def mouseReleaseEvent (self , e ):
120121 #每个标签的鼠标事件发射给槽的都是自身的坐标
121122 #所以获取释放点相对本标签的偏移量,矫正发射的信号
122- xx = int (e .localPos ().x () - 4 )
123- yy = int (e .localPos ().y () - 4 )
123+ xx = int (e .localPos ().x ())
124+ yy = int (e .localPos ().y ())
125+ # print("release: ", xx, yy)
124126
125127 if yy < 0 or xx < 0 or yy >= self .row * self .pixSize or \
126128 xx >= self .column * self .pixSize :
@@ -136,8 +138,8 @@ def mouseReleaseEvent(self, e):
136138 self .rightRelease .emit (self .current_x , self .current_y )
137139
138140 def mouseMoveEvent (self , e ):
139- xx = int (e .localPos ().x () - 4 )
140- yy = int (e .localPos ().y () - 4 )
141+ xx = int (e .localPos ().x ())
142+ yy = int (e .localPos ().y ())
141143 # print('移动位置{}, {}'.format(xx, yy))
142144 if yy < 0 or xx < 0 or yy >= self .row * self .pixSize or \
143145 xx >= self .column * self .pixSize :
@@ -152,14 +154,15 @@ def wheelEvent(self, event):
152154 # 滚轮事件
153155 angle = event .angleDelta ()
154156 angle_y = angle .y ()
155- xx = int (event .x () - 4 ) # 距离左侧
156- yy = int (event .y () - 4 ) # 距离上方
157+ xx = int (event .x ()) # 距离左侧
158+ yy = int (event .y ()) # 距离上方
157159 if yy < 0 or xx < 0 or yy >= self .row * self .pixSize or \
158160 xx >= self .column * self .pixSize :
159161 self .mousewheelEvent .emit (angle_y , self .row , self .column )
160162 else :
161163 self .mousewheelEvent .emit (angle_y , yy // self .pixSize , xx // self .pixSize )
162164
165+
163166 def paintEvent (self , event ):
164167 super ().paintEvent (event )
165168 pix_size = self .pixSize
@@ -184,16 +187,16 @@ def paintEvent(self, event):
184187 for i in range (row ):
185188 for j in range (column ):
186189 if game_board [i ][j ] == 10 :
187- painter .drawPixmap (j * pix_size + 4 , i * pix_size + 4 , QPixmap (self .pixmapNum [10 ]))
190+ painter .drawPixmap (j * pix_size , i * pix_size , QPixmap (self .pixmapNum [10 ]))
188191 if self .paintProbability : # 画概率
189192 if self .paint_cursor :
190193 painter .setOpacity (self .ms_board .game_board_poss [i ][j ])
191194 else :
192195 painter .setOpacity (self .boardProbability [i ][j ])
193- painter .drawPixmap (j * pix_size + 4 , i * pix_size + 4 , QPixmap (self .pixmapNum [100 ]))
196+ painter .drawPixmap (j * pix_size , i * pix_size , QPixmap (self .pixmapNum [100 ]))
194197 painter .setOpacity (1.0 )
195198 else :
196- painter .drawPixmap (j * pix_size + 4 , i * pix_size + 4 , QPixmap (self .pixmapNum [game_board [i ][j ]]))
199+ painter .drawPixmap (j * pix_size , i * pix_size , QPixmap (self .pixmapNum [game_board [i ][j ]]))
197200
198201
199202 # 画高亮
@@ -203,12 +206,12 @@ def paintEvent(self, event):
203206 for r in range (max (current_x - 1 , 0 ), min (current_x + 2 , row )):
204207 for c in range (max (current_y - 1 , 0 ), min (current_y + 2 , column )):
205208 if game_board [r ][c ] == 10 :
206- painter .drawPixmap (c * pix_size + 4 , r * pix_size + 4 , QPixmap (self .pixmapNum [0 ]))
209+ painter .drawPixmap (c * pix_size , r * pix_size , QPixmap (self .pixmapNum [0 ]))
207210 elif mouse_state == 4 and game_board [current_x ][current_y ] == 10 :
208- painter .drawPixmap (current_y * pix_size + 4 , current_x * pix_size + 4 , QPixmap (self .pixmapNum [0 ]))
211+ painter .drawPixmap (current_y * pix_size , current_x * pix_size , QPixmap (self .pixmapNum [0 ]))
209212 # 画光标
210213 if self .paint_cursor :
211- painter .translate (x + 4 , y + 4 )
214+ painter .translate (x , y )
212215 painter .drawPath (self .mouse )
213216 painter .fillPath (self .mouse ,Qt .white )
214217 painter .end ()
0 commit comments