builder_peppermint_void/builder/peppermint/pmostools/peptools/welcome.py
2025-04-25 12:38:42 +00:00

191 lines
5.1 KiB
Python
Executable File

"""
* Author: "PepDebian(peppermintosteam@proton.me)"
*
* License: SPDX-License-Identifier: GPL-3.0-or-later
*
* This script is used to welcome the user to the system
"""
import os
import tkinter as tk
import ttkbootstrap as ttk
import welconf
import welfunc
# Main window configuration
pewel = welconf.bbstyle
pewel.resizable(False, False)
WINDOW_HEIGHT = 450
WINDOW_WIDTH = 700
# Function to center the window on the screen
def center_screen():
"""Center the window on the screen."""
screen_width = pewel.winfo_screenwidth()
screen_height = pewel.winfo_screenheight()
x_cordinate = int((screen_width / 2) - (WINDOW_WIDTH / 2))
y_cordinate = int((screen_height / 2) - (WINDOW_HEIGHT / 2))
pewel.geometry(f"{WINDOW_WIDTH}x{WINDOW_HEIGHT}+{x_cordinate}+{y_cordinate}")
# Function to disable the welcome screen autostart
def disable_autostart():
"""Disable the welcome screen autostart."""
user = os.environ.get("USER")
spath = f"/home/{user}/.config/autostart/Welcome_auto.desktop"
if os.path.isfile(spath):
os.remove(spath)
print("Autostart disabled successfully")
else:
print("No autostart entry to delete")
# Set window icon
pewel.tk.call('wm', 'iconphoto', pewel._w, tk.PhotoImage(
file='/usr/share/pixmaps/peppermint-old.png'))
# Main logo
logo_image = welconf.peppertxt # Original size
logo_label = ttk.Label(pewel, image=logo_image, borderwidth=0)
logo_label.grid(row=0, column=0, columnspan=2, padx=5, pady=5)
# Main frame
main_frame = ttk.Frame(pewel)
main_frame.grid(row=1, column=0, padx=10, pady=10, sticky="nsew")
# ----- "Welcome to Peppermint OS" Section -----
welcome_frame = ttk.Labelframe(main_frame, bootstyle="dark", text="Welcome to Peppermint OS")
welcome_frame.grid(row=0, column=0, padx=5, pady=5, sticky="nsew")
# Buttons with original icon sizes
btn_about = ttk.Button(
welcome_frame,
text="About",
cursor="hand2",
bootstyle="danger",
width=20,
padding=(10, 5),
command=welfunc.about
)
btn_about.grid(row=0, column=0, padx=5, pady=5, sticky="ew")
btn_suggested = ttk.Button(
welcome_frame,
text="Suggested",
cursor="hand2",
bootstyle="danger",
width=20,
padding=(10, 5),
command=welfunc.suggested_packages
)
btn_suggested.grid(row=1, column=0, padx=5, pady=5, sticky="ew")
btn_docs = ttk.Button(
welcome_frame,
text="Pep Docs",
cursor="hand2",
bootstyle="danger",
width=20,
padding=(10, 5),
command=welfunc.pep_docs
)
btn_docs.grid(row=2, column=0, padx=5, pady=5, sticky="ew")
btn_build_log = ttk.Button(
welcome_frame,
text="Build Log",
cursor="hand2",
bootstyle="danger",
width=20,
padding=(10, 5),
command=welfunc.build_date
)
btn_build_log.grid(row=3, column=0, padx=5, pady=5, sticky="ew")
# Button descriptions
ttk.Label(welcome_frame, text=" - What is Peppermint OS", bootstyle="dark").grid(row=0, column=1, sticky="w")
ttk.Label(welcome_frame, text=" - Select Packages and Web Browsers", bootstyle="dark").grid(row=1, column=1, sticky="w")
ttk.Label(welcome_frame, text=" - Peppermint Online Documentation", bootstyle="dark").grid(row=2, column=1, sticky="w")
ttk.Label(welcome_frame, text=" - Review the build log", bootstyle="dark").grid(row=3, column=1, sticky="w")
# ----- "The Peppermint Community" Section -----
community_frame = ttk.Labelframe(main_frame, bootstyle="dark", text="The Peppermint Community")
community_frame.grid(row=0, column=1, padx=5, pady=5, sticky="nsew")
# Right-side icons at original size
forum_icon = welconf.fm
matrix_icon = welconf.mat
mastodon_icon = welconf.tms
codeberg_icon = welconf.cb
# Social buttons
btn_forum = ttk.Button(
community_frame,
text="Forums",
cursor="hand2",
bootstyle="danger",
image=forum_icon,
padding=(15, 15),
width=15,
command=welfunc.source_forge
)
btn_forum.grid(row=0, column=0, padx=10, pady=10)
btn_matrix = ttk.Button(
community_frame,
text="-Matrix-",
cursor="hand2",
bootstyle="danger",
image=matrix_icon,
padding=(15, 15),
width=15,
command=welfunc.matrix
)
btn_matrix.grid(row=0, column=1, padx=10, pady=10)
btn_mastodon = ttk.Button(
community_frame,
text="Mastodon",
cursor="hand2",
bootstyle="danger",
image=mastodon_icon,
padding=(15, 15),
width=15,
command=welfunc.mastodon
)
btn_mastodon.grid(row=1, column=1, padx=10, pady=10)
btn_codeberg = ttk.Button(
community_frame,
text="CodeBerg",
cursor="hand2",
bootstyle="danger",
image=codeberg_icon,
padding=(15, 15),
width=15,
command=welfunc.code_berg
)
btn_codeberg.grid(row=1, column=0, padx=10, pady=10)
# Welcome message
welcome_message = ttk.Label(
community_frame,
text=welconf.MESSAGE_TEXT,
wraplength=250,
bootstyle="dark"
)
welcome_message.grid(row=2, column=0, columnspan=2, pady=5)
# Checkbox to disable autostart
disable_autostart_cb = ttk.Checkbutton(
pewel,
text="Disable Auto start",
bootstyle="light-round-toggle",
command=disable_autostart
)
disable_autostart_cb.place(x=12, y=360)
# Final configurations
pewel.title("Peppermint OS - Welcome")
center_screen()
pewel.mainloop()