Menu

#13 mixedform text elements with spaces

v3
closed
notabug (3)
5
2022-12-12
2022-12-11
No

Hi,

When I try to pass a string with some spaces into the text method and display all the spaces trimmed to one, for example:

text = ' Hello World!'
print(text)
' Hello World!'

But:

self.d.mixedform(text, self.elements, self.height, self.width)
' Hello World!'

There is a way to keep the spaces?

Cheers

Discussion

  • Dimitris Zlatanidis

    Also here all my spaces from the post are gone, so:

    '_' = space

    text = '_ Hello World!'
    print(text)
    '
    ___Hello World!'

    But:

    self.d.mixedform(text, self.elements, self.height, self.width)
    '_Hello World!'

    There is a way to keep the spaces?

     
  • Florent Rougon

    Florent Rougon - 2022-12-11

    Hi,

    This is due to a feature of the dialog program. Please always check its man page before reporting bugs:

    --no-collapse
           Normally dialog converts tabs to  spaces  and  reduces  multiple
           spaces  to  a  single  space  for  text  which is displayed in a
           message boxes, etc.  Use this option to  disable  that  feature.
           Note   that   dialog  will  still  wrap  text,  subject  to  the
           --cr-wrap and --trim options.
    

    You can pass this option either globally via Dialog.add_persistent_args() or locally using no_collapse=True:

    #! /usr/bin/env python3
    
    from dialog import Dialog
    
    d = Dialog(dialog="dialog")
    d.add_persistent_args(["--no-nl-expand", "--no-collapse"])
    
    text = '     Hello World!'
    elements = [
                ("Foo", 1, 1, "175", 1, 20, 4, 3, 0x0),
                ("Bar", 2, 1, "85", 2, 20, 4, 3, 0x0),
    ]
    d.mixedform(text, elements, 20, 70)
    # d.mixedform(text, elements, 20, 70, no_collapse=True)
    

    Also, a self-contained minimal example that shows the problem (like this one without the "--no-collapse" nor no_collapse=True since you didn't know about them) would have saved me some time. :-)

    Regards

     
  • Florent Rougon

    Florent Rougon - 2022-12-11
    • labels: --> notabug
    • status: open --> closed
    • assigned_to: Florent Rougon
     
  • Dimitris Zlatanidis

    Thanks, @frougon this works fine now!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.