Skip to content
Draft
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bb9e32f
Install python-dotenv and tabulate
gvanrossum Apr 17, 2024
6737581
Small working demo that can draw boxes on a canvas
gvanrossum Apr 17, 2024
de03aa9
Add chat history to drawing demo
gvanrossum Apr 17, 2024
2edaedd
[WIP] Hack on translation a bit
gvanrossum Apr 17, 2024
09ea859
New API for chat history
gvanrossum Apr 18, 2024
c52aa53
Improved the schema with ChatGPT's help. Added Arrow and Ellipse.
gvanrossum Apr 19, 2024
5d07a2a
rendering program using Tkinter
gvanrossum Apr 19, 2024
f46a836
Add a simple rendering function (most of it written by ChatGPT)
gvanrossum Apr 19, 2024
131ad4f
Added dashed and dotted arrows (some help from ChatGPT)
gvanrossum Apr 19, 2024
3f44129
Merge commit '66fd7bb' into drawing
gvanrossum Apr 20, 2024
b90faa7
Rip oput history, for now
gvanrossum Apr 22, 2024
02e28e4
Make pyright happy
gvanrossum Apr 22, 2024
3e1f3e6
Merge branch 'main' into drawing
gvanrossum Apr 22, 2024
e9ac5cf
Keep pydantic also happy
gvanrossum Apr 22, 2024
9e14f42
Add (flawed) history based on prompt_preamble
gvanrossum Apr 22, 2024
75c2efe
Prune history
gvanrossum Apr 22, 2024
970d50b
Add temporary logging
gvanrossum Apr 22, 2024
7560273
Alternate prompting scheme from #241
gvanrossum Apr 22, 2024
439f521
Revert changes to translator.py
gvanrossum May 2, 2024
b0fdd8d
Merge branch 'main' into drawing
gvanrossum May 2, 2024
d385e40
Use Anders' suggestion for history
gvanrossum May 2, 2024
42ce16a
Switch schema to dataclasses
gvanrossum May 2, 2024
c6da914
Black formatting
gvanrossum May 2, 2024
390558e
Remove unused imports
gvanrossum May 2, 2024
e42b2dd
Clarify Failure output
gvanrossum May 2, 2024
11edfb7
Revert verbose logging
gvanrossum May 2, 2024
3f099dc
Reuse drawing window
gvanrossum May 2, 2024
5c6e15f
Don't crash if we cannot import readline (e.g. on Windows)
gvanrossum May 8, 2024
0894ef6
Add crude progress messages
gvanrossum May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Black formatting
gvanrossum committed May 2, 2024
commit c6da9147d082a090e4949948ed37addf8cc32c7c
28 changes: 25 additions & 3 deletions python/examples/drawing/render.py
Original file line number Diff line number Diff line change
@@ -22,14 +22,28 @@ def render_drawing(drawing: Drawing):
def draw_box(box: Box):
x1, y1 = box.x, box.y
x2, y2 = x1 + box.width, y1 + box.height
canvas.create_rectangle(x1, y1, x2, y2, outline=getattr(box.style, "line_color", None) or "black", fill=getattr(box.style, "fill_color", None) or "")
canvas.create_rectangle(
x1,
y1,
x2,
y2,
outline=getattr(box.style, "line_color", None) or "black",
fill=getattr(box.style, "fill_color", None) or "",
)
if box.text:
canvas.create_text((x1 + x2) / 2, (y1 + y2) / 2, text=box.text, fill="black")

def draw_ellipse(ellipse: Ellipse):
x1, y1 = ellipse.x, ellipse.y
x2, y2 = x1 + ellipse.width, y1 + ellipse.height
canvas.create_oval(x1, y1, x2, y2, outline=getattr(ellipse.style, "line_color", None) or "black", fill=getattr(ellipse.style, "fill_color", None) or "")
canvas.create_oval(
x1,
y1,
x2,
y2,
outline=getattr(ellipse.style, "line_color", None) or "black",
fill=getattr(ellipse.style, "fill_color", None) or "",
)
if ellipse.text:
canvas.create_text((x1 + x2) / 2, (y1 + y2) / 2, text=ellipse.text, fill="black")

@@ -62,7 +76,15 @@ def draw_arrow(arrow: Arrow):
example_drawing = Drawing(
type="Drawing",
items=[
Box(type="Box", x=50, y=50, width=100, height=100, text="Hello", style=Style(type="Style")),
Box(
type="Box",
x=50,
y=50,
width=100,
height=100,
text="Hello",
style=Style(type="Style"),
),
Ellipse(
type="Ellipse",
x=200,
5 changes: 4 additions & 1 deletion python/examples/drawing/schema.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,10 @@ class Style:

type: Literal["Style"]

corners: Annotated[Optional[Literal["rounded", "sharp"]], Doc("Corner style of the drawing elements.")] = None
corners: Annotated[
Optional[Literal["rounded", "sharp"]],
Doc("Corner style of the drawing elements."),
] = None
line_thickness: Annotated[Optional[int], Doc("Thickness of the lines.")] = None
line_color: Annotated[Optional[str], Doc("CSS-style color code for line color.")] = None
fill_color: Annotated[Optional[str], Doc("CSS-style color code for fill color.")] = None