Displaying the line number
Let's work towards showing the line numbers to the left of the Text widget. This will require us to tweak the code at various places. So, before we start coding, let's look at what we are trying to achieve here.
The View menu has a menu item that allows users to choose whether to show line numbers. We only want to show the line numbers if the option is selected, as shown in the following screenshot:
If the option is selected, we need to display the line numbers in the left frame that we created earlier.
The line number should update every time a user enters a new line, deletes a line, cuts or pastes text from the line, performs ...
Get Tkinter GUI Application Development Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.