473,625 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing in Python Tkinter Textwidget with specified line number.

6 New Member
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(INS ERT, "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
2 2908
nisyna
8 New Member
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
6,596 Recognized Expert Expert
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(INS ERT, "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

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

Similar topics

0
1291
by: Brian Kazian | last post by:
I am currently having trouble running a piece of code I have written. My main code is called new.py, and when I run it, it pops up the TKinter root window as specified. However, if I try perform a function that uses an imported module, the code crashes, giving me this error: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return self.func(*args)
2
2823
by: nholtz | last post by:
Is there any way to delete a widget (window) from a Text widget, and then add it back to the Text, without re-creating the original widget. For example, I think I would like to do something like the following: ########################################################## from Tkinter import * root = Tk()
27
2908
by: bcwhite | last post by:
I've been trying to find out what the future of Python is with regard to Tk. It seems there are several interfaces that make use of new functionality, including "Tile" and "Ttk". If I want to write a program that will run under the standard Python distribution of the future, what extension module should I work with today? Thanks!
0
8688
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7178
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1496
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.