1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

円をドルに変換するコード

Last updated at Posted at 2022-08-27

円をドルに変換するコード

import tkinter as tk
import math

def dispLabel():
    a = int(EditBox1.get())
    b = int(EditBox2.get())
    A1=a//b
    A2=(a/b-A1)*100
    A2=math.ceil(A2)
    str_A1=str(A1)
    str_A2=str(A2)
    
    lbl3.configure(text="ドルに換算すると"+str_A1+"ドルと"+str_A2+"セントです。")


root=tk.Tk()
root.geometry("400x400")

EditBox1= tk.Entry(width=4)
EditBox1.place(x = 250, y = 20)
EditBox2= tk.Entry(width=4)
EditBox2.place(x = 250, y = 60)

btn=tk.Button(text="計算する",command=dispLabel).place(x = 60, y = 100)

lbl1=tk.Label(text="調べたい日本円はいくらですか?").place(x = 20, y = 20)
lbl2=tk.Label(text="今の一ドルあたりの日本円はいくらですか?").place(x = 20, y = 60)
lbl3=tk.Label(text=" ")
lbl3.place(x = 20, y = 140)

tk.mainloop()

円ドル(改).png
円ドル(改)_入力.png

感想

質問文とボックスが被ってしまうことが多くて、位置調整に手間取った。

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?