1

I am trying to place the text box widget onto the screen

I am using the text box to display the output of my program. text box has to be placed on the right side of the screen

my code

import Tkinter

main_window=Tkinter.Tk()
text_widget = tkinter.Text(main_window)
text_widget.insert(INSERT, "text  message will display here")
text_widget.pack(anchor = "w", padx = 50, pady = 50)

main_window.mainloop()

but my problem is text box is not visible on the screen. how to solve that problem?

thanks

10
  • 3
    Can you show more codes? The three line can not describe the error. Commented Aug 6, 2013 at 6:58
  • @zhangyangyu thanks for the reply, I am a newbie to python, if I get a simple demonstration on how the text box works then it will help alot . because I am learning python by simple examples. Commented Aug 6, 2013 at 7:59
  • The three seems good. So if we want to know the problem, we need to know more. Maybe the error doesn't lie in these lines. Commented Aug 6, 2013 at 8:05
  • @zhangyangyu there is no error in those codes, but still text box is not visible on the screen Commented Aug 6, 2013 at 8:30
  • 1
    Is this your whole program? You're missing the instantiation of the Tk class, and you're not calling mainloop. Commented Aug 6, 2013 at 10:58

1 Answer 1

1

You have imported Tkinter but in your third line, you used tkinter.

You might want to change your fourth line to text_widget.insert('insert',"text message will display here")

import Tkinter

main_window=Tkinter.Tk()
text_widget = Tkinter.Text(main_window)
text_widget.insert('insert',"text  message will display here")
text_widget.pack(anchor = "w", padx = 50, pady = 50)

main_window.mainloop()

The above code works fine without any problems in my PC.

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

1 Comment

Actually, he's importing TKinter (notice the capital "K"), then using Tkinter in another place, and tkinter in others.

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.