Wish - StringBox() can accept/return an empty string

So that when someone simply presses Enter without entering anything in the box it returns an empty string. Hitting Esc or the Cancel button should still return None. Right now, it simply refuses to close and return if you try hitting Enter without typing anything, it just stays up, waiting.

This would make it handy to be able to use StringBox to ask for an optional string - that might used as a prefix or suffix for something else for example. Hitting Enter without typing anything would mean you don’t want to add the prefix/suffix. Right now, I can only use GetString for that, but entering a text with spaces causes it to return after the first space - whereas StringBox() will allow spaces in the string.

Note that StringBox() just calls rhinoCommon Rhino.UI.Dialogs.ShowEditBox(), and the problem is with the RhinoCommon method, not in how the rhinoscriptsyntax call is written.

Hey Mitch,

Sometimes it’s just better to write your own.

MitchStringBox.py (3.0 KB)

How about this?

import Rhino

def GetStringSpecial(prompt, default):
    gs = Rhino.Input.Custom.GetString()
    if prompt:
    if default:
    gs.GetLiteralString() # bingo
    if gs.CommandResult() == Rhino.Commands.Result.Success:
        return gs.StringResult()
    return None
value = GetStringSpecial('Enter some string', 'test')
if value:

– Dale