I made a program that automatically calculates the zodiac with tkinter

I made an automatic zodiac calculator

――Recently, I often find out what I thought or thought about (because I have free time). .. .. ――I tried to find out about the zodiac. → ** Zodiac personality diagnosis ** Discovery ――It was unexpectedly hit. (I felt like I was grasping the features well) ――I thought that if you know the zodiac, you can build good relationships, and when you investigate further, you can find an easy way to find it, so I tried programming. [1]


Coding content

This time I created a program using tkinter [2]

# coding:utf-8
import tkinter as tk

Window

In creating a program that automatically calculates, I created a basic window I set the size to 300 in width and 250 in height, and set the title to the name to check the zodiac from the Christian era.

root = tk.Tk()
root.geometry("300x250")
root.title("Let's check the zodiac from the Christian era")

Arrangement of input fields and execution buttons

Input fields are arranged using ʻEntry, and buttons are arranged using Button`.

editbox = tk.Entry(width=5, font=("Times", 28))
editbox.place(x = 10, y = 50)

Button = tk.Button(root, text = "button", font=("Helvetica", 12), command=Push)
Button.place(x = 130, y = 60)

Zodiac display

I placed a text field to display the zodiac with Text this time. The width of the text field is 80, and the height is 250.

eto = tk.Text(root, font=("Times", 12))
eto.place(x = 220, y = 0, width=80, height= 250)

Operation when the button is pressed

First, make a list named ʻEto, The operation (program) that calculates the zodiac from the list when the button is pressed and displays the result in the text field is defined in the function ** Push ** with def`.

Eto = ["Child", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Not yet", "Monkey", "Rooster", "Dog", "亥"]

def Push():
    n = editbox.get()
    amari = ((int(n)+9)%12)
    global Eto
    if amari == 1:
        c = Eto[0]
    elif amari == 2:
        c = Eto[1]
    elif amari == 3:
        c = Eto[2]
    elif amari == 4:
        c = Eto[3]
    elif amari == 5:
        c = Eto[4]
    elif amari == 6:
        c = Eto[5]
    elif amari == 7:
        c = Eto[6]
    elif amari == 8:
        c = Eto[7]
    elif amari == 9:
        c = Eto[8]
    elif amari == 10:
        c = Eto[9]
    elif amari == 11:
        c = Eto[10]
    else:
        c = Eto[11]
    eto.insert(tk.END, str(c) + "\n")

Execution result

2020-07-06.png

Completed form

# coding:utf-8
import tkinter as tk

Eto = ["Child", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Not yet", "Monkey", "Rooster", "Dog", "亥"]

def Push():
    n = editbox.get()
    amari = ((int(n)+9)%12)
    global Eto
    if amari == 1:
        c = Eto[0]
    elif amari == 2:
        c = Eto[1]
    elif amari == 3:
        c = Eto[2]
    elif amari == 4:
        c = Eto[3]
    elif amari == 5:
        c = Eto[4]
    elif amari == 6:
        c = Eto[5]
    elif amari == 7:
        c = Eto[6]
    elif amari == 8:
        c = Eto[7]
    elif amari == 9:
        c = Eto[8]
    elif amari == 10:
        c = Eto[9]
    elif amari == 11:
        c = Eto[10]
    else:
        c = Eto[11]
    eto.insert(tk.END, str(c) + "\n")

root = tk.Tk()
root.geometry("300x250")
root.title("Let's check the zodiac from the Christian era")

editbox = tk.Entry(width=5, font=("Times", 28))
editbox.place(x = 10, y = 50)

Button = tk.Button(root, text = "button", font=("Helvetica", 12), command=Push)
Button.place(x = 130, y = 60)

eto = tk.Text(root, font=("Times", 12))
eto.place(x = 220, y = 0, width=80, height= 250)

root.mainloop()


Impressions

--Use a font that suits you best --The contents of the Push function seems to be a little easier, so think a little more. ―― Why do you need the str function to display the ʻEto list` when it should be a character?


References

[1]. "11 useful calculations to know" [2]. "The easiest Python introductory class", written by Fumitaka Osawa, published by Sotec Co., Ltd.

Recommended Posts

I made a program that automatically calculates the zodiac with tkinter
I made a program that solves the spot the difference in seconds
[Python] I made a Youtube Downloader with Tkinter.
I made a calendar that automatically updates the distribution schedule of Vtuber
A memo that I touched the Datastore with python
I made a twitter app that decodes the characters of Pricone with heroku (failure)
I made a calendar that automatically updates the distribution schedule of Vtuber (Google Calendar edition)
I made a LINE BOT that returns parrots with Go
I made a puzzle game (like) with Tkinter in Python
I made a rigid Pomodoro timer that works with CUI
[Golang] A program that determines the turn with random numbers
I made a plug-in that can "Daruma-san fell" with Minecraft
I made a fortune with Python.
I made a daemon with Python
I made a Python program for Raspberry Pi that operates Omron's environmental sensor in the mode with data storage
I made a program to collect images in tweets that I liked on twitter with Python
Life game with Python [I made it] (on the terminal & Tkinter)
I made a program to solve (hint) Saizeriya's spot the difference
I made a package that can compare morphological analyzers with Python
I made a slack bot that notifies me of the temperature
[Python] A program that creates stairs with #
I made a payroll program in Python!
I made a character counter with Python
I made a Hex map with Python
I made a life game with Numpy
I made a stamp generator with GAN
[Python] A program that rounds the score
I made a simple blackjack with Python
I made a configuration file with Python
I made a WEB application with Django
I made a neuron simulator with Python
[Python] A program that calculates the number of chocolate segments that meet the conditions
[Python] A program that calculates the number of socks to be paired
[Django] I made a field to enter the date with 4 digit numbers
I made a simple timer that can be started from the terminal
I made a GAN with Keras, so I made a video of the learning process.
I made a library konoha that switches the tokenizer to a nice feeling
I made a program to check the size of a file in Python
I made a mistake in fetching the hierarchy with MultiIndex of pandas
I made a module PyNanaco that can charge nanaco credit with python
A model that identifies the guitar with fast.ai
I made a competitive programming glossary with Python
I made a weather forecast bot-like with Python.
I made a GUI application with Python + PyQt5
A memo that made a graph animated with plotly
Nogizaka46 A program that automatically saves blog images
I made a Twitter fujoshi blocker with Python ①
A program that searches for the same image
I made a simple Bitcoin wallet with pycoin
I made a LINE Bot with Serverless Framework!
I tried playing with the calculator on tkinter
I made a Caesar cryptographic program in Python.
I made a bin picking game with Python
I made a Mattermost bot with Python (+ Flask)
I made a QR code image with CuteR
A shell program that displays the Fibonacci sequence
I made a LINE BOT that returns a terrorist image using the Flickr API
With LINEBot, I made an app that informs me of the "bus time"
I made a familiar function that can be used in statistics with Python
[Python] A program that calculates the difference between the total numbers on the diagonal line.
[Python] A program that calculates the number of updates of the highest and lowest records