-
Notifications
You must be signed in to change notification settings - Fork 2
/
p2psp_application_gui.py
53 lines (44 loc) · 1.56 KB
/
p2psp_application_gui.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
@package src
p2psp_application_gui module
"""
# This code is distributed under the GNU General Public License (see
# THE_GENERAL_GNU_PUBLIC_LICENSE.txt for extending this information).
# Copyright (C) 2014, the P2PSP team.
# http://www.p2psp.org
# {{{ Imports
import traceback
try:
from gi.repository import GObject
from gi.repository import Gtk
from gui.controller.main_window_controller import Main_Controller
from gui.view.main_window import Main_Window
from gui.model.model import Model
from gui.common.decorators import exc_handler
except Exception as msg:
traceback.print_exc()
# }}}
@exc_handler
def main_app():
"""
Before using Python threads, or libraries using threads, must apply
GObject.threads_init().This is needed because GTK+ isn't thread safe.Only
one thread,the main thread, is allowed to call GTK+ code at all times.
This function isn't provided by gobject but initializes thread support
in PyGObject (it was called gobject.threads_init() in pygtk).
Contrary to the naming actually it is gi.threads_init().
GObject.idle_add() takes the function and arguments that will get passed to
the function and asks the main loop to schedule its execution in the main
thread.
Instantiate models and views , then pass it to the main_controller.
"""
GObject.threads_init()
App_Model = Model()
App_Window = Main_Window()
App = Main_Controller(App_Window,App_Model)
App.show()
Gtk.main()
App.quit()
print("Exiting Gtk-Main Thread")
if __name__ == "__main__":
main_app()