mirror of https://github.com/astral-sh/uv
docs: add uv run docs for gui scripts (#6478)
## Summary Follow up docs to https://github.com/astral-sh/uv/pull/6453
This commit is contained in:
parent
34dd8401ed
commit
984cb23d56
|
|
@ -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. 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
|
```shell
|
||||||
# For contributors.
|
# For contributors.
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
|
|
@ -212,6 +212,54 @@ $ uv run --python 3.10 example.py
|
||||||
See the [Python version request](../concepts/python-versions.md#requesting-a-version) documentation
|
See the [Python version request](../concepts/python-versions.md#requesting-a-version) documentation
|
||||||
for more details on requesting Python versions.
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
{: 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
|
||||||
|
```
|
||||||
|
|
||||||
|
{: style="height:50px;width:150px"}
|
||||||
|
|
||||||
## Next steps
|
## Next steps
|
||||||
|
|
||||||
To learn more about `uv run`, see the [command reference](../reference/cli.md#uv-run).
|
To learn more about `uv run`, see the [command reference](../reference/cli.md#uv-run).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue