Skip to main content

Code editor

This guide covers setting up your code editor for developing VIKTOR apps. Below instructions assume the app resides in a folder called 'my-app-folder'.

Configure the Python interpreter

Open the 'my-app-folder' directory. PyCharm will take this directory as the root directory from which imports are resolved. If you have not installed your app yet PyCharm will ask you to configure a virtual environment. You can click 'Cancel' as the CLI will create a virtual environment when you use the install command. If there is a 'requirements.txt' file you can run viktor-cli install to create a virtual environment and install the app's dependencies. Subsequently, open the settings to select a Python interpreter:

File > Settings > Project: {Project Name} > Python interpreter > Wheel icon > Add...

The virtual environment created by the CLI will be selected as the default existing environment. You can click 'OK', 'Apply' and 'OK' again to select the Python intepreter. Now you are ready to start development in PyCharm!

Automatically start your app

By means of startup tasks, you are able to automatically start the application as soon as you open the project in your code editor.

note

The startup tasks assume the application is installed correctly.

Within the app directory, add the following files:

my-app-folder
└── .idea
├── runConfigurations
│ └── VIKTOR.xml
└── startup.xml

with the following contents:

my-app-folder/.idea/runConfigurations/VIKTOR.xml
<?xml version="1.0" encoding="UTF-8"?>
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="VIKTOR" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="viktor-cli start" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>
my-app-folder/.idea/startup.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectStartupSharedConfiguration">
<configurations>
<configuration id="Shell Script.VIKTOR" name="VIKTOR" />
</configurations>
</component>
</project>

Now re-open your project to check that the app starts in the terminal of the code editor.