mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
frontend-tools: Display Python version in UI
This commit is contained in:
parent
cee2e7db3f
commit
89d9493468
@ -39,6 +39,8 @@ PythonSettings="Python Settings"
|
||||
PythonSettings.PythonInstallPath32bit="Python Install Path (32bit)"
|
||||
PythonSettings.PythonInstallPath64bit="Python Install Path (64bit)"
|
||||
PythonSettings.BrowsePythonPath="Browse Python Path"
|
||||
PythonSettings.PythonVersion="Loaded Python Version: %1"
|
||||
PythonSettings.PythonNotLoaded="Python not currently loaded"
|
||||
ScriptLogWindow="Script Log"
|
||||
Description="Description"
|
||||
ScriptDescriptionLink.Text="Open this link in your default web browser?"
|
||||
|
@ -268,6 +268,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="pythonVersionLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -194,6 +194,7 @@ ScriptsTool::ScriptsTool() : QDialog(nullptr), ui(new Ui_ScriptsTool)
|
||||
config_get_string(config, "Python", "Path" ARCH_NAME);
|
||||
ui->pythonPath->setText(path);
|
||||
ui->pythonPathLabel->setText(obs_module_text(PYTHONPATH_LABEL_TEXT));
|
||||
updatePythonVersionLabel();
|
||||
#else
|
||||
delete ui->pythonSettingsTab;
|
||||
ui->pythonSettingsTab = nullptr;
|
||||
@ -219,6 +220,20 @@ ScriptsTool::~ScriptsTool()
|
||||
ui->scripts->currentRow());
|
||||
}
|
||||
|
||||
void ScriptsTool::updatePythonVersionLabel()
|
||||
{
|
||||
QString label;
|
||||
if (obs_scripting_python_loaded()) {
|
||||
char version[8];
|
||||
obs_scripting_python_version(version, sizeof(version));
|
||||
label = QString(obs_module_text("PythonSettings.PythonVersion"))
|
||||
.arg(version);
|
||||
} else {
|
||||
label = obs_module_text("PythonSettings.PythonNotLoaded");
|
||||
}
|
||||
ui->pythonVersionLabel->setText(label);
|
||||
}
|
||||
|
||||
void ScriptsTool::RemoveScript(const char *path)
|
||||
{
|
||||
for (size_t i = 0; i < scriptData->scripts.size(); i++) {
|
||||
@ -460,6 +475,8 @@ void ScriptsTool::on_pythonPathBrowse_clicked()
|
||||
if (!obs_scripting_load_python(path))
|
||||
return;
|
||||
|
||||
updatePythonVersionLabel();
|
||||
|
||||
for (OBSScript &script : scriptData->scripts) {
|
||||
enum obs_script_lang lang = obs_script_get_lang(script);
|
||||
if (lang == OBS_SCRIPT_LANG_PYTHON) {
|
||||
|
@ -31,6 +31,8 @@ class ScriptsTool : public QDialog {
|
||||
std::unique_ptr<Ui_ScriptsTool> ui;
|
||||
QWidget *propertiesView = nullptr;
|
||||
|
||||
void updatePythonVersionLabel();
|
||||
|
||||
public:
|
||||
ScriptsTool();
|
||||
~ScriptsTool();
|
||||
|
11
deps/obs-scripting/obs-scripting-python.c
vendored
11
deps/obs-scripting/obs-scripting-python.c
vendored
@ -1590,6 +1590,17 @@ bool obs_scripting_python_runtime_linked(void)
|
||||
return (bool)RUNTIME_LINK;
|
||||
}
|
||||
|
||||
void obs_scripting_python_version(char *version, size_t version_length)
|
||||
{
|
||||
#if RUNTIME_LINK
|
||||
snprintf(version, version_length, "%d.%d", python_version.major,
|
||||
python_version.minor);
|
||||
#else
|
||||
snprintf(version, version_length, "%d.%d", PY_MAJOR_VERSION,
|
||||
PY_MINOR_VERSION);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool obs_scripting_python_loaded(void)
|
||||
{
|
||||
return python_loaded;
|
||||
|
1
deps/obs-scripting/obs-scripting.h
vendored
1
deps/obs-scripting/obs-scripting.h
vendored
@ -46,6 +46,7 @@ EXPORT void obs_scripting_set_log_callback(scripting_log_handler_t handler,
|
||||
void *param);
|
||||
|
||||
EXPORT bool obs_scripting_python_runtime_linked(void);
|
||||
EXPORT void obs_scripting_python_version(char *version, size_t version_length);
|
||||
EXPORT bool obs_scripting_python_loaded(void);
|
||||
EXPORT bool obs_scripting_load_python(const char *python_path);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user