# ----------------------------------- MainMenusGUI - Main Menus GUI Function (the code of this module in order to avoid running them during module import and defines GUI functions/signals) -----------------------------------
defmain_menus_gui_func():
globalbuilder
globalmenu1001m
# Define builder and get all objects (Main Menu GUI and About Dialog) from GUI file.
# ********************** Define object functions for Main Menu GUI **********************
defon_menu1001m_show(widget):
checkmenuitem1001m.disconnect_by_func(on_checkmenuitem1001m_toggled)# Disconnect "on_checkmenuitem1001m_toggled" function in order to prevent it from sending event signals when toggling is performed by the code for reflecting the user preference about "Floating Window".
open_terminal_thread=Thread(target=main_menus_gui_open_terminal_func,daemon=True).start()# Terminal is run in another thread in order not to wait end of the run which occurs in single threaded code execution.
defon_checkmenuitem1001m_toggled(widget):# "Floating Summary" menu item
...
...
@@ -75,7 +84,7 @@ def main_menus_gui_func():
globalThread
fromthreadingimportThread
defrestart_as_root():# Running action is performed in a separate thread for letting rest of the function code to be run without waiting closing the new opened application.
os.system("pkexec system-monitoring-center")# For running application as root by using polkit authentication window
os.system("pkexec system-monitoring-center")# For running application as root by using polkit authentication window
restart_as_root_thread=Thread(target=restart_as_root,daemon=True).start()# Define a thread and run it
os.kill(os.getpid(),signal.SIGTERM)# Get PID of the current application and end it
...
...
@@ -100,7 +109,7 @@ def main_menus_gui_func():
Gtk.main_quit()
# ********************** Connect signals to GUI objects for Main Menu GUI **********************
disk_mount_point=bytes(line_split[1],"utf-8").decode("unicode_escape")# String is decoded in order to convert string with escape characters such as "\\040" if they exist.