Reader small image

You're reading from  Tkinter GUI Application Development Blueprints

Product typeBook
Published inNov 2015
Reading LevelExpert
PublisherPackt
ISBN-139781785889738
Edition1st Edition
Languages
Right arrow
Author (1)
Bhaskar Chaudhary
Bhaskar Chaudhary
author image
Bhaskar Chaudhary

Bhaskar Chaudhary is a professional programmer and information architect. He has a decade of experience in consulting, contracting, and educating in the field of software development. He has worked with a large set of programming languages on various platforms over the years. He is an electronics hobbyist and a musician in his free time.
Read more about Bhaskar Chaudhary

Right arrow

Adding the cursor information bar


The cursor information bar is simply a small label at the bottom-right corner of the Text widget, which displays the current position of the cursor, as shown in the following screenshot:

The user can choose to show/hide this info bar from the View menu (refer to the code in 2.11.py in the code bundle). Begin by creating a Label widget within the Text widget and pack it in the bottom-right corner, as follows:

cursor_info_bar = Label(content_text, text='Line: 1 | Column: 1')
cursor_info_bar.pack(expand=NO, fill=None, side=RIGHT, anchor='se')

In many ways, this is similar to displaying the line numbers. Here too, the positions must be calculated after every key press, after events such as cut, paste, undo, redo, new, and open, or activities that lead to a change in cursor positions. Because this too needs to be updated for all the changed content, for every key press, we will update on_content_changed to update this, as follows:

def on_content_changed(event=None...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Tkinter GUI Application Development Blueprints
Published in: Nov 2015Publisher: PacktISBN-13: 9781785889738

Author (1)

author image
Bhaskar Chaudhary

Bhaskar Chaudhary is a professional programmer and information architect. He has a decade of experience in consulting, contracting, and educating in the field of software development. He has worked with a large set of programming languages on various platforms over the years. He is an electronics hobbyist and a musician in his free time.
Read more about Bhaskar Chaudhary