Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- 컬렉션 타입
- 메소드오버로딩
- 예외미루기
- 오라클
- 집합_SET
- 어윈 사용법
- GRANT VIEW
- 환경설정
- exception
- 예외처리
- 정수형타입
- 사용자예외클래스생성
- 컬렉션프레임워크
- NestedFor
- abstract
- 자바
- 한국건설관리시스템
- 대덕인재개발원
- 인터페이스
- oracle
- 제네릭
- 다형성
- cursor문
- Java
- 자동차수리시스템
- 객체 비교
- 참조형변수
- 생성자오버로드
- EnhancedFor
- 추상메서드
Archives
- Today
- Total
거니의 velog
231103_파이썬 기초 7 본문
[pyqt09.ui]
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>413</width>
<height>444</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLineEdit" name="le">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>291</width>
<height>31</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QPushButton" name="pb1">
<property name="geometry">
<rect>
<x>60</x>
<y>110</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
<widget class="QPushButton" name="pb2">
<property name="geometry">
<rect>
<x>170</x>
<y>110</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>2</string>
</property>
</widget>
<widget class="QPushButton" name="pb3">
<property name="geometry">
<rect>
<x>280</x>
<y>110</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>3</string>
</property>
</widget>
<widget class="QPushButton" name="pb4">
<property name="geometry">
<rect>
<x>60</x>
<y>180</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>4</string>
</property>
</widget>
<widget class="QPushButton" name="pb5">
<property name="geometry">
<rect>
<x>170</x>
<y>180</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>5</string>
</property>
</widget>
<widget class="QPushButton" name="pb6">
<property name="geometry">
<rect>
<x>280</x>
<y>180</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>6</string>
</property>
</widget>
<widget class="QPushButton" name="pb7">
<property name="geometry">
<rect>
<x>60</x>
<y>250</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>7</string>
</property>
</widget>
<widget class="QPushButton" name="pb8">
<property name="geometry">
<rect>
<x>170</x>
<y>250</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>8</string>
</property>
</widget>
<widget class="QPushButton" name="pb9">
<property name="geometry">
<rect>
<x>280</x>
<y>250</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>9</string>
</property>
</widget>
<widget class="QPushButton" name="pb0">
<property name="geometry">
<rect>
<x>60</x>
<y>320</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
<widget class="QPushButton" name="pbCall">
<property name="geometry">
<rect>
<x>170</x>
<y>320</y>
<width>181</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>☎</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>413</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
[day04.pyqt09]
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok01.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
# pb1 = QPushButton("", self)
# pb1.setIcon(QtGui.QIcon('0.png'))
# pb1.setIconSize(QtCore.QSize(40, 40))
# pb1.setGeometry(QtCore.QRect(0, 0, 40, 40))
# pb1.clicked.connect(self.myclick)
#
# pb2 = QPushButton("", self)
# pb2.setIcon(QtGui.QIcon('0.png'))
# pb2.setIconSize(QtCore.QSize(40, 40))
# pb2.setGeometry(QtCore.QRect(40, 0, 40, 40))
# pb2.clicked.connect(self.myclick)
for i in range(10):
for j in range(10):
pb = QPushButton("", self)
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40))
pb.clicked.connect(self.myclick)
self.show()
def myclick(self) :
# pass
print("myclick")
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok01.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
# pb1 = QPushButton("", self)
# pb1.setIcon(QtGui.QIcon('0.png'))
# pb1.setIconSize(QtCore.QSize(40, 40))
# pb1.setGeometry(QtCore.QRect(0, 0, 40, 40))
# pb1.clicked.connect(self.myclick)
#
# pb2 = QPushButton("", self)
# pb2.setIcon(QtGui.QIcon('0.png'))
# pb2.setIconSize(QtCore.QSize(40, 40))
# pb2.setGeometry(QtCore.QRect(40, 0, 40, 40))
# pb2.clicked.connect(self.myclick)
for i in range(10):
for j in range(10):
pb = QPushButton("", self)
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40))
pb.clicked.connect(self.myclick)
self.show()
def myclick(self) :
# pass
print("myclick")
self.sender().setIcon(QtGui.QIcon('1.png'))
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok01.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.flagWB = True
self.setupUi(self)
# pb1 = QPushButton("", self)
# pb1.setIcon(QtGui.QIcon('0.png'))
# pb1.setIconSize(QtCore.QSize(40, 40))
# pb1.setGeometry(QtCore.QRect(0, 0, 40, 40))
# pb1.clicked.connect(self.myclick)
#
# pb2 = QPushButton("", self)
# pb2.setIcon(QtGui.QIcon('0.png'))
# pb2.setIconSize(QtCore.QSize(40, 40))
# pb2.setGeometry(QtCore.QRect(40, 0, 40, 40))
# pb2.clicked.connect(self.myclick)
for i in range(10):
for j in range(10):
pb = QPushButton("", self)
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40))
pb.clicked.connect(self.myclick)
self.show()
def myclick(self) :
if self.flagWB:
self.sender().setIcon(QtGui.QIcon('2.png'))
else:
self.sender().setIcon(QtGui.QIcon('1.png'))
self.flagWB = not self.flagWB
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
* 오목 : 2차원 배열 이해에 좋다.
* 테트리스 : 자료구조 이해에 좋다.
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok02.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.arr2D = [
[0,0,0,0,0, 0,0,0,0,0],
[0,1,1,2,1, 0,0,0,0,0],
[0,0,0,2,2, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,1,0,0,0],
[0,0,0,0,0, 0,1,2,0,0],
[0,0,0,0,0, 0,0,0,2,0],
[0,0,0,0,0, 0,0,0,0,0]
]
self.pb2D = []
self.setupUi(self)
for i in range(10):
line = []
for j in range(10):
pb = QPushButton("", self)
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
#pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40)) # x,y축 기준
pb.setGeometry(QtCore.QRect(j*40, i*40, 40, 40)) # 배열 기준
pb.clicked.connect(self.myclick)
line.append(pb)
self.pb2D.append(line)
self.show()
self.myrender()
def myrender(self):
# self.pb2D[3][1].setIcon(QtGui.QIcon('2.png'))
for i in range(0, 10): # y축
for j in range(0, 10): # x축
if self.arr2D[i][j] == 0:
self.pb2D[i][j].setIcon(QtGui.QIcon('0.png'))
if self.arr2D[i][j] == 1:
self.pb2D[i][j].setIcon(QtGui.QIcon('1.png'))
if self.arr2D[i][j] == 2:
self.pb2D[i][j].setIcon(QtGui.QIcon('2.png'))
def myclick(self) :
print("myclick")
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok02.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.arr2D = [
[0,0,0,0,0, 0,0,0,0,0],
[0,1,1,2,1, 0,0,0,0,0],
[0,0,0,2,2, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,1,0,0,0],
[0,0,0,0,0, 0,1,2,0,0],
[0,0,0,0,0, 0,0,0,2,0],
[0,0,0,0,0, 0,0,0,0,0]
]
self.pb2D = []
self.setupUi(self)
for i in range(10):
line = []
for j in range(10):
pb = QPushButton("", self)
pb.setToolTip("{},{}".format(i,j))
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
#pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40)) # x,y축 기준
pb.setGeometry(QtCore.QRect(j*40, i*40, 40, 40)) # 배열 기준
pb.clicked.connect(self.myclick)
line.append(pb)
self.pb2D.append(line)
self.show()
self.myrender()
def myrender(self):
# self.pb2D[3][1].setIcon(QtGui.QIcon('2.png'))
for i in range(0, 10): # y축
for j in range(0, 10): # x축
if self.arr2D[i][j] == 0:
self.pb2D[i][j].setIcon(QtGui.QIcon('0.png'))
if self.arr2D[i][j] == 1:
self.pb2D[i][j].setIcon(QtGui.QIcon('1.png'))
if self.arr2D[i][j] == 2:
self.pb2D[i][j].setIcon(QtGui.QIcon('2.png'))
def myclick(self) :
# print("myclick")
# self.arr2D[0][0] = 1
# self.myrender()
str_ij = self.sender().toolTip()
# print(str_ij)
arr_ij = str_ij.split(",")
# print(arr_ij)
str_i = arr_ij[0]
str_j = arr_ij[1]
# print(str_i, str_j)
i = int(str_i)
j = int(str_j)
self.arr2D[i][j] = 1
self.myrender()
print(self.arr2D)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok02.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.arr2D = [
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0]
]
self.pb2D = []
self.flagWB = True
self.setupUi(self)
for i in range(10):
line = []
for j in range(10):
pb = QPushButton("", self)
pb.setToolTip("{},{}".format(i,j))
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
#pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40)) # x,y축 기준
pb.setGeometry(QtCore.QRect(j*40, i*40, 40, 40)) # 배열 기준
pb.clicked.connect(self.myclick)
line.append(pb)
self.pb2D.append(line)
self.show()
self.myrender()
def myrender(self):
# self.pb2D[3][1].setIcon(QtGui.QIcon('2.png'))
for i in range(0, 10): # y축
for j in range(0, 10): # x축
if self.arr2D[i][j] == 0:
self.pb2D[i][j].setIcon(QtGui.QIcon('0.png'))
if self.arr2D[i][j] == 1:
self.pb2D[i][j].setIcon(QtGui.QIcon('1.png'))
if self.arr2D[i][j] == 2:
self.pb2D[i][j].setIcon(QtGui.QIcon('2.png'))
def myclick(self) :
# print("myclick")
# self.arr2D[0][0] = 1
# self.myrender()
str_ij = self.sender().toolTip()
# print(str_ij)
arr_ij = str_ij.split(",")
# print(arr_ij)
str_i = arr_ij[0]
str_j = arr_ij[1]
# print(str_i, str_j)
i = int(str_i)
j = int(str_j)
# self.arr2D[i][j] = 1
# self.myrender()
if self.flagWB:
self.arr2D[i][j] = 2
else:
self.arr2D[i][j] = 1
self.flagWB = not self.flagWB
self.myrender()
print(self.arr2D)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok02.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.arr2D = [
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0]
]
self.pb2D = []
self.flagWB = True
self.setupUi(self)
for i in range(10):
line = []
for j in range(10):
pb = QPushButton("", self)
pb.setToolTip("{},{}".format(i,j))
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
#pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40)) # x,y축 기준
pb.setGeometry(QtCore.QRect(j*40, i*40, 40, 40)) # 배열 기준
pb.clicked.connect(self.myclick)
line.append(pb)
self.pb2D.append(line)
self.show()
self.myrender()
def myrender(self):
# self.pb2D[3][1].setIcon(QtGui.QIcon('2.png'))
for i in range(0, 10): # y축
for j in range(0, 10): # x축
if self.arr2D[i][j] == 0:
self.pb2D[i][j].setIcon(QtGui.QIcon('0.png'))
if self.arr2D[i][j] == 1:
self.pb2D[i][j].setIcon(QtGui.QIcon('1.png'))
if self.arr2D[i][j] == 2:
self.pb2D[i][j].setIcon(QtGui.QIcon('2.png'))
def myclick(self) :
# print("myclick")
# self.arr2D[0][0] = 1
# self.myrender()
str_ij = self.sender().toolTip()
# print(str_ij)
arr_ij = str_ij.split(",")
# print(arr_ij)
str_i = arr_ij[0]
str_j = arr_ij[1]
# print(str_i, str_j)
i = int(str_i)
j = int(str_j)
# self.arr2D[i][j] = 1
# self.myrender()
if self.arr2D[i][j] > 0 :
return
if self.flagWB:
self.arr2D[i][j] = 2
else:
self.arr2D[i][j] = 1
self.myrender()
self.flagWB = not self.flagWB
print(self.arr2D)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok02.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.arr2D = [
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0]
]
self.pb2D = []
self.flagWB = True
self.setupUi(self)
for i in range(10):
line = []
for j in range(10):
pb = QPushButton("", self)
pb.setToolTip("{},{}".format(i,j))
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
#pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40)) # x,y축 기준
pb.setGeometry(QtCore.QRect(j*40, i*40, 40, 40)) # 배열 기준
pb.clicked.connect(self.myclick)
line.append(pb)
self.pb2D.append(line)
self.show()
self.myrender()
def myrender(self):
# self.pb2D[3][1].setIcon(QtGui.QIcon('2.png'))
for i in range(0, 10): # y축
for j in range(0, 10): # x축
if self.arr2D[i][j] == 0:
self.pb2D[i][j].setIcon(QtGui.QIcon('0.png'))
if self.arr2D[i][j] == 1:
self.pb2D[i][j].setIcon(QtGui.QIcon('1.png'))
if self.arr2D[i][j] == 2:
self.pb2D[i][j].setIcon(QtGui.QIcon('2.png'))
def getUp(self, i, j, stone):
cnt = 0
while True:
i = i - 1
if i < 0: # 파이썬에만 있는 오류로 index가 -1이 되는 순간 역회전을 함. 이를 방지한다.
return cnt
if self.arr2D[i][j] == stone:
cnt = cnt + 1
else:
return cnt
def myclick(self) :
# print("myclick")
# self.arr2D[0][0] = 1
# self.myrender()
str_ij = self.sender().toolTip()
# print(str_ij)
arr_ij = str_ij.split(",")
# print(arr_ij)
str_i = arr_ij[0]
str_j = arr_ij[1]
# print(str_i, str_j)
i = int(str_i)
j = int(str_j)
# self.arr2D[i][j] = 1
# self.myrender()
if self.arr2D[i][j] > 0 :
return
stone = -1
if self.flagWB:
self.arr2D[i][j] = 2
stone = 2
else:
self.arr2D[i][j] = 1
stone = 1
up = self.getUp(i,j,stone)
print("up",up)
self.myrender()
self.flagWB = not self.flagWB
# print(self.arr2D)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
import sys
from PyQt5 import uic, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.Qt import QPushButton
form_class = uic.loadUiType("myomok02.ui")[0]
class MainClass(QMainWindow, form_class):
def __init__(self):
QMainWindow.__init__(self)
self.arr2D = [
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0],
[0,0,0,0,0, 0,0,0,0,0]
]
self.pb2D = []
self.flagWB = True
self.setupUi(self)
for i in range(10):
line = []
for j in range(10):
pb = QPushButton("", self)
pb.setToolTip("{},{}".format(i,j))
pb.setIcon(QtGui.QIcon('0.png'))
pb.setIconSize(QtCore.QSize(40, 40))
#pb.setGeometry(QtCore.QRect(i*40, j*40, 40, 40)) # x,y축 기준
pb.setGeometry(QtCore.QRect(j*40, i*40, 40, 40)) # 배열 기준
pb.clicked.connect(self.myclick)
line.append(pb)
self.pb2D.append(line)
self.show()
self.myrender()
def myrender(self):
# self.pb2D[3][1].setIcon(QtGui.QIcon('2.png'))
for i in range(0, 10): # y축
for j in range(0, 10): # x축
if self.arr2D[i][j] == 0:
self.pb2D[i][j].setIcon(QtGui.QIcon('0.png'))
if self.arr2D[i][j] == 1:
self.pb2D[i][j].setIcon(QtGui.QIcon('1.png'))
if self.arr2D[i][j] == 2:
self.pb2D[i][j].setIcon(QtGui.QIcon('2.png'))
def getUP(self, i, j, stone):
cnt = 0
try: # 맨 밑 단을 누르면 프로그램이 종료되는 현상을 방지하기 위한 예외 처리문
while True:
i = i - 1
if i < 0: # 파이썬에만 있는 오류로 index가 -1이 되는 순간 역회전을 함. 이를 방지한다.
return cnt
if self.arr2D[i][j] == stone:
cnt = cnt + 1
else:
return cnt
except:
return cnt
def getDW(self, i, j, stone):
cnt = 0
try: # 맨 밑 단을 누르면 프로그램이 종료되는 현상을 방지하기 위한 예외 처리문
while True:
i = i + 1
if i < 0: # 파이썬에만 있는 오류로 index가 -1이 되는 순간 역회전을 함. 이를 방지한다.
return cnt
if self.arr2D[i][j] == stone:
cnt = cnt + 1
else:
return cnt
except:
return cnt
def myclick(self) :
# print("myclick")
# self.arr2D[0][0] = 1
# self.myrender()
str_ij = self.sender().toolTip()
# print(str_ij)
arr_ij = str_ij.split(",")
# print(arr_ij)
str_i = arr_ij[0]
str_j = arr_ij[1]
# print(str_i, str_j)
i = int(str_i)
j = int(str_j)
# self.arr2D[i][j] = 1
# self.myrender()
if self.arr2D[i][j] > 0 :
return
stone = -1
if self.flagWB:
self.arr2D[i][j] = 2
stone = 2
else:
self.arr2D[i][j] = 1
stone = 1
up = self.getUP(i,j,stone)
print("up",up)
dw = self.getDW(i,j,stone)
print("dw",dw)
self.myrender()
self.flagWB = not self.flagWB
# print(self.arr2D)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainClass()
app.exec_()
'대덕인재개발원 > 대덕인재개발원_파이썬 프로그래밍' 카테고리의 다른 글
231106_DB 개론 1 (0) | 2023.11.06 |
---|---|
231106_파이썬 기초 8 (0) | 2023.11.06 |
231102_파이썬 기초 6 (0) | 2023.11.02 |
231101_파이썬 기초 5 (0) | 2023.11.01 |
231031_파이썬 기초 4 (0) | 2023.10.31 |