By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,660 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,660 IT Pros & Developers. It's quick & easy.

Writing in Python Tkinter Textwidget with specified line number.

P: 6
Hi all !

I am developing GUI in Python Tkinter for one application.
In this I have created one Text box. And I need to insert the text inside the text box directly in to some paticular line say 10th line, without inserting any '/n' before that line...
For Example :
text = Text(parent, height, width, .... ) # Creating Text widget inside its parent.
text.insert(INSERT, "Hi\n") # inserting "Hi" in the first line
text.insert("%d.%d"%(10, 0), "Hello") # Now Inserting "Hello" at 10th row or line.

But whenever I execute this program, The text is always inserted at the next line(2nd line)line only... and not at the 10th line.....
Is there any way to solve this problem? Please help me out...

Thanks in advance,
Shambhu.
Aug 8 '07 #1
Share this Question
Share on Google+
2 Replies


P: 8
I have the same problem...but I havent't still found a solution.
Now I use PIL and wxwidgets and the situation is better.
Aug 8 '07 #2

bartonc
Expert 5K+
P: 6,596
Hi all !

I am developing GUI in Python Tkinter for one application.
In this I have created one Text box. And I need to insert the text inside the text box directly in to some paticular line say 10th line, without inserting any '/n' before that line...
For Example :
text = Text(parent, height, width, .... ) # Creating Text widget inside its parent.
text.insert(INSERT, "Hi\n") # inserting "Hi" in the first line
text.insert("%d.%d"%(10, 0), "Hello") # Now Inserting "Hello" at 10th row or line.

But whenever I execute this program, The text is always inserted at the next line(2nd line)line only... and not at the 10th line.....
Is there any way to solve this problem? Please help me out...

Thanks in advance,
Shambhu.
Hi Shambhu. The problem is not only is Tkinter very limited, but text widgets of this type are completely line based (a newline counts as one line).

Our new friend, nisyna, has the right suggestions. In order to get the effect that you are after, you'll need to be working with a graphical (bit mapped) widget.

Hope that helps.
Aug 8 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.