diff --git a/libs/python/bench-ui/examples/folder_example.py b/libs/python/bench-ui/examples/folder_example.py new file mode 100644 index 00000000..324c2cdb --- /dev/null +++ b/libs/python/bench-ui/examples/folder_example.py @@ -0,0 +1,40 @@ +from __future__ import annotations +import time +from bench_ui import launch_window, get_element_rect, execute_javascript +from pathlib import Path +import os + +def main(): + os.environ["CUA_BENCH_UI_DEBUG"] = "1" + + # Get the path to the gui folder + gui_folder = Path(__file__).parent / "gui" + + # Launch a window serving the static folder + pid = launch_window( + folder=str(gui_folder), + title="Static Folder Example", + width=800, + height=600, + ) + print(f"Launched window with PID: {pid}") + print(f"Serving folder: {gui_folder}") + + # Give the window a moment to render + time.sleep(1.5) + + # Query the client rect of the button element + rect = get_element_rect(pid, "#testButton", space="window") + print("Button rect (window space):", rect) + + # Check if button has been clicked + clicked = execute_javascript(pid, "document.getElementById('testButton').disabled") + print("Button clicked:", clicked) + + # Get the page title + title = execute_javascript(pid, "document.title") + print("Page title:", title) + + +if __name__ == "__main__": + main() diff --git a/libs/python/bench-ui/examples/gui/index.html b/libs/python/bench-ui/examples/gui/index.html new file mode 100644 index 00000000..962994f7 --- /dev/null +++ b/libs/python/bench-ui/examples/gui/index.html @@ -0,0 +1,42 @@ + + + + + + + Static Folder Example + + + + +
+

Static Folder Example

+

This page is served from a static folder using bench-ui!

+ +
+ +
+ +
+

This example demonstrates:

+ +
+ + +

+
+ + + + + \ No newline at end of file diff --git a/libs/python/bench-ui/examples/gui/logo.svg b/libs/python/bench-ui/examples/gui/logo.svg new file mode 100644 index 00000000..bd22d128 --- /dev/null +++ b/libs/python/bench-ui/examples/gui/logo.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/python/bench-ui/examples/gui/styles.css b/libs/python/bench-ui/examples/gui/styles.css new file mode 100644 index 00000000..fe63c6e6 --- /dev/null +++ b/libs/python/bench-ui/examples/gui/styles.css @@ -0,0 +1,92 @@ +body { + font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; + margin: 0; + padding: 20px; + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + min-height: 100vh; + display: flex; + justify-content: center; + align-items: center; +} + +.container { + background: white; + border-radius: 12px; + padding: 40px; + box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); + max-width: 600px; + width: 100%; +} + +h1 { + color: #333; + margin-top: 0; + font-size: 2em; +} + +p { + color: #666; + line-height: 1.6; +} + +.image-container { + display: flex; + justify-content: center; + margin: 30px 0; +} + +.logo { + width: 150px; + height: 150px; +} + +.info { + background: #f8f9fa; + border-left: 4px solid #667eea; + padding: 20px; + margin: 20px 0; + border-radius: 4px; +} + +.info ul { + margin: 10px 0; + padding-left: 20px; +} + +.info li { + color: #555; + margin: 8px 0; +} + +.btn { + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + color: white; + border: none; + padding: 12px 30px; + font-size: 16px; + border-radius: 6px; + cursor: pointer; + transition: transform 0.2s, box-shadow 0.2s; + font-weight: 600; +} + +.btn:hover:not(:disabled) { + transform: translateY(-2px); + box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4); +} + +.btn:active:not(:disabled) { + transform: translateY(0); +} + +.btn:disabled { + opacity: 0.6; + cursor: not-allowed; +} + +#status { + margin-top: 15px; + font-weight: 600; + color: #28a745; + font-size: 18px; +} \ No newline at end of file diff --git a/libs/xfce/Dockerfile b/libs/xfce/Dockerfile index 15dd8dc9..550e3f81 100644 --- a/libs/xfce/Dockerfile +++ b/libs/xfce/Dockerfile @@ -123,8 +123,20 @@ RUN mkdir -p /home/cua/.cache && \ # Install computer-server using Python 3.12 pip RUN python3.12 -m pip install cua-computer-server -# Install PyQt6 and pywebview, used by cua-bench for web UIs -RUN python3.12 -m pip install "pywebview[pyside6]" +# Install GTK and WebKit dependencies for pywebview +RUN apt-get update && apt-get install -y \ + python3-gi \ + python3-gi-cairo \ + gir1.2-gtk-3.0 \ + gir1.2-webkit2-4.1 \ + libgirepository1.0-dev \ + libcairo2-dev \ + pkg-config \ + gobject-introspection \ + && rm -rf /var/lib/apt/lists/* + +# Install pywebview with GTK backend, used by cua-bench for web UIs +RUN python3.12 -m pip install "pywebview[gtk]" RUN python3.12 -m pip install cua-bench-ui>=0.7.0 --no-cache-dir # Install playwright and Firefox dependencies diff --git a/libs/xfce/Dockerfile.dev b/libs/xfce/Dockerfile.dev index f1dd7f02..f827c777 100644 --- a/libs/xfce/Dockerfile.dev +++ b/libs/xfce/Dockerfile.dev @@ -124,8 +124,20 @@ COPY python/computer-server /tmp/computer-server RUN python3.12 -m pip install /tmp/computer-server && \ rm -rf /tmp/computer-server -# Install PyQt6 and pywebview, used by cua-bench for web UIs -RUN python3.12 -m pip install "pywebview[pyside6]" +# Install GTK and WebKit dependencies for pywebview +RUN apt-get update && apt-get install -y \ + python3-gi \ + python3-gi-cairo \ + gir1.2-gtk-3.0 \ + gir1.2-webkit2-4.1 \ + libgirepository1.0-dev \ + libcairo2-dev \ + pkg-config \ + gobject-introspection \ + && rm -rf /var/lib/apt/lists/* + +# Install pywebview with GTK backend, used by cua-bench for web UIs +RUN python3.12 -m pip install "pywebview[gtk]" RUN python3.12 -m pip install cua-bench-ui>=0.7.0 --no-cache-dir # Install playwright and Firefox dependencies