-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyinstallerSetting.cs
101 lines (92 loc) · 3.26 KB
/
PyinstallerSetting.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PyinstallerHelper
{
public partial class PyinstallerSetting : Form
{
public PyinstallerSetting()
{
InitializeComponent();
MaximizeBox = false;
}
private void button1_Click(object sender, EventArgs e)
{
RuntimeConfiguration.c.PyinstallerPath = textBox1.Text;
RuntimeConfiguration.c.WriteTo(Constants.SettingsPath);
this.Close();
}
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Choose pyinstaller executable";
ofd.Filter = "Executable|*.exe";
ofd.Multiselect = false;
ofd.ShowDialog();
if (ofd.FileName == null || ofd.FileName.Length == 0)
{
return;
}
else
{
textBox1.Text = ofd.FileName;
}
}
private void PyinstallerSetting_Load(object sender, EventArgs e)
{
textBox1.Text = RuntimeConfiguration.c.PyinstallerPath;
if (textBox1.Text == "pyinstaller")
{
textBox1.Text = Routines.GetFullPath("pyinstaller.exe");
if (!Routines.ExistsOnPath("pyinstaller.exe"))
{
label3.Text = "Pyinstaller not found";
label3.ForeColor = Color.Red;
}
}
Process p = new Process()
{
StartInfo =
{
FileName = RuntimeConfiguration.c.PyinstallerPath,
Arguments = "--version",
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
},
};
p.Start();
p.WaitForExit();
label3.Text = $"Pyinstaller Version: {p.StandardOutput.ReadToEnd()}{p.StandardError.ReadToEnd()}";
}
private void button2_Click(object sender, EventArgs e)
{
if (!Routines.ExistsOnPath("py.exe"))
{
MessageBox.Show("Python could not be found! Please install Python or go to Settings -> Python to fix this!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
else
{
if (Routines.RunGUICommand("py.exe -m pip install pyinstaller --upgrade --break --no-color --no-input --yes", 300, "Upgrading Pyinstaller", this) == DialogResult.OK)
{
MessageBox.Show("Successfully upgraded Pyinstaller");
} else
{
MessageBox.Show("Failed! Please try manually");
}
}
PyinstallerSetting_Load(sender, e);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}