-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
35 lines (28 loc) · 1020 Bytes
/
test.py
File metadata and controls
35 lines (28 loc) · 1020 Bytes
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
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk
# Create the main application window
class MyWindow(Gtk.ApplicationWindow):
def __init__(self, app):
super().__init__(application=app, title="Alert Dialog Example")
self.set_default_size(400, 300)
# Create a button that will trigger the alert dialog
button = Gtk.Button(label="Show Alert")
button.connect("clicked", self.on_button_clicked)
self.set_child(button)
def on_button_clicked(self, widget):
# Create an AlertDialog instance
alert = Gtk.NativeDialog.newv()
alert.set_transient_for(self)
# Show the alert dialog
alert.show(parent=self)
# Create the application
class MyApplication(Gtk.Application):
def __init__(self):
super().__init__(application_id="com.example.AlertDialogExample")
def do_activate(self):
win = MyWindow(self)
win.present()
# Run the application
app = MyApplication()
app.run()