-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminimal_dpg_test.py
More file actions
49 lines (39 loc) · 1.35 KB
/
minimal_dpg_test.py
File metadata and controls
49 lines (39 loc) · 1.35 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
#!/usr/bin/env python3
"""
Minimal DPG test to verify environment
"""
import os
import sys
try:
import dearpygui.dearpygui as dpg
except ImportError:
print("DearPyGui not found. Please install it with: pip install dearpygui")
sys.exit(1)
# Check if running in a headless environment
if os.environ.get('DISPLAY') is None:
print("Warning: No display detected. DearPyGui requires a display.")
sys.exit(1)
def run_test():
"""Run a minimal DPG test"""
dpg.create_context()
# Create window without using context manager
viewport = dpg.create_viewport(title="DPG Test", width=600, height=400)
window = dpg.add_window(label="Hello World", width=600, height=400)
# Add UI elements
dpg.add_text(parent=window, default_value="Hello, world!")
dpg.add_button(parent=window, label="Click Me", callback=lambda: print("Button clicked!"))
# Setup and show
dpg.setup_dearpygui()
dpg.show_viewport()
try:
# Try to render a single frame
dpg.render_dearpygui_frame()
print("Successfully rendered a frame!")
except Exception as e:
print(f"Error rendering frame: {e}")
# Cleanup
dpg.destroy_context()
print("Test completed. If you saw no errors, DPG is working correctly.")
if __name__ == "__main__":
print("Starting minimal DPG test...")
run_test()