Skip to main content
2 of 4
added 503 characters in body
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

Run a script and see.

Like any code we can run and see, the worst thing that can happen is your computer explodes, starts a fire an burns down your city.

Here is a test script to set a string property of each subtype to the window manager, and display them in a panel (using the simple panel template code) as well as write their value to system console on change.

import bpy
from bpy.props import StringProperty

subtypes = ['FILE_PATH', 'DIR_PATH', 'FILE_NAME', 'BYTE_STRING', 'PASSWORD', 'NONE']

def print_value(subtype):
    def print_value(self, context):
        print(subtype, getattr(self, subtype))
    return print_value

for st in subtypes:
    setattr(bpy.types.WindowManager,
            st, 
            StringProperty(subtype=st, update=print_value(st)))


class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        wm = context.window_manager
        layout = self.layout
        for st in subtypes:
            layout.prop(wm, st)

def register():
    bpy.utils.register_class(HelloWorldPanel)

def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)

if __name__ == "__main__":
    register()

Here is the result.

enter image description here

and the result of setting all to "xxxxxx" in the panel written to system console. Plus my explanation of what they do as a comment

FILE_PATH xxxxxx # adds a button to select file from filebrowser
DIR_PATH xxxxxx  # adds a button to select folder from filebrowser
FILE_NAME xxxxxx # not sure??
BYTE_STRING b'xxxxxx' # gives a bytecode representation of string
PASSWORD xxxxxx # hides the input as asterisks 
NONE xxxxxx  # default is just a string nothing more nothing less.

Note

The 'FILE_NAME' option AFAICT is for, as the name suggests a filename. Filenames cannot contain certain characters. It doesn't appear to in anyway auto-parse. The Paint Palettes addon uses the subtype for preset file names. The following method is used to parse out illegal / invalid chars.

def as_filename(name):  # could reuse for other presets
    for char in " !@#$%^&*(){}:\";'[]<>,.\\/?":
        name = name.replace(char, '_')
    return name.lower().strip()
batFINGER
  • 85.2k
  • 10
  • 114
  • 244