Ignore keystrokes in Tk

Discussion in 'Perl Misc' started by Larry, Dec 12, 2005.

  1. Larry

    Larry Guest

    Another Tk question ... I have a textbox that I want to populate from
    my script, and I want the user to be able to select and copy from the
    textbox, but I don't want them to be able to modify it. There is a
    "-state disabled" attribute which prevents them from modifying, but it
    also prevents them from selecting text.

    I'm thinking I need to do something with "bind" but I can't figure out
    what. I tried binding the <Key> event to a subroutine that returns 0,
    or returns 1, and neither had any effect.
    Larry, Dec 12, 2005
    #1
    1. Advertising

  2. Larry

    Eric Bohlman Guest

    "Larry" <> wrote in news:1134411759.156788.317960
    @f14g2000cwb.googlegroups.com:

    > Another Tk question ... I have a textbox that I want to populate from
    > my script, and I want the user to be able to select and copy from the
    > textbox, but I don't want them to be able to modify it. There is a
    > "-state disabled" attribute which prevents them from modifying, but it
    > also prevents them from selecting text.


    By a "textbox" do you mean an Entry or a Text? If the latter, there's
    already an ROText that will do what you want.
    Eric Bohlman, Dec 12, 2005
    #2
    1. Advertising

  3. Larry

    Larry Guest

    Eric Bohlman wrote:
    > "Larry" <> wrote in news:1134411759.156788.317960
    > @f14g2000cwb.googlegroups.com:
    >
    > > Another Tk question ... I have a textbox that I want to populate from
    > > my script, and I want the user to be able to select and copy from the
    > > textbox, but I don't want them to be able to modify it. There is a
    > > "-state disabled" attribute which prevents them from modifying, but it
    > > also prevents them from selecting text.

    >
    > By a "textbox" do you mean an Entry or a Text? If the latter, there's
    > already an ROText that will do what you want.


    It's actually a "Scrolled".
    Larry, Dec 13, 2005
    #3
  4. Larry

    Larry Guest

    Larry wrote:
    > Eric Bohlman wrote:
    > > "Larry" <> wrote in news:1134411759.156788.317960
    > > @f14g2000cwb.googlegroups.com:
    > >
    > > > Another Tk question ... I have a textbox that I want to populate from
    > > > my script, and I want the user to be able to select and copy from the
    > > > textbox, but I don't want them to be able to modify it. There is a
    > > > "-state disabled" attribute which prevents them from modifying, but it
    > > > also prevents them from selecting text.

    > >
    > > By a "textbox" do you mean an Entry or a Text? If the latter, there's
    > > already an ROText that will do what you want.

    >
    > It's actually a "Scrolled".


    Oh, I get it... I didn't realize that the Scrolled had "Text" as an
    option. I changed it to "ROText" and that did the trick. (Except that
    it also made the background gray, but I was able to fix that with
    "-background white").

    Thanks!
    Larry, Dec 13, 2005
    #4
  5. Larry

    Eric Bohlman Guest

    "Larry" <> wrote in
    news::

    > Oh, I get it... I didn't realize that the Scrolled had "Text" as an
    > option. I changed it to "ROText" and that did the trick. (Except
    > that it also made the background gray, but I was able to fix that with
    > "-background white").


    It's not an "option"; it's a "subwidget" (Scrolled is actually a composite
    widget consisting of a user-specified subwidget and two scrollbar
    subwidgets).

    > Thanks!


    And thanks for reminding me about the background issue; I had forgotten
    about it and was wondering why the ROText I'm using in a quote-collection-
    viewer looked so off.
    Eric Bohlman, Dec 14, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob T

    Capturing Keystrokes

    Rob T, May 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    804
    Vidar Petursson
    May 14, 2004
  2. Lucas Tam
    Replies:
    5
    Views:
    6,229
    WizyDig
    Dec 2, 2004
  3. Replies:
    3
    Views:
    419
    VisionSet
    Jun 28, 2004
  4. Martijn Mulder

    where do the keystrokes go?

    Martijn Mulder, Dec 18, 2005, in forum: Java
    Replies:
    2
    Views:
    394
    Martijn Mulder
    Dec 18, 2005
  5. Rob Meade
    Replies:
    6
    Views:
    259
    Rob Meade
    Mar 1, 2004
Loading...

Share This Page