Use existing installed python

1. use installed python
2. add settings to choose python directory
3. add py3 compability
4. create hello world python example
This commit is contained in:
bao-qian
2016-05-05 01:57:03 +01:00
parent bc0f5a9136
commit 785843198a
27 changed files with 362 additions and 177 deletions

View File

@@ -1,16 +1,53 @@
using System.Collections.Generic;
using System.Linq;
using Wox.Core.Plugin;
using Wox.Plugin;
namespace Wox.Core.UserSettings
{
public class PluginsSettings
{
public string PythonDirectory { get; set; }
public Dictionary<string, Plugin> Plugins { get; set; } = new Dictionary<string, Plugin>();
public class PluginSettings
public void UpdatePluginSettings(List<PluginPair> plugins)
{
var metadatas = plugins.Select(p => p.Metadata);
foreach (var metadata in metadatas)
{
if (Plugins.ContainsKey(metadata.ID))
{
var settings = Plugins[metadata.ID];
if (settings.ActionKeywords?.Count > 0)
{
metadata.ActionKeywords = settings.ActionKeywords;
metadata.ActionKeyword = settings.ActionKeywords[0];
}
}
else
{
Plugins[metadata.ID] = new Plugin
{
ID = metadata.ID,
Name = metadata.Name,
ActionKeywords = metadata.ActionKeywords,
Disabled = false
};
}
}
}
public void UpdateActionKeyword(PluginMetadata metadata)
{
var settings = Plugins[metadata.ID];
settings.ActionKeywords = metadata.ActionKeywords;
}
}
public class Plugin
{
public string ID { get; set; }
public string Name { get; set; }
public List<string> ActionKeywords { get; set; }
public bool Disabled { get; set; }
}
}

View File

@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using Wox.Core.Plugin;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
using Newtonsoft.Json;
@@ -31,7 +29,7 @@ namespace Wox.Core.UserSettings
// Order defaults to 0 or -1, so 1 will let this property appear last
[JsonProperty(Order = 1)]
public Dictionary<string, PluginSettings> PluginSettings { get; set; } = new Dictionary<string, PluginSettings>();
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
public List<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new List<CustomPluginHotkey>();
[Obsolete]
@@ -54,61 +52,9 @@ namespace Wox.Core.UserSettings
public int ProxyPort { get; set; }
public string ProxyUserName { get; set; }
public string ProxyPassword { get; set; }
public void UpdatePluginSettings()
{
var metadatas = PluginManager.AllPlugins.Select(p => p.Metadata);
if (PluginSettings == null)
{
var configs = new Dictionary<string, PluginSettings>();
foreach (var metadata in metadatas)
{
addPluginMetadata(configs, metadata);
}
PluginSettings = configs;
}
else
{
var configs = PluginSettings;
foreach (var metadata in metadatas)
{
if (configs.ContainsKey(metadata.ID))
{
var config = configs[metadata.ID];
if (config.ActionKeywords?.Count > 0)
{
metadata.ActionKeywords = config.ActionKeywords;
metadata.ActionKeyword = config.ActionKeywords[0];
}
}
else
{
addPluginMetadata(configs, metadata);
}
}
}
}
private void addPluginMetadata(Dictionary<string, PluginSettings> configs, PluginMetadata metadata)
{
configs[metadata.ID] = new PluginSettings
{
ID = metadata.ID,
Name = metadata.Name,
ActionKeywords = metadata.ActionKeywords,
Disabled = false
};
}
public void UpdateActionKeyword(PluginMetadata metadata)
{
var config = PluginSettings[metadata.ID];
config.ActionKeywords = metadata.ActionKeywords;
}
}
[Obsolete]
public enum OpacityMode
{
Normal = 0,