-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuitka-gui.py
More file actions
146 lines (120 loc) · 5.17 KB
/
nuitka-gui.py
File metadata and controls
146 lines (120 loc) · 5.17 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import tkinter as tk
from tkinter import filedialog, messagebox, ttk
import os, sys, subprocess
import ctypes
# ====== Windows Admin ======
def ensure_admin():
if os.name != "nt":
return
try:
is_admin = ctypes.windll.shell32.IsUserAnAdmin()
except Exception:
is_admin = False
if not is_admin:
params = " ".join([f'"{arg}"' for arg in sys.argv])
ctypes.windll.shell32.ShellExecuteW(
None, "runas", sys.executable, params, None, 1
)
sys.exit()
# ================== FONCTIONS ==================
assets_files = []
def browse_script():
path = filedialog.askopenfilename(filetypes=[("Python files", "*.py")])
if path:
script_entry.delete(0, tk.END)
script_entry.insert(0, path)
def browse_icon():
path = filedialog.askopenfilename(filetypes=[("ICO files", "*.ico")])
if path:
icon_entry.delete(0, tk.END)
icon_entry.insert(0, path)
def browse_assets_files():
files = filedialog.askopenfilenames(title="Sélectionne plusieurs fichiers", filetypes=[("Tous fichiers", "*.*")])
if files:
assets_files.clear()
assets_files.extend(files)
assets_entry.delete(0, tk.END)
assets_entry.insert(0, ", ".join([os.path.basename(f) for f in files]))
def browse_output():
path = filedialog.askdirectory()
if path:
output_entry.delete(0, tk.END)
output_entry.insert(0, path)
def build_command():
script = script_entry.get().strip()
icon = icon_entry.get().strip()
output_dir = output_entry.get().strip()
if not script:
messagebox.showerror("Erreur", "Sélectionne un fichier Python !")
return None, None
if not output_dir:
output_dir = os.path.dirname(script)
cmd = [sys.executable, "-m", "nuitka"]
if standalone_var.get(): cmd.append("--standalone")
if onefile_var.get(): cmd.append("--onefile")
if noconsole_var.get(): cmd.append("--windows-console=disable")
if show_progress_var.get(): cmd.append("--show-progress")
if remove_output_var.get(): cmd.append("--remove-output")
if icon: cmd.append(f'--windows-icon-from-ico={icon}')
for f in assets_files:
dest = os.path.basename(f)
cmd.append(f'--include-data-files={f}={dest}')
if admin_uac_var.get():
cmd.append("--windows-uac-admin")
cmd.append("--enable-plugin=tk-inter")
cmd.append(f'--output-dir={output_dir}')
cmd.append(script)
return cmd, output_dir
def run_nuitka():
cmd, _ = build_command()
if not cmd: return
subprocess.Popen(["cmd", "/k"] + cmd)
print(f"Commande Nuitka : {' '.join(cmd)}")
# ================== GUI ==================
root = tk.Tk()
root.title("Nuitka GUI niggers")
root.geometry("700x600")
style = ttk.Style(root)
style.theme_use("clam")
# ----- FRAME FICHIERS -----
files_frame = ttk.LabelFrame(root, text="Fichiers / Dossiers", padding=10)
files_frame.pack(fill="x", padx=10, pady=5)
row1 = ttk.Frame(files_frame); row1.pack(fill="x", pady=4)
ttk.Label(row1, text="Script Python :", width=18).pack(side="left")
script_entry = ttk.Entry(row1, width=45); script_entry.pack(side="left", padx=5, fill="x", expand=True)
ttk.Button(row1, text="Choisir .py", command=browse_script).pack(side="right")
row2 = ttk.Frame(files_frame); row2.pack(fill="x", pady=4)
ttk.Label(row2, text="Icône (.ico) :", width=18).pack(side="left")
icon_entry = ttk.Entry(row2, width=45); icon_entry.pack(side="left", padx=5, fill="x", expand=True)
ttk.Button(row2, text="Parcourir", command=browse_icon).pack(side="right")
row3 = ttk.Frame(files_frame); row3.pack(fill="x", pady=4)
ttk.Label(row3, text="Fichiers assets :", width=18).pack(side="left")
assets_entry = ttk.Entry(row3, width=45); assets_entry.pack(side="left", padx=5, fill="x", expand=True)
ttk.Button(row3, text="Choisir fichiers", command=browse_assets_files).pack(side="right")
row4 = ttk.Frame(files_frame); row4.pack(fill="x", pady=4)
ttk.Label(row4, text="Dossier de sortie :", width=18).pack(side="left")
output_entry = ttk.Entry(row4, width=45); output_entry.pack(side="left", padx=5, fill="x", expand=True)
ttk.Button(row4, text="Parcourir", command=browse_output).pack(side="right")
# ----- OPTIONS NUITKA -----
options_frame = ttk.LabelFrame(root, text="Options Nuitka", padding=10)
options_frame.pack(fill="x", padx=10, pady=5)
standalone_var = tk.BooleanVar(value=True)
onefile_var = tk.BooleanVar(value=True)
noconsole_var = tk.BooleanVar(value=True)
show_progress_var = tk.BooleanVar(value=True)
remove_output_var = tk.BooleanVar(value=True)
admin_uac_var = tk.BooleanVar(value=False)
opts = [
("Standalone", standalone_var),
("Onefile", onefile_var),
("Console désactivée", noconsole_var),
("Barre de progression", show_progress_var),
("Nettoyer les fichiers temp", remove_output_var),
("Admin (UAC)", admin_uac_var),
]
for text, var in opts:
ttk.Checkbutton(options_frame, text=text, variable=var).pack(anchor="w", pady=2)
# ----- BOUTON COMPILER -----
ttk.Button(root, text="Compiler", command=run_nuitka).pack(pady=20)
ensure_admin()
root.mainloop()