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?

[備忘録]電卓の開発

Posted at

はじめに

初めまして。独学で、プログラミングの学習を行っているえむしたと申します。
今回は、PythonとTKinterを使った電卓開発の備忘録を記録していきます。
拙い記事ではありますが、読んでいただけると幸いです。

使用ツール

言語:Python
FW:TKinter
バージョン管理: Git, GitHub
開発ツール: VScode

要件

・四則演算
・入力した数字をリスト管理し、足し算、掛け算を1つのボタンで合計する

四則演算のボタン配置

イメージ図
スクリーンショット (1).png

ボタン配置
buttons = [
    ('税込', 1, 0), ('税抜', 1, 1), ('保存', 1, 2), ('合計', 1, 3), ('掛算', 1, 4), ('C', 1, 5)
    ('7', 2, 0), ('8', 2, 1), ('9', 2, 2), ('/', 2, 3), ('リセット', 2, 4),
    ('4', 3, 0), ('5', 3, 1), ('6', 3, 2), ('*', 3, 3),
    ('1', 4, 0), ('2', 4, 1), ('3', 4, 2), ('-', 4, 3),
    ('0', 5, 0), ('.', 5, 1), ('=', 5, 2), ('+', 5, 3),
] 

for (text, row, col) in buttons: #text=ボタン、row=ボタンの配置行、col=ボタンの配置列 ('税抜'=ボタン, '1'=行, '0'=列)
    button = tk.Button(button_frame, text=text, font=("Arial", 18), width=5, height=2) #ボタンのウィジェットを配置。フォントや、幅、高さを指定
    button.grid(row=row, column=col, padx=5, pady=5) #ボタンの位置、余白を指定

まとめ

今回は、電卓のボタン部分のUIを実装しました。
通常の電卓+入力数字の保存を実装したかったので、少し多くなってしまってデザインが・・となってます
もう少し簡単なUIを考えないといけないと反省

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?