# How to popup simple message box from python console?

How can i popup message box from python console ? something like message('test').

• bpy.ops.wm.splash('INVOKE_DEFAULT') pops up the splash screen. On writing an operator with a dialogue see Related May 30, 2018 at 13:24
• there is no popup box in blender like you get with javascript alert("test") May 30, 2018 at 13:34

One way to do this is by using a operator and the self.report() method. Here is a example

import bpy

class MessageBoxOperator(bpy.types.Operator):
bl_idname = "ui.show_message_box"
bl_label = "Minimal Operator"

def execute(self, context):
#this is where I send the message
self.report({'INFO'}, "This is a test")
return {'FINISHED'}

bpy.utils.register_class(MessageBoxOperator)

# test call to the
bpy.ops.ui.show_message_box()


This will show a little message box up in the top tool bar and really isn't efficient for a bigger/longer message.

Another more efficient way of displaying a message box is window_manager.popup_menu() here is an example script:

import bpy

def ShowMessageBox(message = "", title = "Message Box", icon = 'INFO'):

def draw(self, context):
self.layout.label(text=message)

bpy.context.window_manager.popup_menu(draw, title = title, icon = icon)

#Shows a message box with a specific message
ShowMessageBox("This is a message")

#Shows a message box with a message and custom title
ShowMessageBox("This is a message", "This is a custom title")

#Shows a message box with a message, custom title, and a specific icon
ShowMessageBox("This is a message", "This is a custom title", 'ERROR')


You can see hear I made a custom message box method called ShowMessageBox() this is what the method will show starting from the first example to the third:

Hope this helps! (sorry for the super late reply)

EDIT for 2.80

UILayout.label(text="") requires text to be a keyword argument.

self.layout.label(text=message)

• The second method works but the first one , i can see any message box. where is it ? at top toolbar i can't see any message. Jun 5, 2018 at 19:56
• How do I make this work under 2.8? Jan 2, 2019 at 7:08
• @yaruncan I made it work by changing self.layout.label(message) to self.layout.label(text=message) Mar 14, 2021 at 17:09