This repository was archived by the owner on Jul 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwelcome.py
More file actions
executable file
·54 lines (43 loc) · 1.92 KB
/
Copy pathwelcome.py
File metadata and controls
executable file
·54 lines (43 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
import sys
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw
class MainWindow(Gtk.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.box1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.set_child(self.box1)
self.button1 = Gtk.Button(label="Hello")
self.box1.append(self.button1)
self.button1.connect('clicked', self.hello)
self.button2 = Gtk.Button(label="About")
self.box1.append(self.button2)
self.button2.connect('clicked', self.open_about_window)
def hello(self, button):
print("Hello world")
def open_about_window(self, widget):
dialog = Adw.AboutWindow(transient_for=app.get_active_window())
dialog.set_application_name("App name")
dialog.set_version("1.0")
dialog.set_developer_name("Developer")
dialog.set_license_type(Gtk.License(Gtk.License.GPL_3_0))
dialog.set_comments("Adw about Window example")
dialog.set_website("https://github.com/Tailko2k/GTK4PythonTutorial")
dialog.set_issue_url("https://github.com/Tailko2k/GTK4PythonTutorial/issues")
dialog.add_credit_section("Contributors", ["Name1 url"])
dialog.set_translator_credits("Name1 url")
dialog.set_copyright("© 2022 developer")
dialog.set_developers(["Developer"])
dialog.set_application_icon("com.github.devname.appname") # icon must be uploaded in ~/.local/share/icons or /usr/share/icons
dialog.set_visible(True)
class MyApp(Adw.Application):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.connect('activate', self.on_activate)
def on_activate(self, app):
self.win = MainWindow(application=app)
self.win.present()
app = MyApp(application_id="com.example.GtkApplication")
app.run(sys.argv)