Nice to meet you with python

Introduction

I entered the school from April, but I haven't been to school except for the entrance ceremony, so I haven't made any friends: cry: Of course, studying is the most important thing because it is a school, but I think it is also important to make friends. So, I decided to introduce myself a little in ** quiz format ** using python. (The name will not be posted on Qiita due to privacy issues)


Think about your first impression

I thought about information that can be easily understood when face-to-face After all, the best is ** face **, but it is difficult to explain the face. Then, the next information you can find is ** height ** So I thought I'd ask everyone to guess my height

Think about your height

If you don't enter my height exactly, you won't get the correct answer If you're too tall, you'll get caught up in me


import tkinter as tk
import tkinter.messagebox as tmsg

def ButtonClick_h():
    h = editboxl_h.get()
    c = editboxl_h.get()
    
    my_h = False
    if len(c) != 3:
        tmsg.showinfo("mistake", "Enter a 3-digit number!")
    else:
        kazuok = True
        for i in range(1):
            if (h[i] < "0") or (h[i] > "9"):
                tmsg.showerror("error", "Numbers!")
                kazuok = False
                break
            if kazuok :
                my_h = True             

    if my_h :
        if int(h) == 174:
            tmsg.showinfo("Correct answer", "I'll do it!")    
        elif 170 <= int(h) < 174:
            tmsg.showinfo("I'm sorry!", "It ’s a little higher!")
        elif 174 < int(h) <= 179:
            tmsg.showinfo("I'm sorry!", "It ’s a little lower!")
        elif int(h) < 170:
            tmsg.showinfo("At all!", "Such a small one!")         
        else:
            int(h) > 180
            tmsg.showinfo("At all!", "That's not the case!" )

Think about what to say if you introduce yourself face-to-face

I've introduced myself several times before, but I thought about what I was talking about. I talk a lot, but I thought the next thing to say after the name was ** birthday ** and ** favorite thing **


Think about your birthday

If you don't guess your birthday, you won't get the correct answer

def ButtonClick_b():
    b = editboxl_b.get()
    d = editboxl_b.get()    
    
    my_b = False
    if len(d) != 1:
        tmsg.showinfo("mistake", "Great tip! In a single digit!")
    else:
        kazuok = True
        for i in range(1):
            if (b[i] < "0") or (b[i] > "9"):
                tmsg.showerror("error", "Not a number")
                kazuok = False
                break
            if kazuok :
                my_b = True             

    if my_b :
        if int(b) == 3:
            tmsg.showinfo("Correct answer", "大Correct answer!君とは気が合うかもね(笑)")    
        elif 1 <= int(b) < 2:
            tmsg.showinfo("I'm sorry!", "It ’s a little higher")
        elif 4 < int(b) <= 6:
            tmsg.showinfo("I'm sorry!", "A little lower")     
        else:
            int(b) > 6
            tmsg.showinfo("At all!", "The temperature is just right(Tips)" )

Guess what you like

I like sports, but I get the ones I especially like This is a program where you can win from "basketball," "baseball," and "soccer."

def ButtonClick_s1():
    tmsg.showinfo("No!", "Basketball is also interesting though! !!")            

def ButtonClick_s2():
    tmsg.showinfo("Correct answer", "Baseball is the best! !!" )

def ButtonClick_s3():
    tmsg.showinfo("No!", "I'm not very good at soccer.")

Final result


import tkinter as tk
import tkinter.messagebox as tmsg

def ButtonClick_h():
    h = editboxl_h.get()
    c = editboxl_h.get()
    
    my_h = False
    if len(c) != 3:
        tmsg.showinfo("mistake", "Enter a 3-digit number!")
    else:
        kazuok = True
        for i in range(1):
            if (h[i] < "0") or (h[i] > "9"):
                tmsg.showerror("error", "Numbers!")
                kazuok = False
                break
            if kazuok :
                my_h = True             

    if my_h :
        if int(h) == 174:
            tmsg.showinfo("Correct answer", "I'll do it!")    
        elif 170 <= int(h) < 174:
            tmsg.showinfo("I'm sorry!", "It ’s a little higher!")
        elif 174 < int(h) <= 179:
            tmsg.showinfo("I'm sorry!", "It ’s a little lower!")
        elif int(h) < 170:
            tmsg.showinfo("At all!", "Such a small one!")         
        else:
            int(h) > 180
            tmsg.showinfo("At all!", "That's not the case!" )
    
def ButtonClick_b():
    b = editboxl_b.get()
    d = editboxl_b.get()    
    
    my_b = False
    if len(d) != 1:
        tmsg.showinfo("mistake", "Great tip! In a single digit!")
    else:
        kazuok = True
        for i in range(1):
            if (b[i] < "0") or (b[i] > "9"):
                tmsg.showerror("error", "Not a number")
                kazuok = False
                break
            if kazuok :
                my_b = True             

    if my_b :
        if int(b) == 3:
            tmsg.showinfo("Correct answer", "大Correct answer!君とは気が合うかもね(笑)")    
        elif 1 <= int(b) < 2:
            tmsg.showinfo("I'm sorry!", "It ’s a little higher")
        elif 4 < int(b) <= 6:
            tmsg.showinfo("I'm sorry!", "A little lower")     
        else:
            int(b) > 6
            tmsg.showinfo("At all!", "The temperature is just right(Tips)" )

def ButtonClick_s1():
    tmsg.showinfo("No!", "Basketball is also interesting though! !!")            

def ButtonClick_s2():
    tmsg.showinfo("Correct answer", "Baseball is the best! !!" )

def ButtonClick_s3():
    tmsg.showinfo("No!", "I'm really bad at soccer!")
                         
root = tk.Tk()
root.geometry("800x800")
root.title("Get to know me")

labell_h = tk.Label(root, text="(It's about this time ...)Nice to meet you!", font=("Helvetica", 30))
labell_h.place(x = 20, y = 0)

labell_i = tk.Label(root, text="Get to know me even a little in 2 minutes!", font=("Helvetica", 20))
labell_i.place(x = 20, y = 50)

labell_h = tk.Label(root, text="[SIZE] Let's guess the height(3 single-byte numbers)", font=("Helvetica", 20))
labell_h.place(x = 20, y = 150)

labell_b = tk.Label(root, text="[BIRTHDAY] Let's guess the month of birth(Half-width numbers)", font=("Helvetica", 20))
labell_b.place(x = 20, y = 300)

labell_x = tk.Label(root, text="[LIKE] Let's guess which sport you like", font=("Helvetica", 20))
labell_x.place(x = 20, y = 500)

editboxl_h = tk.Entry(width = 3, font=("Helvetica", 28))
editboxl_h.place(x =120, y = 200)

editboxl_b = tk.Entry(width = 3, font=("Helvetica", 28))
editboxl_b.place(x =120, y = 360)

height = tk.Label(root, text = "cm", font=("Helvetica", 20))
height.place(x = 200, y = 200)

monthl = tk.Label(root, text = "Month", font=("Helvetica", 20))
monthl.place(x = 200, y = 360)

buttonl_h = tk.Button(root, text = "click", font=("Helvetica", 14), command=ButtonClick_h)
buttonl_h.place(x = 240, y =200)

buttonl_b= tk.Button(root, text = "click", font=("Helvetica", 14), command=ButtonClick_b)
buttonl_b.place(x = 240, y =360)

buttonl_s1 = tk.Button(root, text = "basketball", font=("Helvetica", 14), command=ButtonClick_s1)
buttonl_s1.place(x = 120, y =560)

buttonl_s2 = tk.Button(root, text = "baseball", font=("Helvetica", 14), command=ButtonClick_s2)
buttonl_s2.place(x = 120, y =630)

buttonl_s3 = tk.Button(root, text = "Football", font=("Helvetica", 14), command=ButtonClick_s3)
buttonl_s3.place(x = 120, y =700)

root.mainloop()

2020-07-09.png

It will look like this! !! !!


Impressions

Originally, I might have been able to introduce myself face-to-face in April, but I'm glad I was able to introduce myself in this way.

Recommended Posts

Nice to meet you with python
Connect to BigQuery with Python
Connect to Wikipedia with Python
Post to slack with Python 3
Switch python to 2.7 with alternatives
Write to csv with Python
Nice to meet you, I would like to introduce myself.
Site notes to help you use NetworkX with Python
Solution when you want to use cv_bridge with python3 (virtualenv)
Python: How to use async with
Link to get started with python
[Python] Write to csv file with Python
Knowledge you need to know when programming competitive programming with Python2
Create folders from '01' to '12' with python
Try to operate Facebook with Python
Output to csv file with Python
Convert list to DataFrame with python
MP3 to WAV conversion with Python
To do tail recursion with Python2
How to get started with Python
What to do with PYTHON release?
Unable to install Python with pyenv
How to use FTP with Python
How to calculate date with python
Easily post to twitter with Python 3
Until you run python with apache
I want to debug with Python
Python | What you can do with Python
Don't write Python if you want to speed it up with Python
A note on what you did to use Flycheck with Python
What to do if you can't install pyaudio with pip #Python
Try to reproduce color film with Python
Try logging in to qiita with Python
Change Python 64bit environment to 32bit environment with Anaconda
English speech recognition with python [speech to text]
HTML email with image to send with python
Memo to ask for KPI with python
Python to remember only with hello, worlds
Output color characters to pretty with python
Introduction to Python Image Inflating Image inflating with ImageDataGenerator
Output Python log to console with GAE
Convert Excel data to JSON with python
Convert Hiragana to Romaji with Python (Beta)
Fractal to make and play with Python
I wanted to solve ABC160 with Python
Connect to MySQL with Python within Docker
How to work with BigQuery in Python
[Introduction to Python] Let's use foreach with Python
Single pixel camera to experience with Python
[Python] Introduction to CNN with Pytorch MNIST
Convert FX 1-minute data to 5-minute data with Python
I want to analyze logs with Python
How to do portmanteau test with python
I want to play with aws with python
How to display python Japanese with lolipop
Trying to handle SQLite3 with Python [Note]
[Part1] Scraping with Python → Organize to csv!
Connect to s3 with AWS Lambda Python
Add Gaussian noise to images with python2.7
How to enter Japanese with Python curses
Convert HEIC files to PNG files with Python