From ebb9572628d9e946cad0ceefa3be978a3ad77f4a Mon Sep 17 00:00:00 2001 From: Joao Angelo <78273535+Joao-Angelo-P@users.noreply.github.com> Date: Mon, 31 Mar 2025 10:56:59 -0400 Subject: [PATCH 1/3] Update calculator2.py Disabled the user input in Entry widget. For force the user use only buttons entry data. --- calculator/calculator2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/calculator/calculator2.py b/calculator/calculator2.py index dda9abc..6f12343 100644 --- a/calculator/calculator2.py +++ b/calculator/calculator2.py @@ -1,5 +1,7 @@ # Inspirado no programa 'clac1.py' do livro "Python and Tkinter Programming" de John E.Grayson from tkinter import * +if 'constants' not in __import__('tkinter').__all__: + from tkinter import constants def frame(root, side): w = Frame(master=root) @@ -17,7 +19,7 @@ def button(root, text, side, command=None, **kw): frame_top = Frame(root,) frame_top.pack(side=TOP, fill=BOTH, expand=YES) Entry(master=frame_top, relief=SUNKEN, - textvariable=display).pack(side=LEFT, expand=YES, fill=BOTH, padx=5, pady=2) + textvariable=display, state=constants.DISABLED).pack(side=LEFT, expand=YES, fill=BOTH, padx=5, pady=2) Button(frame_top, text="C", command=lambda w=display: w.set(''), bg="red", fg="white", relief=RIDGE).pack(side=RIGHT, expand=False, padx=2) From a5ba37dfeeba4302e53bbb5469fcd82cf2601f7c Mon Sep 17 00:00:00 2001 From: Joao Angelo <78273535+Joao-Angelo-P@users.noreply.github.com> Date: Mon, 31 Mar 2025 11:18:14 -0400 Subject: [PATCH 2/3] Update calculator2.py Exclude the "from tkinter import constants", forgot already have. --- calculator/calculator2.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/calculator/calculator2.py b/calculator/calculator2.py index 6f12343..1c4faf3 100644 --- a/calculator/calculator2.py +++ b/calculator/calculator2.py @@ -1,7 +1,5 @@ # Inspirado no programa 'clac1.py' do livro "Python and Tkinter Programming" de John E.Grayson from tkinter import * -if 'constants' not in __import__('tkinter').__all__: - from tkinter import constants def frame(root, side): w = Frame(master=root) From 73429e66fac4af8f19a155e16996e0966cc116c2 Mon Sep 17 00:00:00 2001 From: Joao Angelo <78273535+Joao-Angelo-P@users.noreply.github.com> Date: Mon, 31 Mar 2025 12:44:42 -0400 Subject: [PATCH 3/3] Update calculator2.py only "state=DISABLED". --- calculator/calculator2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calculator/calculator2.py b/calculator/calculator2.py index 1c4faf3..93678c4 100644 --- a/calculator/calculator2.py +++ b/calculator/calculator2.py @@ -17,7 +17,7 @@ def button(root, text, side, command=None, **kw): frame_top = Frame(root,) frame_top.pack(side=TOP, fill=BOTH, expand=YES) Entry(master=frame_top, relief=SUNKEN, - textvariable=display, state=constants.DISABLED).pack(side=LEFT, expand=YES, fill=BOTH, padx=5, pady=2) + textvariable=display, state=DISABLED).pack(side=LEFT, expand=YES, fill=BOTH, padx=5, pady=2) Button(frame_top, text="C", command=lambda w=display: w.set(''), bg="red", fg="white", relief=RIDGE).pack(side=RIGHT, expand=False, padx=2)