diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af26cb543..96285ed14 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -137,9 +137,9 @@ To preview any changes to the documentation locally: 1. Install the [Rust toolchain](https://www.rust-lang.org/tools/install). -1. Run `cargo dev generate-all`, to update any auto-generated documentation. +2. Run `cargo dev generate-all`, to update any auto-generated documentation. -1. Run the development server with: +3. Run the development server with: ```shell # For contributors. diff --git a/docs/assets/uv_gui_script_hello_world.png b/docs/assets/uv_gui_script_hello_world.png new file mode 100644 index 000000000..c9b5f133c Binary files /dev/null and b/docs/assets/uv_gui_script_hello_world.png differ diff --git a/docs/assets/uv_gui_script_hello_world_pyqt.png b/docs/assets/uv_gui_script_hello_world_pyqt.png new file mode 100644 index 000000000..afe5d7841 Binary files /dev/null and b/docs/assets/uv_gui_script_hello_world_pyqt.png differ diff --git a/docs/guides/scripts.md b/docs/guides/scripts.md index 3ab513df7..5904ac398 100644 --- a/docs/guides/scripts.md +++ b/docs/guides/scripts.md @@ -212,6 +212,54 @@ $ uv run --python 3.10 example.py See the [Python version request](../concepts/python-versions.md#requesting-a-version) documentation for more details on requesting Python versions. +## Using GUI scripts + +On Windows `uv` will run your script ending with `.pyw` extension using `pythonw`: + +```python title="example.pyw" +from tkinter import Tk, ttk + +root = Tk() +root.title("uv") +frm = ttk.Frame(root, padding=10) +frm.grid() +ttk.Label(frm, text="Hello World").grid(column=0, row=0) +root.mainloop() +``` + +```console +PS> uv run example.pyw +``` + +![Run Result](../assets/uv_gui_script_hello_world.png){: style="height:50px;width:150px"} + +Similarly, it works with dependencies as well: + +```python title="example_pyqt.pyw" +import sys +from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QGridLayout + +app = QApplication(sys.argv) +widget = QWidget() +grid = QGridLayout() + +text_label = QLabel() +text_label.setText("Hello World!") +grid.addWidget(text_label) + +widget.setLayout(grid) +widget.setGeometry(100, 100, 200, 50) +widget.setWindowTitle("uv") +widget.show() +sys.exit(app.exec_()) +``` + +```console +PS> uv run --with PyQt5 example_pyqt.pyw +``` + +![Run Result](../assets/uv_gui_script_hello_world_pyqt.png){: style="height:50px;width:150px"} + ## Next steps To learn more about `uv run`, see the [command reference](../reference/cli.md#uv-run).