Tkinter.Text can never be empty?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harry Pehkonen

    Tkinter.Text can never be empty?

    While setting up some unit tests, I came to the conclusion that a
    Tkinter Text widget can never be empty, but will always (?) contain a
    \n. Here is a brief example:
    [color=blue][color=green][color=darkred]
    >>> import Tkinter
    >>> t = Tkinter.Text()
    >>> t.get(0.0, Tkinter.END)[/color][/color][/color]
    '\n'[color=blue][color=green][color=darkred]
    >>> t.delete(0.0, Tkinter.END)
    >>> t.get(0.0, Tkinter.END)[/color][/color][/color]
    '\n'[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]

    My apologies, but I have not checked whether or not this can be
    reproduced in Tcl/Tk (which I think might have been appropriate).

    My question is: Is there *always* a trailing \n, is this a bug, or am
    I doing something silly?

    Thanks!
    Harry.
  • vincent wehren

    #2
    Re: Tkinter.Text can never be empty?

    "Harry Pehkonen" <harry.pehkonen @hotpop.com> schrieb im Newsbeitrag
    news:70df36e9.0 309160826.596dd 5ab@posting.goo gle.com...
    | While setting up some unit tests, I came to the conclusion that a
    | Tkinter Text widget can never be empty, but will always (?) contain a
    | \n. Here is a brief example:
    |
    | >>> import Tkinter
    | >>> t = Tkinter.Text()
    | >>> t.get(0.0, Tkinter.END)
    | '\n'
    | >>> t.delete(0.0, Tkinter.END)
    | >>> t.get(0.0, Tkinter.END)
    | '\n'
    | >>>
    |
    | My apologies, but I have not checked whether or not this can be
    | reproduced in Tcl/Tk (which I think might have been appropriate).
    |
    | My question is: Is there *always* a trailing \n, is this a bug, or am
    | I doing something silly?

    Nope, this is one of the idiosyncrasies of our friend the Text widget;
    there's always this immortal LF at the end.

    Vincent Wehren
    |
    | Thanks!
    | Harry.


    Comment

    • Harry Pehkonen

      #3
      Re: Tkinter.Text can never be empty?

      > | >>> t = Tkinter.Text()[color=blue]
      > | >>> t.get(0.0, Tkinter.END)
      > '\n'
      > | My question is: Is there *always* a trailing \n, is this a bug, or am
      > | I doing something silly?
      >
      > Nope, this is one of the idiosyncrasies of our friend the Text widget;
      > there's always this immortal LF at the end.
      >
      > Vincent Wehren[/color]

      Thanks, Vincent :D

      Harry.

      Comment

      Working...