Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4586818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:41:32+00:00 2026-05-21T21:41:32+00:00

I’m working with the Text widget and I have an issue about old-school shortcuts

  • 0

I’m working with the Text widget and I have an issue about old-school shortcuts that Tk uses.

Ie:

Select all: Ctrl + / vs Ctrl + a
Cut: Ctrl + w vs Ctrl + x
Copy: Meta + w vs Ctrl + c
Paste: Ctrl + y vs Ctrl + v

On Windows, all of them work except Ctrl+a.

1) Is it possible to redirect binds, so .bind('<Control-a>') calls already bound Ctrl + /?

2) I tried for “select all”:

txt_text.bind('<Control-a>', self.ctext_selectall)

Where:

def ctext_selectall(self, callback):
    """Select all text in the text widget"""
    self.txt_text.tag_add('sel', '1.0', 'end')

But it does not work, since Ctrl+a works by default (cursor goes to the start). It function with some other, unbound, letter. Any chances of making this work if the solution under 1 is not possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:41:33+00:00Added an answer on May 21, 2026 at 9:41 pm

    The default bindings are applied to the widget class. When you do a bind, it affects a specific widget and that binding happens before the class binding. So what is happening is that your binding is happening and then the class binding is happening, which makes it seem as if your binding isn’t working.

    There are two ways to solve this. One, your ctext_selectall can return the string “break” which will prevent the class binding from firing. That should be good enough to solve your immediate problem.

    The second solution involves changing the class binding so that your preferred binding applies to all text widgets. You would do this using the bind_class method.

    Here’s an example of rebinding the class:

    def __init__(...):
        self.root.bind_class("Text","<Control-a>", self.selectall)
    
    def selectall(self, event):
        event.widget.tag_add("sel","1.0","end")
    

    effbot.org has a pretty decent writeup titled Events and Bindings. It goes into a little more detail about class and widget bindings and the order in which they occur.

    Tk’s binding mechanism is about the best of any GUI toolkit there is. Once you understand how it works (and it’s remarkably simple) you’ll find it’s easy to augment or replace any or all of the default bindings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.