썬글라스가 잘 어울리는 개발고미
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)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

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

최근 댓글

최근 글

티스토리

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

DEV on the Beach

공부 기록노트/python

[python]day3. 파이큐티(PyQt5 ) - 홀 짝 게임 만들기

2023. 1. 3. 19:50
import sys

from PyQt5 import uic
from PyQt5.QtWidgets import QMainWindow, QApplication, QMessageBox
from PyQt5.Qt import QLabel
from PyQt5.uic.Compiler.qtproxies import QtWidgets, QtCore
import random
from _operator import eq


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

class MyWindow(QMainWindow, form_class):
   
    
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.pb.clicked.connect(self.myclick)
    
    def myclick(self):
        mine =""
        com =""
        result=""
        
        # print("hello")
        mine = self.leMine.text()
        print(mine)
        
        rnd = random.random();
        
        if rnd>0.5:
            com = "홀"
        else:
            com = "짝"
        
        if mine == "홀" or mine =="짝":
            if com != mine :
                result = "짐"
            else :
                result = "이김"
        elif mine != "홀" and mine !="짝" :
            result = "다시 입력"
        
        print("나:",mine)
        print("컴:",com)
        print("결과:",result)
        
        self.leCom.setText(com)
        self.leResult.setText(result)


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

main04.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>762</width>
    <height>596</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QLabel" name="lbl2">
    <property name="geometry">
     <rect>
      <x>180</x>
      <y>120</y>
      <width>91</width>
      <height>41</height>
     </rect>
    </property>
    <property name="text">
     <string>컴:</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pb">
    <property name="geometry">
     <rect>
      <x>180</x>
      <y>210</y>
      <width>191</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>게임하기</string>
    </property>
   </widget>
   <widget class="QLabel" name="lbl3">
    <property name="geometry">
     <rect>
      <x>180</x>
      <y>170</y>
      <width>91</width>
      <height>41</height>
     </rect>
    </property>
    <property name="text">
     <string>결과:</string>
    </property>
   </widget>
   <widget class="QLabel" name="lbl1">
    <property name="geometry">
     <rect>
      <x>180</x>
      <y>80</y>
      <width>91</width>
      <height>41</height>
     </rect>
    </property>
    <property name="text">
     <string>나:</string>
    </property>
   </widget>
   <widget class="QLineEdit" name="leMine">
    <property name="geometry">
     <rect>
      <x>230</x>
      <y>90</y>
      <width>113</width>
      <height>20</height>
     </rect>
    </property>
   </widget>
   <widget class="QLineEdit" name="leCom">
    <property name="geometry">
     <rect>
      <x>230</x>
      <y>130</y>
      <width>113</width>
      <height>20</height>
     </rect>
    </property>
   </widget>
   <widget class="QLineEdit" name="leResult">
    <property name="geometry">
     <rect>
      <x>230</x>
      <y>180</y>
      <width>113</width>
      <height>21</height>
     </rect>
    </property>
    <property name="inputMask">
     <string/>
    </property>
    <property name="text">
     <string/>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>762</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

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

[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]day3. 파이큐티(PyQt5 ) 시작하기 - designer실행  (1) 2023.01.03
    '공부 기록노트/python' 카테고리의 다른 글
    • [python]day3. 파이큐티(PyQt5 ) - 가위바위보 게임 만들기
    • [python]day3. 파이큐티(PyQt5 ) - 로또번호 번호 출력하기
    • [python]day3. 파이큐티(PyQt5 ) - 구구단 출력
    • [python]day3. 파이큐티(PyQt5 ) - 숫자 증가시키기
    썬글라스가 잘 어울리는 개발고미
    썬글라스가 잘 어울리는 개발고미

    티스토리툴바