How to run python script without f5

Hi!

This is probably a silly question, but my son is just starting to code without drag and drop, and is using this tutorial:

https://projects.raspberrypi.org/en/projects/getting-started-with-minecraft-pi/2

Towards the end of the tutorial, it says:

Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message “Hello world” to the screen:

from mcpi import minecraft

mc = minecraft.Minecraft.create()

mc.postToChat(“Hello world”)

If you’re entering commands directly in to the Python window, just hit Enter after each line. If it’s a file, save with Ctrl + S and run with F5 . When your code runs, you should see your message on screen in the game.

However, I’m just realizing that the Kano computer keyboard does not have an “f5” button on it. Hitting “Enter” just makes the terminal move down to the next line while typing. How do we run the code without an f5 key?

Thank you!

There should be a bar at the top of the window where you’re editing the code (if there’s not, try holding down ‘Ctrl’ or ‘Alt’ and see if it appears). In that toolbar, there’s a button that says ‘Run’. Click on that, then select ‘Run Module’.

If you don’t want to have to do that every time, you can change the shortcut for that: go to the topbar again, then select ‘Options’, then ‘Configure IDLE’. That should pop up a new settings window.

In the settings window that pops up, look at the top and select ‘Keys’. There should be a section that says ‘Custom Key Bindings.’ Scroll down in that until you see ‘run-module’. Select that, then click ‘Get New Keys for Selection’. That will let you set your own custom shortcut instead of using F5 (I suggest something like Ctrl+Shift+R).