import customtkinter as ctk from PIL import Image, ImageDraw, UnidentifiedImageError…
- User
import customtkinter as ctk from PIL import Image, ImageDraw, UnidentifiedImageError
تنظیمات اولیه
ctk.set_appearance_mode("dark") # حالت تیره ctk.set_default_color_theme("blue") # تم رنگی آبی
ایجاد پنجره اصلی
root = ctk.CTk() root.title("درباره ما") root.geometry("950x750")
def create_gradient_background(): gradient_image = Image.new("RGB", (900, 800), "#0f2027") draw = ImageDraw.Draw(gradient_image) for i in range(900): r = int(15 + (44 - 15) * (i / 900)) g = int(32 + (83 - 32) * (i / 900)) b = int(39 + (100 - 39) * (i / 900)) color = (r, g, b) draw.line([(i, 0), (i, 800)], fill=color) gradient_image_path = "gradient_bg.png" gradient_image.save(gradient_image_path) return gradient_image_path
def load_image(image_path): try: return Image.open(image_path) except (FileNotFoundError, UnidentifiedImageError): print(f"Error loading image from {image_path}") return None
def create_main_frame(root): main_frame = ctk.CTkFrame(master=root, corner_radius=15) main_frame.pack(pady=20, padx=20, fill="both", expand=True) return main_frame
def create_content_frame(main_frame): content_frame = ctk.CTkFrame(master=main_frame, corner_radius=15, fg_color="#333333", border_color="#FFD700", border_width=2) content_frame.pack(pady=20, padx=20, fill="both", expand=True) return content_frame
def add_title(content_frame): title_label = ctk.CTkLabel(master=content_frame, text="درباره ما", font=("B Titr", 36, "bold"), text_color="#FFD700") title_label.pack(pady=20)
def add_logo(content_frame, image_path): logo_image = load_image(image_path) if logo_image: logo_ctk_image = ctk.CTkImage(light_image=logo_image, dark_image=logo_image, size=(150, 150)) image_label = ctk.CTkLabel(master=content_frame, image=logo_ctk_image, text="") image_label.pack(pady=20)
def add_about_text(content_frame): about_text = ( "ما در [نام شرکت/سازمان] متعهد به ارائه بهترین خدمات و محصولات به مشتریان خود هستیم. " "هدف ما ایجاد تجربهای بینظیر برای شماست و ما همیشه در تلاشیم تا با نوآوری و کیفیت بالا، " "نیازهای شما را برآورده کنیم. تیم ما متشکل از افراد ماهر و حرفهای است که با اشتیاق و تعهد، " "به دنبال ارائه بهترینها هستند." ) about_label = ctk.CTkLabel(master=content_frame, text=about_text, font=("B Nazanin", 18), wraplength=800, justify="right", text_color="#FFFFFF") about_label.pack(pady=20)
def add_separator(content_frame): separator = ctk.CTkFrame(master=content_frame, height=2, width=700, fg_color="#FFD700") separator.pack(pady=10)
def add_contact_info(content_frame): contact_title_label = ctk.CTkLabel(master=content_frame, text="راههای ارتباطی", font=("B Titr", 30, "bold"), text_color="#FFD700") contact_title_label.pack(pady=20) contact_text = ( "آدرس: خیابان مثال، پلاک 123، شهر مثال\n" "تلفن: 123-4567890\n" "ایمیل: info@example.com\n" "وبسایت: www.example.com" ) contact_label = ctk.CTkLabel(master=content_frame, text=contact_text, font=("B Nazanin", 18), wraplength=800, justify="right", text_color="#FFFFFF") contact_label.pack(pady=10)
Assistant