-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gui.py
More file actions
66 lines (54 loc) · 2.09 KB
/
Copy pathtest_gui.py
File metadata and controls
66 lines (54 loc) · 2.09 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
#!/usr/bin/env python3
"""
Script de prueba para verificar que la GUI funciona en WSL.
"""
import sys
import os
# Configurar DISPLAY si no está configurado
if not os.getenv('DISPLAY'):
# Intentar WSLg
if os.path.exists('/tmp/.X11-unix/X0'):
os.environ['DISPLAY'] = ':0'
print("✓ DISPLAY configurado para WSLg: :0")
else:
# Intentar con IP de Windows
import subprocess
try:
result = subprocess.run(['ip', 'route'], capture_output=True, text=True)
for line in result.stdout.split('\n'):
if 'default' in line:
windows_ip = line.split()[2]
os.environ['DISPLAY'] = f'{windows_ip}:0.0'
print(f"✓ DISPLAY configurado para servidor X11: {os.environ['DISPLAY']}")
break
except:
print("⚠️ No se pudo configurar DISPLAY automáticamente")
print("💡 Ejecuta: export DISPLAY=:0 (para WSLg) o export DISPLAY=<IP_WINDOWS>:0.0 (para VcXsrv)")
try:
import tkinter as tk
from tkinter import messagebox
print("✓ tkinter importado correctamente")
# Crear ventana de prueba
root = tk.Tk()
root.title("Prueba de GUI en WSL")
root.geometry("400x200")
label = tk.Label(root, text="✅ ¡La GUI funciona correctamente en WSL!",
font=('Arial', 14), pady=50)
label.pack()
def close_test():
root.destroy()
print("✓ Prueba completada exitosamente")
button = tk.Button(root, text="Cerrar", command=close_test,
font=('Arial', 12), padx=20, pady=10)
button.pack()
print("✓ Ventana de prueba creada")
print("💡 Si ves una ventana, ¡todo funciona!")
root.mainloop()
except ImportError as e:
print(f"❌ Error: tkinter no está instalado")
print("💡 Instala con: sudo apt-get install python3-tk")
sys.exit(1)
except Exception as e:
print(f"❌ Error al crear la ventana: {e}")
print("💡 Verifica que DISPLAY esté configurado correctamente")
sys.exit(1)