썬글라스가 잘 어울리는 개발고미
DEV on the Beach
썬글라스가 잘 어울리는 개발고미
전체 방문자
오늘
어제
  • 분류 전체보기 (83)
    • 공부 기록노트 (7)
      • React (3)
      • java (15)
      • !오류 (1)
      • html css (1)
      • javascript (11)
      • JSP (4)
      • python (16)
      • network (0)
      • Oracle (6)
      • Git (1)
      • 정보처리기사 (4)
      • plug-in (1)
      • 프로그램 설치 (0)
      • Spring (0)
      • CS (0)
    • 신기술 동향 (0)
    • 맛집 카페 리뷰 (3)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 제이쿼리
  • 리액트
  • java
  • JSP
  • 혼공
  • ArrayList
  • 파이썬
  • 핸드드립
  • Collection Framework
  • 프로그래머스문제풀이

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
썬글라스가 잘 어울리는 개발고미

DEV on the Beach

공부 기록노트/python

[python]day3. 파이큐티(PyQt5 ) - 로또번호 번호 출력하기

2023. 1. 3. 19:51

 

import sys

from PyQt5 import uic
from PyQt5.QtWidgets import QMainWindow, QApplication, QMessageBox
from PyQt5.Qt import QLabel
import random

form_class = uic.loadUiType("main05.ui")[0]

class MyWindow(QMainWindow, form_class):

    
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.pb.clicked.connect(self.myclick)
    
    def myclick(self):
        arr = [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,
           31,32,33,34,35,36,37,38,39,40,
           41,42,43,44,45]
        
        # 1000번섞기
        for i in range(1000):
            # 배열의 길이 5를 곱해야 4.9999 정수 4가나옴 (o)
            # random.random()=>자바의 Math.random과 같다.
            rnd = int(random.random()*len(arr))
            a = arr[rnd]
            b = arr[0]
            arr[0] = a
            arr[rnd] = b
            
        print(arr)
        self.lbl1.setText(str(arr[0]))
        self.lbl2.setText(str(arr[1]))
        self.lbl3.setText(str(arr[2]))
        self.lbl4.setText(str(arr[3]))
        self.lbl5.setText(str(arr[4]))
        self.lbl6.setText(str(arr[5]))    
           

if __name__ == "__main__":
    app = QApplication(sys.argv)
    myWindow = MyWindow()
    myWindow.show()
    app.exec_()

main05.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>363</width>
    <height>268</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>30</x>
      <y>40</y>
      <width>31</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>__</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pb">
    <property name="geometry">
     <rect>
      <x>30</x>
      <y>70</y>
      <width>231</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>40</y>
      <width>31</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>__</string>
    </property>
   </widget>
   <widget class="QLabel" name="lbl3">
    <property name="geometry">
     <rect>
      <x>110</x>
      <y>40</y>
      <width>31</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>__</string>
    </property>
   </widget>
   <widget class="QLabel" name="lbl4">
    <property name="geometry">
     <rect>
      <x>150</x>
      <y>40</y>
      <width>31</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>__</string>
    </property>
   </widget>
   <widget class="QLabel" name="lbl5">
    <property name="geometry">
     <rect>
      <x>190</x>
      <y>40</y>
      <width>31</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>__</string>
    </property>
   </widget>
   <widget class="QLabel" name="lbl6">
    <property name="geometry">
     <rect>
      <x>230</x>
      <y>40</y>
      <width>31</width>
      <height>16</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>363</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

'공부 기록노트 > python' 카테고리의 다른 글

[python]day4. 파이큐티(pyQt5) - 별 찍기  (1) 2023.01.03
[python]day3. 파이큐티(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
    '공부 기록노트/python' 카테고리의 다른 글
    • [python]day4. 파이큐티(pyQt5) - 별 찍기
    • [python]day3. 파이큐티(PyQt5 ) - 가위바위보 게임 만들기
    • [python]day3. 파이큐티(PyQt5 ) - 홀 짝 게임 만들기
    • [python]day3. 파이큐티(PyQt5 ) - 구구단 출력
    썬글라스가 잘 어울리는 개발고미
    썬글라스가 잘 어울리는 개발고미

    티스토리툴바