Skip to content

cmdbox_EN

windows99-hue edited this page Jul 17, 2026 · 2 revisions

cmdbox - Code Display Box in the Upper-Left Corner

The code box that appears when Monika inputs code.

dokibox.cmdbox("os.remove(\"y_cg1.png\")", result="y_cg1.png has been successfully deleted.")
Parameter Type Default Description
cmd str "" The code being input
result str or function "" The result after executing the cmd parameter. When runcmd is True, the value of result is determined by the actual execution result. When passing a string, it outputs the string directly. When passing a function or a parameterless lambda, it executes the function after cmd completes and outputs the function's return value.
font_size int 20 Font size
font_family str Consolas Font family
runcmd bool False Whether to actually execute this command in the system
language str "Python" Where to run the command. Options: "Python", "cmd", "powershell"
clear bool False Whether to clear history when this cmdbox executes
chardelay int 50 Interval between characters in typewriter effect (milliseconds)

Example of passing a function to result

def del_cover():
    path = r"E:\99_my_small_programs\99ddlcmsgbox\01-images\cover4.png"
    try:
        os.remove(path)
        return "cover4.png has been successfully deleted"
    except FileNotFoundError:
        return "Error: cover4.png file does not exist"
    except Exception as e:
        return f"Deletion failed: {str(e)}"

# runcmd=False, result passes a deletion function
dokibox.cmdbox(
    cmd="os.remove cover4.png",
    result=del_cover
)

Closing the cmdbox

Due to the special nature of this window in the story, I designed the closecmdbox() function. When you need to close the cmdbox, please call closecmdbox().

dokibox.dialogbox("That's all for the code demonstration~ Fun, isn't it?", name=self.monika,
                            sprites=[self.monika("center", "happy")], fdst=True)
dokibox.closecmdbox()
Parameter Type Default Description
delay int 0 Wait time before closing the cmdbox, in milliseconds (ms)

Clone this wiki locally