Welcome to Python, Peetie!
When you call layout.operator(…) you need to give it the name of a registered operator. In Blender, custom operators are implemented as Python classes, so yes, you’ll have to create another class in your Python file. In the Blender text editor if you go to Templates > Python > Operator Simple, it will bring up the skeleton of a basic operator. You can copy the class definition into your Python file along with your Panel class. The bl_idname you give your operator is what you pass to layout.operator, so that it knows what code to call when the button is pressed. Whatever you write into the execute method of your operator is the code that’s executed when you press the button.
Note that right now your register_class call is referring to GlobalShaders, but it should be referring to Test (the class name of your Panel). You have to have a second register_class call that registers your custom operator as well.
You’ve chosen a challenge that might be more complex than it initially appears because loading files, executing arbitrary code, and interacting with the operating system are all Python programming tasks that don’t have much to do with 3D… they’re general purpose programming tasks, and fairly advanced ones at that.
There’s two basic approaches to executing a Python script from a running Python process. You can create a subprocess to run the script, or you can treat the script as a string and “exec” it inside the process that’s running your operator.
The following code should create a new Blender process in the background and execute a python file—but I haven’t tested it, so please excuse my errors. Check out the Python subprocess module’s documentation.
import bpy
import os
import subprocess
subprocess.call([
bpy.app.binary_path,
'--background', '-noaudio', '-nojoystick',
os.path.abspath(bpy.data.filepath), # the current .blend file
'--python',
os.path.abspath(python_script_filepath)
])
The other strategy is to “exec” the code as a string. It behaves approximately like you typed the contents of the file wherever the exec function is called, which would probably be in the middle of your operator’s execute method.
with open('python_script_file.py', 'r') as scriptfile:
script_text = scriptfile.read()
exec(script_text)
Hope some of this helps!