Results 1 to 9 of 9

Thread: Tkinter (in python) Text Widget State

  1. #1
    Join Date
    Jul 2007
    Beans
    386

    Tkinter (in python) Text Widget State

    Hi everybody.

    In Tkinter (python) text widget, is there a way to prevent the Text widget from being edited by the user, but allow the program to do inserts and deletes?

    I know one way is to keep the widget disabled and then when I need to e.g. insert, I would briefly set the state to normal, insert, and then disable. However, this seems rather cheesy, because the user may get lucky and edit the thing in the moment of it being enabled. Are there better ways?

  2. #2
    Join Date
    Mar 2009
    Location
    Buenos Aires, AR
    Beans
    2,325
    Distro
    Ubuntu

    Re: Tkinter (in python) Text Widget State

    Using the readonly property... read here are all the answers to your questions, learned from there:
    infohost.nmt.edu/tcc/help/pubs/tkinter.pdf

  3. #3
    Join Date
    Jul 2007
    Beans
    386

    Re: Tkinter (in python) Text Widget State

    The readonly option does not seem to be available for text widget.

  4. #4
    Join Date
    Mar 2009
    Location
    Buenos Aires, AR
    Beans
    2,325
    Distro
    Ubuntu

    Re: Tkinter (in python) Text Widget State

    Read the PDF; if you dont post any code, we cant help more than that... ʘ‿ʘ

  5. #5
    Join Date
    Jul 2007
    Beans
    386

    Re: Tkinter (in python) Text Widget State

    My code is very simple. I just want to be able to achieve the readonly effect on the tkinter text widget.

  6. #6
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,292
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Tkinter (in python) Text Widget State

    Quote Originally Posted by DBQ View Post
    However, this seems rather cheesy, because the user may get lucky and edit the thing in the moment of it being enabled.
    Actually no, they may not.
    「明後日の夕方には帰ってるからね。」


  7. #7
    Join Date
    Jul 2007
    Beans
    386

    Re: Tkinter (in python) Text Widget State

    Why not? Suppose they highlight some text and hold down the delete key. When the widget state is set to normal for a moment, the text may get deleted. Please elaborate if possible. Thank You!

  8. #8
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,292
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Tkinter (in python) Text Widget State

    Quote Originally Posted by DBQ View Post
    Why not? Suppose they highlight some text and hold down the delete key. When the widget state is set to normal for a moment, the text may get deleted. Please elaborate if possible. Thank You!
    Have you tried this? When a callback gets executed, the program stops responding to events until the callback returns. There is no other way to do what you want.
    「明後日の夕方には帰ってるからね。」


  9. #9
    Join Date
    Jul 2007
    Beans
    386

    Re: Tkinter (in python) Text Widget State

    I tried my experiment with holding down the delete key and sure enough the text was deleted.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •