From 246b2e41e9a0c88598c81a55d63696999a96da11 Mon Sep 17 00:00:00 2001 From: eshanized Date: Sat, 21 Dec 2024 01:37:49 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs(=5Fexplain):=20more=20detai?= =?UTF-8?q?ls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/share/snigdhaos-welcome/conflicts.py | 58 +++++++++++++----------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/usr/share/snigdhaos-welcome/conflicts.py b/usr/share/snigdhaos-welcome/conflicts.py index c8c8d49..7a87af4 100644 --- a/usr/share/snigdhaos-welcome/conflicts.py +++ b/usr/share/snigdhaos-welcome/conflicts.py @@ -1,25 +1,30 @@ import gi import os -gi.require_version('Gtk', '3.0') -from gi.repository import Gtk +# Ensure the correct GTK version is available +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk # Import GTK for creating GUI components + +# Get the directory of the current script to handle resource paths base_dir = os.path.dirname(os.path.realpath(__file__)) class Conflicts(Gtk.Window): def __init__(self): + # Initialize the window with a title and default size super(Conflicts, self).__init__(title="Information") - self.set_border_width(10) - self.set_default_size(550, 250) - self.connect("delete-event", self.close) + self.set_border_width(10) # Add border width for better spacing + self.set_default_size(550, 250) # Set default window size + self.connect("delete-event", self.close) # Handle window close event + # Set the window icon from the images folder self.set_icon_from_file(os.path.join(base_dir, 'images/snigdhaos-icon.png')) - self.set_position(Gtk.WindowPosition.CENTER) + self.set_position(Gtk.WindowPosition.CENTER) # Center the window on the screen - # Vertical box to hold all UI elements + # Create a vertical box container for organizing the widgets vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) - vbox.set_homogeneous(False) # Optional: Allow different sized widgets - self.add(vbox) + vbox.set_homogeneous(False) # Optional: Allow widgets to have different sizes + self.add(vbox) # Add the vertical box to the window - # List of conflicts and messages + # List of warning messages and titles warnings = [ ("Warning 1", "xcursor-breeze conflicts with breeze"), ("Warning 2", "visual-studio-code-bin conflicts with code"), @@ -29,30 +34,31 @@ class Conflicts(Gtk.Window): ("Warning 6", "midori (zeitgeist) conflicts with catfish") ] - # Iterate through warnings to dynamically add them to the UI + # Loop through each warning and create UI components dynamically for title, message in warnings: - # Create and style header label with markup - header = Gtk.Label(xalign=0) + # Create a header label with bold and italic markup + header = Gtk.Label(xalign=0) # Align the header text to the left header.set_markup(f"{title}") - vbox.pack_start(header, False, False, 0) + vbox.pack_start(header, False, False, 0) # Add header to the vertical box - # Create message label + # Create a message label for each warning msg_label = Gtk.Label() - msg_label.set_text(message) - msg_label.set_xalign(0) # Align the text to the left - vbox.pack_start(msg_label, False, False, 0) + msg_label.set_text(message) # Set the message text + msg_label.set_xalign(0) # Align the message text to the left + vbox.pack_start(msg_label, False, False, 0) # Add message label to the vertical box - # Add a close button at the bottom of the window - close_button = Gtk.Button(label="Close") - close_button.connect("clicked", self.close) - vbox.pack_start(close_button, False, False, 0) + # Add a "Close" button at the bottom of the window + close_button = Gtk.Button(label="Close") # Create a button labeled "Close" + close_button.connect("clicked", self.close) # Connect the button click to close the window + vbox.pack_start(close_button, False, False, 0) # Add the button to the vertical box def close(self, widget, event=None): - # Close the window when the close button is clicked + # Close the window when the "Close" button is clicked or the window is closed self.destroy() -# Run the application +# Main execution block: Runs when the script is executed directly if __name__ == "__main__": + # Create an instance of the Conflicts window window = Conflicts() - window.show_all() - Gtk.main() + window.show_all() # Display all widgets in the window + Gtk.main() # Start the GTK event loop to handle user interactions