0

Hey guys I am doing a sample project on python. I have made a simple calculator. The thing is that I want that calculator in a box. I have read many articles and I found about Tkinter.

The thing is I want to get the input as a text using tkinter.

My code

import tkinter as tk

root = tk.Tk()

my_text = tk.Text(root)

my_text.pack()

my_text.insert(tk.END,"Select operation.")

When i run my_text.insert(tk.END,"Select operation.") it works fine in a box but when i run my_text.insert(input(tk.END,"Enter choice(1/2/3/4")): it doesn't work ..

Why is it so. I need Enter choice(1/2/3/4")): to be printed on the screen with box.

Hope you can find a solution for me ..Thanks in advance

5
  • If I understood you correctly, you should check out Entry widget. Commented May 26, 2014 at 10:31
  • thats doesnt have any purpose here ?? Commented May 26, 2014 at 10:36
  • the thing is that i want enter choice text to be displayed in a box with input function Commented May 26, 2014 at 10:37
  • I believe the first comment is what you are looking for. I think you can use a StringVar to have a prompt inside the entry box if I can remember right. Commented May 26, 2014 at 11:58
  • i have used string var but it didnt solved my prob Commented May 26, 2014 at 14:00

1 Answer 1

1

You cannot use input with a text widget. You will need to create buttons or bindings that react to events. You should work through a complete Tkinter tutorial so you can understand how it works.

Sign up to request clarification or add additional context in comments.

1 Comment

so you say i need to use buttons for my purpose ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.