Skip to content

Commit a4e40f7

Browse files
authored
Python support (#570)
1 parent 058bc90 commit a4e40f7

28 files changed

+1345
-34
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ indent_size = 2
1212

1313
[{Makefile,**.mk}]
1414
indent_style = tab
15+
16+
[*.py]
17+
indent_size = 4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ install
1111
*.compiled
1212
*.flatpak
1313
.fenv
14+
.venv
15+
__pycache__
16+
*.pyc
17+
18+
# IDEs / editors
19+
.idea
1420

1521
# Project files
1622
src/Library/**/settings

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Among other things, Workbench comes with
1414

1515
- Live GTK/CSS preview
1616
- Library of 100+ examples
17-
- JavaScript, Rust and Vala support
17+
- JavaScript, Python, Rust and Vala support
1818
- Declarative user interface syntax
1919
- Autosave, sessions and projects
2020
- Code linter and formatter

Workbench.doap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<programming-language>Vala</programming-language>
1616
<programming-language>C</programming-language>
1717
<programming-language>Rust</programming-language>
18+
<programming-language>Python</programming-language>
1819

1920
<platform>GTK 4</platform>
2021
<platform>Libadwaita</platform>

build-aux/library-index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ for (const file_info of demos_dir.enumerate_children(
4747
if (demo_dir.get_child("main.js").query_exists(null)) {
4848
languages.push("javascript");
4949
}
50+
if (demo_dir.get_child("main.py").query_exists(null)) {
51+
languages.push("python");
52+
}
5053
if (demo_dir.get_child("main.vala").query_exists(null)) {
5154
languages.push("vala");
5255
}

data/app.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Type=Application
88
Categories=WebDevelopment;Development;IDE;GNOME;GTK;
99
Icon=@app_id@
1010
# TRANSLATORS: Don't translate
11-
Keywords=CSS;JavaScript;GJS;Blueprint;builder;Vala;GTK;libadwaita;Rust;doc;playground;code;
11+
Keywords=CSS;JavaScript;GJS;Blueprint;builder;Vala;GTK;libadwaita;Python;PyGObject;Rust;doc;playground;code;
1212
DBusActivatable=true
1313
StartupNotify=true

data/app.metainfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<ul>
1616
<li>Live GTK/CSS preview</li>
1717
<li>Library of 100+ examples</li>
18-
<li>JavaScript, Rust and Vala support</li>
18+
<li>JavaScript, Python, Rust and Vala support</li>
1919
<li>Declarative user interface syntax</li>
2020
<li>Autosave, sessions and projects</li>
2121
<li>Code linter and formatter</li>

po/POTFILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ src/sessions.js
6060
src/DocumentationViewer.blp
6161
src/DocumentationViewer.js
6262
src/langs/css/css.js
63+
src/langs/python/Builder.js
6364

6465
src/langs/rust/Compiler.js
6566
troll/src/async.js

src/Extensions/Extensions.blp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ Adw.Window window {
5353
enabled: true;
5454
}
5555

56+
$Extension {
57+
title: _("Python");
58+
enabled: true;
59+
}
60+
5661
$Extension extension_rust {
5762
title: _("Rust");
5863
hint: _("To enable Rust support, run the following command in your Console or Terminal");

src/Library/demos/Welcome/main.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import gi
2+
3+
gi.require_version("Gtk", "4.0")
4+
gi.require_version("Adw", "1")
5+
from gi.repository import Gtk, Adw
6+
import workbench
7+
8+
9+
def greet(_widget):
10+
dialog = Adw.MessageDialog(
11+
body="Hello World!",
12+
transient_for=workbench.window
13+
)
14+
15+
dialog.add_response("ok", "Ok")
16+
dialog.connect("response", dialog_response)
17+
dialog.present()
18+
19+
20+
def dialog_response(dialog: Adw.MessageDialog, response: str):
21+
print(response)
22+
dialog.close()
23+
24+
25+
subtitle_box: Gtk.Box = workbench.builder.get_object("subtitle")
26+
27+
button = Gtk.Button(
28+
label="Press me",
29+
margin_top=6,
30+
css_classes=["suggested-action"]
31+
)
32+
button.connect("clicked", greet)
33+
34+
subtitle_box.append(button)
35+
36+
print("Welcome to Workbench!")

0 commit comments

Comments
 (0)