Page MenuHome

Support string formatting for stamp note
Needs ReviewPublic

Authored by Campbell Barton (campbellbarton) on Mar 15 2016, 10:24 AM.

Details

Summary

Experimental patch for evaluating the string with Python's str.format based on discussion with @venomgfx,
not really pushing this to go into master - just including for reference.


Example stamp note:

tiles: {scene.render.tile_x}x{scene.render.tile_y}, shift: {camera.data.shift_x}x{camera.data.shift_y}, ver: {bpy.app.version_string}

... evaluates to: tiles: 64x64, shift: 0.0x0.0, ver: 2.77 (sub 0)

This is an equivalent of doing:

scene.render.stamp_note_text.format(**dict(scene=context.scene, camera=scene.camera, bpy=bpy, context=context))


Possible Improvements:

  • An error in one expression could be made so only the text between the {} fail.
  • error handling could be better in general. currently errors just show in console.

Diff Detail

Repository
rB Blender
Branch
TEMP-STAMP_NOTE_FORMAT

Event Timeline

Campbell Barton (campbellbarton) retitled this revision from to Support string formatting for stamp note.
  • rename funciton
  • Add missing decref

Tested it and works great! It's so useful.

We were discussing the possibility to support multiple lines (\n), which internally Blender does but the UI doesn't (it shows an unrecognized symbol).

This brought the topic of, how useful would it be to have multi-line text fields (like textareas). In which other cases would this be useful? What do you think @Jonathan Williamson (carter2422), @Julian Eisel (Severin)?

I think some kind of text area support would totally be good to have (@Campbell Barton (campbellbarton), isn't that pretty much what BLF does even?), +1 from here.

Yep, multi-line text editing would be good, though pretty much separate from this patch.