Skip to content

Commit

Permalink
[DYN-3109] Disallow Python Migration Assistant when a Python3 engine …
Browse files Browse the repository at this point in the history
…is selected (#11158)

* Disable migration button for cpython3 engine

* Update ScriptEditorWindow.xaml
  • Loading branch information
zeusongit authored Oct 7, 2020
1 parent 16e8ce5 commit 89fe860
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
<value>Use this dropdown to choose the python version/engine to execute your code.</value>
</data>
<data name="PythonScriptEditorMigrationAssistantButtonTooltip" xml:space="preserve">
<value>Migration Assistant to update your Python 2 scripts to Python 3.</value>
<value>Migration Assistant to update your Python 2 scripts to Python 3. Engine must be set to Python 2 version to work.</value>
</data>
<data name="PythonSearchTags" xml:space="preserve">
<value>IronPython;CPython;</value>
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/PythonNodeModels/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<value>Use this dropdown to choose the python version/engine to execute your code.</value>
</data>
<data name="PythonScriptEditorMigrationAssistantButtonTooltip" xml:space="preserve">
<value>Migration Assistant to update your Python 2 scripts to Python 3.</value>
<value>Migration Assistant to update your Python 2 scripts to Python 3. Engine must be set to Python 2 version to work.</value>
</data>
<data name="PythonSearchTags" xml:space="preserve">
<value>IronPython;CPython;</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<DependentUpon>ScriptEditorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SharedCompletionProvider.cs" />
<Compile Include="ValueConverter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DynamoCoreWpf\DynamoCoreWpf.csproj">
Expand Down
8 changes: 6 additions & 2 deletions src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:dww="clr-namespace:Dynamo.Wpf.Windows;assembly=DynamoCoreWpf"
xmlns:avalonedit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
xmlns:p="clr-namespace:PythonNodeModels.Properties;assembly=PythonNodeModels"
xmlns:pythonNodeModel="clr-namespace:PythonNodeModels;assembly=PythonNodeModels"
xmlns:pw="clr-namespace:PythonNodeModelsWpf"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="{Binding nodeModel.Name, Mode=OneWay, RelativeSource={RelativeSource Self}}"
Height="500"
Expand Down Expand Up @@ -56,6 +56,7 @@
<Setter Property="Foreground"
Value="#bbbbbb" />
</Style>
<pw:SelectedPythonEngineToMigrationConverter x:Key="SelectedPythonEngineToMigrationConverter" />
</ResourceDictionary>

</Window.Resources>
Expand Down Expand Up @@ -105,7 +106,10 @@
<Button Style="{StaticResource IconButton}"
Name="MigrationAssistantBtn"
Click="OnMigrationAssistantClicked"
ToolTip="{x:Static p:Resources.PythonScriptEditorMigrationAssistantButtonTooltip}">
ToolTip="{x:Static p:Resources.PythonScriptEditorMigrationAssistantButtonTooltip}"
ToolTipService.ShowOnDisabled="True"
ToolTipService.IsEnabled="True"
IsEnabled="{Binding SelectedItem, ElementName=EngineSelectorComboBox, Converter={StaticResource SelectedPythonEngineToMigrationConverter}}">
<Button.Resources>
<Image x:Key="Shape"
Width="44"
Expand Down
24 changes: 24 additions & 0 deletions src/Libraries/PythonNodeModelsWpf/ValueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using PythonNodeModels;
using System;
using System.Globalization;
using System.Windows.Data;

namespace PythonNodeModelsWpf
{
public class SelectedPythonEngineToMigrationConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return false;
}
return (PythonEngineVersion)value == PythonEngineVersion.IronPython2;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

0 comments on commit 89fe860

Please sign in to comment.