DaVinci Resolve Joke Message

This Python script for Blackmagic Resolve and Resolve Studio will create a custom popup message you can use to play a joke on your unsuspecting coworkers.

To install copy and paste this script into a plain text editor and save as April Fools Day.py to one of these locations:

Linux:
/opt/resolve/Fusion/Scripts/Edit

macOS:
/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Scripts/Edit

Windows:
%PROGRAMDATA%\Blackmagic Design\DaVinci Resolve\Support\Fusion\Scripts\Edit

The script will be accessible from the Workspace -> Scripts -> Edit menu.

Windows requires Python 2.7 or 3.6.

See the video tutorial for more details.

Visit www.metafide.com for DaVinci Resolve productivity apps and custom Resolve coding.

Thanks Adrew Hazelden for demystifying the Blackmagic API built-in Qt bindings.

                    
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Joke pop-up messsage for DaVinci Resolve and resolve Studio. Use at your own risk.
# I'm not responsible for any damages or loss of work arising from the use of this script.
# The script itself can't cause any damage, but a colorist freaking out may!

# Igor Ridanovic, Meta Fide, www.metafide.com
# Thanks Adrew Hazelden for demystifying the BMD API built-in Qt bindings.

# Save this script as April Fools Day.py to:
# Windows: %PROGRAMDATA%\Blackmagic Design\DaVinci Resolve\Support\Fusion\Scripts\Edit
# macOS: /Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Scripts/Edit
# Linux: /opt/resolve/Fusion/Scripts/Edit

# The script will be accessible from the Workspace -> Scripts -> Edit menu.

import sys
import time

buttonCSS = '''
    QPushButton {
    background-color: #2f2f2f;
    color: #929292;
    width: 98px;
    height: 13px;
    font-size: 12px;
    font-weight: normal;
    border-color: #e64b3d;
    border-style: solid;
    border-width: 1px;
    border-radius: 12px;
    padding: 5px;
    margin-left: 8px;
    margin-top: 20px;
    margin-bottom: 6px;
    outline: 0;
    }
    QPushButton:hover {
    color: #ffffff;
    }
    QPushButton:pressed {
    background-color: #171717;
    }
    }
'''

labelCSS = '''
    QLabel {
    color: #fafafa;
    font-size: 16px;
    font-weight: bold;
    margin-left: 8px;
    margin-right: 8px;
    }
'''

jokeMessageCSS = '''
    QLabel {
    margin-left: 8px;
    margin-right: 8px;
    }
'''


class AprilFoolsDay(object):

    def __init__(self):
        try:
            self.ui   = fusion.UIManager
            self.disp = bmd.UIDispatcher(self.ui)
        # No support for the DVR internal Qt when running as an external script.
        except AttributeError:
            sys.exit()

    def collect_input(self):

        win = self.disp.AddWindow({  'ID': 'Message1',
                                     'WindowTitle': 'DaVinci Resolve',
                                     'WindowModality': 'WindowModal'
                            },

                            [
                                self.ui.VGroup(
                                [
                                    self.ui.VGap(0, .25),
                                    self.ui.Label({  'ID': 'msgHeader',
                                                'WordWrap': True,
                                                'Text': 'Enter a joke message and time delay.',
                                                'StyleSheet': labelCSS
                                            }),

                                    self.ui.LineEdit({'ID': 'jokeHeader', 'PlaceholderText': 'Message header'}),
                                    self.ui.LineEdit({'ID': 'jokeMsg', 'PlaceholderText': 'Message'}),
                                    self.ui.HGroup(
                                    [
                                        self.ui.LineEdit({'ID': 'secondsDelay', 'PlaceholderText': 'Seconds'}),
                                        self.ui.HGap(0, 7)
                                    ]),

                                    self.ui.HGroup(
                                    [
                                        self.ui.HGap(0, 4),
                                        self.ui.Button({'ID': 'Accept',
                                                    'Text': 'Done',
                                                    'StyleSheet': buttonCSS
                                                })
                                    ]),
                                ]),
                            ])



        self.itm = win.GetItems()

        def _closewindow(ev):
            self.disp.ExitLoop()

        win.On.Accept.Clicked  = _closewindow

        win.Resize([500,230])
        win.Show()
        self.disp.RunLoop()
        win.Hide()

        # Return delay for the joke message.
        delay = self.itm['secondsDelay'].Text
        if delay == '' or not delay.isdigit():
            delay = 0

        return int(delay)



    def display_message(self):

        jokeHeader  = self.itm['jokeHeader'].Text
        jokeMessage = self.itm['jokeMsg'].Text

        if jokeHeader.rstrip() == '':
            jokeHeader = 'DaVinci Resolve Joke Message'

        if jokeMessage.rstrip() == '':
            jokeMessage = 'This joke message was brought to you by Meta Fide. When you are done joking visit www.metafide.com for more serious off-the-shelf and custom apps.'

        win = self.disp.AddWindow({  'ID': 'Message2',
                                 'WindowTitle': 'DaVinci Resolve',
                                 'WindowModality': 'WindowModal'
                            },

                            [
                                self.ui.VGroup(
                                [

                                    self.ui.Label({  'ID': 'msgHeader',
                                                'WordWrap': True,
                                                'Text': jokeHeader,
                                                'StyleSheet': labelCSS
                                            }),
                                    self.ui.Label({  'ID': 'msg-txt',
                                                'WordWrap': True,
                                                'Text': jokeMessage,
                                                'StyleSheet': jokeMessageCSS
                                            }),

                                    self.ui.HGroup(
                                    [
                                        self.ui.HGap(0, 4),
                                        self.ui.Button({'ID': 'Accept',
                                                    'Text': 'Done',
                                                    'StyleSheet': buttonCSS
                                                })
                                    ]),
                                ]),
                            ])



        itm = win.GetItems()

        def _closewindow(ev):
            self.disp.ExitLoop()

        win.On.Accept.Clicked  = _closewindow

        win.Resize([500,185])
        win.Show()
        self.disp.RunLoop()
        win.Hide()


if __name__ == '__main__':

    afd   = AprilFoolsDay()
    delay = afd.collect_input()
    time.sleep(delay)
    afd.display_message()