-
Notifications
You must be signed in to change notification settings - Fork 0
/
gtk_helper.py
37 lines (29 loc) · 1.06 KB
/
gtk_helper.py
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from gi.repository import Gtk
from main import APP_NAME
class GtkGladeHelper:
@staticmethod
def show_error_msg(msg, parent_window=None):
position = Gtk.WindowPosition.CENTER_ALWAYS
if parent_window is not None:
position = Gtk.WindowPosition.CENTER_ON_PARENT
dlg = Gtk.MessageDialog(parent_window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, msg)
dlg.set_position(position)
dlg.set_title(APP_NAME)
dlg.run()
dlg.destroy()
@staticmethod
def show_question_msg(question, parent_window=None):
position = Gtk.WindowPosition.CENTER_ALWAYS
if parent_window is not None:
position = Gtk.WindowPosition.CENTER_ON_PARENT
dlg = Gtk.MessageDialog(parent_window, 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, question)
dlg.set_position(position)
dlg.set_title(APP_NAME)
result = dlg.run()
dlg.destroy()
return result
@staticmethod
def show_info_msg():
pass