I want to place a shortcut in the panel I'm creating for changing the F-curves Default Interpolation Type found in Preferences> Animation> F-Curves.

I have the Python Tooltips enabled and it says:


How do I write a script to access this operator with its functionality?


1 Answer 1


You can access that Preferences property with the following code:


To use this in a panel:

    row.prop(context.preferences.edit, "keyframe_new_interpolation_type")

The full code (using the UI Panel Simple template found in the Text Editor> Templates menu):

import bpy

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):
        layout = self.layout
        row = layout.row()
        row.prop(context.preferences.edit, "keyframe_new_interpolation_type")

def register():

def unregister():

if __name__ == "__main__":

Which displays like this, in the Object tab of the Properties Editor:

enter image description here

If you need to set this value manually you can see the list of strings this property expects to be set to in the Blender 2.80 Python API.

  • $\begingroup$ Oh my word! It works and it was so simple. How did you find it? $\endgroup$
    – Ryan
    Aug 28, 2019 at 20:49
  • $\begingroup$ I looked up how to access the User Preferences in 2.79 here, typed bpy.context.preferences (as 2.80 has 'Preferences' instead of 'User Preferences') in Blender's Python Console and used Autocomplete to display the various options. $\endgroup$ Aug 28, 2019 at 20:54
  • $\begingroup$ This helped so much. Thank you. $\endgroup$
    – Ryan
    Aug 28, 2019 at 20:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .