import sys
from PyQt5 import uic
from PyQt5.QtWidgets import QMainWindow, QApplication, QMessageBox
from PyQt5.Qt import QLabel
form_class = uic.loadUiType("main07.ui")[0]
class MyWindow(QMainWindow, form_class):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pb.clicked.connect(self.myclick)
def drawStar(self,cnt):
ret = ""
for i in range(cnt):
ret += "*"
ret += "\n"
return ret
def myclick(self):
f = self.le_first.text()
l = self.le_last.text()
ff = int(f)
ll = int(l)
txt=""
for i in range(ff, ll+1):
txt += self.drawStar(i)
# txt+= self.drawStar(1)
# txt+= self.drawStar(2)
#print(f,l,p)
self.pte.setPlainText(txt)
if __name__ == "__main__":
app = QApplication(sys.argv)
myWindow = MyWindow()
myWindow.show()
app.exec_()
main07.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>318</width>
<height>414</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLabel" name="lbl1">
<property name="geometry">
<rect>
<x>70</x>
<y>30</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>첫번째별수:</string>
</property>
</widget>
<widget class="QPushButton" name="pb">
<property name="geometry">
<rect>
<x>60</x>
<y>90</y>
<width>181</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>출력하기</string>
</property>
</widget>
<widget class="QLabel" name="lbl2">
<property name="geometry">
<rect>
<x>70</x>
<y>60</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>마지막별수:</string>
</property>
</widget>
<widget class="QLineEdit" name="le_first">
<property name="geometry">
<rect>
<x>170</x>
<y>30</y>
<width>71</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="le_last">
<property name="geometry">
<rect>
<x>170</x>
<y>60</y>
<width>71</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QPlainTextEdit" name="pte">
<property name="geometry">
<rect>
<x>60</x>
<y>130</y>
<width>181</width>
<height>221</height>
</rect>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>318</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
'공부 기록노트 > python' 카테고리의 다른 글
[python]day4. 파이큐티(pyQt5) - 곱하기 연산 (0) | 2023.01.03 |
---|---|
[python]day4. 파이큐티(pyQt5) - 전화번호 찍기 (0) | 2023.01.03 |
[python]day3. 파이큐티(PyQt5 ) - 가위바위보 게임 만들기 (0) | 2023.01.03 |
[python]day3. 파이큐티(PyQt5 ) - 로또번호 번호 출력하기 (0) | 2023.01.03 |
[python]day3. 파이큐티(PyQt5 ) - 홀 짝 게임 만들기 (0) | 2023.01.03 |