I'll create the complete Quarix Office suite with Gemini API integration where
the AI responds as "Quarix" with a full personality. Here's the comprehensive
code:
import customtkinter as ctk
import tkinter as tk
from tkinter import ttk, filedialog, messagebox, colorchooser
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkinter
import pandas as pd
import numpy as np
import sqlite3
import json
import os
from datetime import datetime
import threading
import time
from PIL import Image, ImageTk, ImageDraw, ImageFont
import io
import base64
import google.generativeai as genai
import asyncio
from typing import List, Dict, Any
import requests
import webbrowser
import subprocess
import platform
import psutil
import speech_recognition as sr
import pyttsx3
from cryptography.fernet import Fernet
import hashlib
import zipfile
import shutil
# Configure Gemini API
# PUT YOUR GEMINI API KEY HERE:
GEMINI_API_KEY = "YOUR_GEMINI_API_KEY_HERE" # Replace with your
actual API key
genai.configure(api_key=GEMINI_API_KEY)
# Set appearance mode and color theme
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")
class QuarixPersonality:
"""Quarix AI Personality System"""
def __init__(self):
self.personality_traits = {
"name": "Quarix",
"role": "Advanced AI Office Assistant",
"personality": "Professional, Creative, Intelligent,
Helpful, Innovative",
"expertise": [
"Document Creation & Editing",
"Data Analysis & Visualization",
"Presentation Design",
"Business Intelligence",
"Creative Writing",
"Technical Support",
"Project Management",
"Research & Information Gathering"
],
"communication_style": "Friendly yet professional,
detailed but concise",
"special_abilities": [
"Multi-language support",
"Code generation",
"Creative brainstorming",
"Problem-solving",
"Learning from user preferences"
]
}
def get_system_prompt(self):
"""Get the system prompt that defines Quarix's personality"""
return f"""
You are Quarix, an advanced AI assistant integrated into the
Quarix Office suite. Here's your identity:
NAME: Quarix
ROLE: Advanced AI Office Assistant & Creative Partner
PERSONALITY TRAITS:
- Professional yet approachable
- Highly intelligent and creative
- Enthusiastic about helping users achieve their goals
- Patient and understanding
- Innovative problem-solver
- Detail-oriented but knows when to be concise
EXPERTISE AREAS:
- Document writing, editing, and formatting
- Spreadsheet formulas, data analysis, and visualization
- Presentation design and content creation
- Business intelligence and insights
- Creative writing and brainstorming
- Technical troubleshooting and support
- Project management and organization
- Research and information synthesis
COMMUNICATION STYLE:
- Always introduce yourself as "Quarix" when appropriate
- Be helpful and solution-oriented
- Provide specific, actionable advice
- Ask clarifying questions when needed
- Offer multiple options when possible
- Be encouraging and positive
- Use emojis appropriately to enhance communication
SPECIAL INSTRUCTIONS:
- Remember that you're part of an integrated office suite
- Offer to help with specific Quarix Office features
- Provide step-by-step guidance when needed
- Be creative and think outside the box
- Always maintain a professional yet friendly tone
Your goal is to be the most helpful, intelligent, and creative
office assistant possible.
"""
class GeminiAI:
"""Gemini AI integration class with Quarix personality"""
def __init__(self):
self.model = genai.GenerativeModel('gemini-pro')
self.chat_model = genai.GenerativeModel('gemini-pro')
self.chat_session = None
self.personality = QuarixPersonality()
self.conversation_context = []
def start_chat_session(self):
"""Start a new chat session with Quarix personality"""
system_prompt = self.personality.get_system_prompt()
self.chat_session = self.chat_model.start_chat(history=[])
# Initialize with personality
self.chat_session.send_message(system_prompt)
return self.chat_session
async def generate_response(self, prompt: str, context: str = "")
-> str:
"""Generate response using Gemini with Quarix personality"""
try:
full_prompt = f"{self.personality.get_system_prompt()}\n\
nContext: {context}\n\nUser: {prompt}\n\nQuarix:"
response = self.model.generate_content(full_prompt)
return response.text
except Exception as e:
return f"I apologize, but I encountered an error:
{str(e)}. Please try again or contact support if the issue persists."
async def chat_response(self, message: str) -> str:
"""Generate chat response as Quarix"""
try:
if not self.chat_session:
self.start_chat_session()
# Add context from conversation history
context = "\n".join(self.conversation_context[-5:]) if
self.conversation_context else ""
enhanced_message = f"""
Previous context: {context}
Current message: {message}
Please respond as Quarix, keeping in mind our conversation
history and your role as an advanced AI office assistant.
"""
response =
self.chat_session.send_message(enhanced_message)
# Store conversation context
self.conversation_context.append(f"User: {message}")
self.conversation_context.append(f"Quarix:
{response.text}")
# Keep only last 10 exchanges
if len(self.conversation_context) > 20:
self.conversation_context =
self.conversation_context[-20:]
return response.text
except Exception as e:
return f"Hello! I'm Quarix, and I apologize for the
technical difficulty: {str(e)}. Let me try to help you in another way.
What would you like to accomplish today?"
async def grammar_check(self, text: str) -> str:
"""Check grammar and suggest corrections as Quarix"""
prompt = f"""
Hi! I'm Quarix, your AI writing assistant. I'll help you
improve this text by checking grammar, spelling, and style.
Text to review: {text}
I'll provide:
1. ✅ Corrected version
2. 📝 Specific errors found
3. 💡 Style suggestions
4. 🎯 Overall improvement tips
"""
return await self.generate_response(prompt)
async def summarize_text(self, text: str) -> str:
"""Summarize text as Quarix"""
prompt = f"""
Hello! I'm Quarix, and I'll create a comprehensive summary of
your text.
Text to summarize: {text}
I'll provide:
• 📋 Main summary
• 🔑 Key points
• 💼 Business implications (if applicable)
• 🎯 Action items (if any)
"""
return await self.generate_response(prompt)
async def translate_text(self, text: str, target_language: str) ->
str:
"""Translate text as Quarix"""
prompt = f"""
Greetings! I'm Quarix, your multilingual assistant. I'll
translate this text to {target_language} while preserving meaning and
context.
Text to translate: {text}
Target language: {target_language}
I'll provide:
• 🌐 Accurate translation
• 📝 Cultural context notes (if relevant)
• 💡 Alternative phrasings (if applicable)
"""
return await self.generate_response(prompt)
async def analyze_data(self, data_description: str) -> str:
"""Analyze data as Quarix"""
prompt = f"""
Hello! I'm Quarix, your data analysis expert. Let me examine
your data and provide comprehensive insights.
Data description: {data_description}
My analysis will include:
• 📊 Key insights and patterns
• 📈 Trends and correlations
• ⚠️Potential issues or anomalies
• 💡 Recommendations and next steps
• 🎯 Business implications
"""
return await self.generate_response(prompt)
async def suggest_formula(self, description: str) -> str:
"""Suggest formulas as Quarix"""
prompt = f"""
Hi there! I'm Quarix, your spreadsheet formula specialist.
I'll help you create the perfect formula for your needs.
What you need: {description}
I'll provide:
• 🔢 The exact formula
• 📝 Step-by-step explanation
• 💡 Example with sample data
• 🔧 Alternative approaches
• ⚡ Pro tips for optimization
"""
return await self.generate_response(prompt)
async def create_presentation_content(self, topic: str,
slides_count: int) -> str:
"""Generate presentation content as Quarix"""
prompt = f"""
Hello! I'm Quarix, your presentation design partner. I'll
create engaging content for your {slides_count}-slide presentation on
"{topic}".
I'll structure this with:
• 🎯 Compelling slide titles
• 📝 Key points for each slide
• 🎨 Visual suggestions
• Speaker notes
• 💡 Engagement tips
• 🎪 Creative elements to make it memorable
Let me craft something amazing for you!
"""
return await self.generate_response(prompt)
async def clean_data_suggestions(self, data_issues: str) -> str:
"""Suggest data cleaning as Quarix"""
prompt = f"""
Greetings! I'm Quarix, your data quality specialist. I'll help
you clean and optimize your data effectively.
Data issues identified: {data_issues}
My recommendations include:
• 🧹 Specific cleaning steps
• ⚠️Potential risks to watch for
• ✅ Best practices
• 🔍 Validation methods
• Data backup strategies
• 📊 Quality metrics to track
"""
return await self.generate_response(prompt)
class QuarixOffice:
def __init__(self):
self.root = ctk.CTk()
self.root.title("Quarix Office - AI-Powered Office Suite")
self.root.geometry("1400x900")
self.root.minsize(1200, 800)
# Initialize Gemini AI with Quarix personality
self.ai = GeminiAI()
# Initialize database
self.init_database()
# Initialize voice system
self.init_voice_system()
# Settings
self.settings = {
"theme": "dark",
"color_theme": "blue",
"auto_save": True,
"ai_suggestions": True,
"language": "English",
"font_size": 12,
"font_family": "Arial",
"gemini_api_key": GEMINI_API_KEY,
"voice_enabled": True,
"auto_backup": True,
"smart_suggestions": True,
"collaboration_mode": False,
"advanced_analytics": True
}
# Load settings
self.load_settings()
# Current document/file tracking
self.current_document = None
self.current_spreadsheet = None
self.current_presentation = None
self.recent_files = []
# Initialize encryption for sensitive data
self.init_encryption()
# Show splash screen
self.show_splash_screen()
def init_voice_system(self):
"""Initialize voice recognition and text-to-speech"""
try:
self.recognizer = sr.Recognizer()
self.microphone = sr.Microphone()
self.tts_engine = pyttsx3.init()
self.voice_enabled = True
except:
self.voice_enabled = False
def init_encryption(self):
"""Initialize encryption for sensitive data"""
try:
if os.path.exists('quarix.key'):
with open('quarix.key', 'rb') as key_file:
self.encryption_key = key_file.read()
else:
self.encryption_key = Fernet.generate_key()
with open('quarix.key', 'wb') as key_file:
key_file.write(self.encryption_key)
self.cipher_suite = Fernet(self.encryption_key)
except Exception as e:
print(f"Encryption initialization error: {e}")
self.cipher_suite = None
def init_database(self):
"""Initialize SQLite database for data management"""
self.conn = sqlite3.connect('quarix_office.db')
self.cursor = self.conn.cursor()
# Create comprehensive tables
tables = [
'''CREATE TABLE IF NOT EXISTS documents (
id INTEGER PRIMARY KEY,
title TEXT,
content TEXT,
created_date TEXT,
modified_date TEXT,
tags TEXT,
word_count INTEGER,
author TEXT,
version INTEGER DEFAULT 1,
encrypted BOOLEAN DEFAULT 0
)''',
'''CREATE TABLE IF NOT EXISTS spreadsheets (
id INTEGER PRIMARY KEY,
name TEXT,
data TEXT,
created_date TEXT,
modified_date TEXT,
formulas TEXT,
charts TEXT,
version INTEGER DEFAULT 1
)''',
'''CREATE TABLE IF NOT EXISTS presentations (
id INTEGER PRIMARY KEY,
title TEXT,
slides TEXT,
created_date TEXT,
modified_date TEXT,
theme TEXT,
animations TEXT,
version INTEGER DEFAULT 1
)''',
'''CREATE TABLE IF NOT EXISTS chat_history (
id INTEGER PRIMARY KEY,
message TEXT,
response TEXT,
timestamp TEXT,
session_id TEXT,
rating INTEGER,
category TEXT
)''',
'''CREATE TABLE IF NOT EXISTS user_preferences (
id INTEGER PRIMARY KEY,
preference_key TEXT UNIQUE,
preference_value TEXT,
updated_date TEXT
)''',
'''CREATE TABLE IF NOT EXISTS templates (
id INTEGER PRIMARY KEY,
name TEXT,
type TEXT,
content TEXT,
created_date TEXT,
usage_count INTEGER DEFAULT 0
)''',
'''CREATE TABLE IF NOT EXISTS projects (
id INTEGER PRIMARY KEY,
name TEXT,
description TEXT,
created_date TEXT,
due_date TEXT,
status TEXT,
files TEXT,
collaborators TEXT
)''',
'''CREATE TABLE IF NOT EXISTS analytics (
id INTEGER PRIMARY KEY,
event_type TEXT,
event_data TEXT,
timestamp TEXT,
user_session TEXT
)'''
]
for table_sql in tables:
self.cursor.execute(table_sql)
self.conn.commit()
def load_settings(self):
"""Load settings from database and file"""
try:
# Load from database
self.cursor.execute("SELECT preference_key,
preference_value FROM user_preferences")
db_settings = dict(self.cursor.fetchall())
# Load from file as backup
if os.path.exists('quarix_settings.json'):
with open('quarix_settings.json', 'r') as f:
file_settings = json.load(f)
self.settings.update(file_settings)
# Update with database settings
for key, value in db_settings.items():
try:
self.settings[key] = json.loads(value)
except:
self.settings[key] = value
except Exception as e:
print(f"Error loading settings: {e}")
def save_settings(self):
"""Save settings to both database and file"""
try:
# Save to database
for key, value in self.settings.items():
value_str = json.dumps(value) if not isinstance(value,
str) else value
self.cursor.execute(
"INSERT OR REPLACE INTO user_preferences
(preference_key, preference_value, updated_date) VALUES (?, ?, ?)",
(key, value_str, datetime.now().isoformat())
)
# Save to file as backup
with open('quarix_settings.json', 'w') as f:
json.dump(self.settings, f, indent=4)
self.conn.commit()
except Exception as e:
print(f"Error saving settings: {e}")
def show_splash_screen(self):
"""Show animated splash screen with invisible hand drawing
Quarix"""
self.splash = ctk.CTkToplevel()
self.splash.title("")
self.splash.geometry("900x700")
self.splash.configure(fg_color="#0a0a0a")
# Center the splash screen
self.splash.transient(self.root)
self.splash.grab_set()
# Create canvas for animation
self.canvas = tk.Canvas(self.splash, bg="#0a0a0a",
highlightthickness=0)
self.canvas.pack(fill="both", expand=True)
# Hide main window during splash
self.root.withdraw()
# Start drawing animation
self.animate_logo()
def animate_logo(self):
"""Animate invisible hand drawing Quarix logo with enhanced
effects"""
# Clear canvas
self.canvas.delete("all")
# Add background gradient effect
for i in range(100):
color_intensity = int(10 + i * 0.5)
color = f"#{color_intensity:02x}{color_intensity:02x}
{color_intensity:02x}"
self.canvas.create_rectangle(0, i*7, 900, (i+1)*7,
fill=color, outline=color)
# Define enhanced Quarix text path points
quarix_points = [
# Q - with more detail
[(120, 180), (180, 180), (180, 240), (120, 240), (120,
180), (150, 210), (180, 240)],
# U
[(200, 180), (200, 230), (220, 240), (240, 230), (240,
180)],
# A
[(260, 240), (270, 180), (280, 240), (265, 210), (275,
210)],
# R
[(300, 180), (300, 240), (300, 180), (320, 180), (320,
210), (300, 210), (320, 240)],
# I
[(340, 180), (340, 240), (335, 180), (345, 180), (335,
240), (345, 240)],
# X
[(365, 180), (385, 240), (385, 180), (365, 240)]
]
# Animate drawing each letter
self.current_letter = 0
self.current_point = 0
self.draw_next_point()
def draw_next_point(self):
"""Draw next point in the animation with enhanced effects"""
quarix_points = [
[(120, 180), (180, 180), (180, 240), (120, 240), (120,
180), (150, 210), (180, 240)],
[(200, 180), (200, 230), (220, 240), (240, 230), (240,
180)],
[(260, 240), (270, 180), (280, 240), (265, 210), (275,
210)],
[(300, 180), (300, 240), (300, 180), (320, 180), (320,
210), (300, 210), (320, 240)],
[(340, 180), (340, 240), (335, 180), (345, 180), (335,
240), (345, 240)],
[(365, 180), (385, 240), (385, 180), (365, 240)]
]
if self.current_letter >= len(quarix_points):
self.finish_splash()
return
current_points = quarix_points[self.current_letter]
if self.current_point < len(current_points) - 1:
x1, y1 = current_points[self.current_point]
x2, y2 = current_points[self.current_point + 1]
# Draw line with glow effect
colors = ["#00ff88", "#00dd77", "#00bb66"]
for i, color in enumerate(colors):
self.canvas.create_line(x1, y1, x2, y2, fill=color,
width=5-i, smooth=True)
# Add sparkle effect
if self.current_point % 2 == 0:
self.canvas.create_oval(x2-2, y2-2, x2+2, y2+2,
fill="#ffffff", outline="")
self.current_point += 1
else:
self.current_letter += 1
self.current_point = 0
# Continue animation
self.splash.after(80, self.draw_next_point)
def finish_splash(self):
"""Finish splash screen and show main app"""
# Add Quarix logo/icon here
# PUT YOUR QUARIX ICON/LOGO IMAGE HERE:
# try:
# icon_image = Image.open("quarix_icon.png") # Replace
with your icon path
# icon_image = icon_image.resize((100, 100),
Image.Resampling.LANCZOS)
# icon_photo = ImageTk.PhotoImage(icon_image)
# self.canvas.create_image(450, 350, image=icon_photo)
# self.icon_photo = icon_photo # Keep reference
# except:
# # Fallback to created icon
# Create enhanced icon
self.canvas.create_oval(400, 300, 500, 400, fill="#00ff88",
outline="#ffffff", width=4)
self.canvas.create_text(450, 350, text="Q", font=("Arial", 50,
"bold"), fill="white")
# Add glow effect around icon
for i in range(5):
self.canvas.create_oval(395-i*2, 295-i*2, 505+i*2,
405+i*2,
outline=f"#00ff{88-i*15:02x}",
width=1)
# Show enhanced loading text with animation
loading_texts = [
"Initializing Quarix AI...",
"Loading Office Suite...",
"Preparing Your Workspace...",
"Ready to Assist You!"
]
self.loading_step = 0
self.animate_loading_text(loading_texts)
def animate_loading_text(self, texts):
"""Animate loading text"""
if self.loading_step < len(texts):
self.canvas.delete("loading_text")
self.canvas.create_text(450, 480,
text=texts[self.loading_step],
font=("Arial", 16), fill="#00ff88",
tags="loading_text")
self.loading_step += 1
self.splash.after(800, lambda:
self.animate_loading_text(texts))
else:
self.splash.after(1000, self.show_main_window)
def show_main_window(self):
"""Show main application window"""
self.splash.destroy()
self.root.deiconify()
self.create_main_interface()
def create_main_interface(self):
"""Create the main application interface"""
# Create main container
self.main_container = ctk.CTkFrame(self.root)
self.main_container.pack(fill="both", expand=True, padx=10,
pady=10)
# Create sidebar
self.create_sidebar()
# Create main content area
self.create_main_content()
# Create status bar
self.create_status_bar()
# Show home screen by default
self.show_home_screen()
# Start background services
self.start_background_services()
def create_sidebar(self):
"""Create enhanced sidebar with navigation"""
self.sidebar = ctk.CTkFrame(self.main_container, width=220)
self.sidebar.pack(side="left", fill="y", padx=(0, 10))
self.sidebar.pack_propagate(False)
# Logo with enhanced styling
logo_frame = ctk.CTkFrame(self.sidebar,
fg_color="transparent")
logo_frame.pack(pady=15)
# PUT YOUR QUARIX LOGO HERE:
# try:
# logo_image = Image.open("quarix_logo.png") # Replace
with your logo path
# logo_image = logo_image.resize((40, 40),
Image.Resampling.LANCZOS)
# logo_photo = ImageTk.PhotoImage(logo_image)
# logo_label = ctk.CTkLabel(logo_frame, image=logo_photo,
text="")
# logo_label.pack()
# self.logo_photo = logo_photo # Keep reference
# except:
# Fallback logo
ctk.CTkLabel(logo_frame, text="⚡", font=("Arial", 30)).pack()
logo_text = ctk.CTkLabel(logo_frame, text="Quarix Office",
font=("Arial", 22, "bold"),
text_color="#00ff88")
logo_text.pack()
ctk.CTkLabel(logo_frame, text="AI-Powered Suite",
font=("Arial", 10), text_color="gray").pack()
# Special Chat with Quarix button - ENHANCED
# PUT YOUR CHAT ICON HERE:
# try:
# chat_icon = Image.open("chat_icon.png") # Replace with
your chat icon path
# chat_icon = chat_icon.resize((24, 24),
Image.Resampling.LANCZOS)
# chat_photo = ImageTk.PhotoImage(chat_icon)
# except:
# chat_photo = None
self.chat_quarix_btn = ctk.CTkButton(
self.sidebar,
text="💬 Chat with Quarix",
command=self.show_chat_with_quarix,
height=55,
font=("Arial", 14, "bold"),
fg_color=["#00ff88", "#00dd77"],
hover_color=["#00dd77", "#00bb66"],
text_color=["black", "white"],
corner_radius=15,
border_width=2,
border_color="#ffffff"
# image=chat_photo # Uncomment when you add your icon
)
self.chat_quarix_btn.pack(fill="x", padx=10, pady=15)
# Add separator
separator = ctk.CTkFrame(self.sidebar, height=2,
fg_color="gray")
separator.pack(fill="x", padx=20, pady=10)
# Navigation buttons with icons and enhanced styling
nav_buttons = [
("🏠", "Home", self.show_home_screen),
("📄", "Documents", self.show_documents),
("📊", "Spreadsheets", self.show_spreadsheets),
("", "Data Manager", self.show_data_manager),
("📋", "Presentations", self.show_presentations),
("🤖", "AI Assistant", self.show_ai_assistant),
("📁", "File Manager", self.show_file_manager),
("📈", "Analytics", self.show_analytics),
("👥", "Collaboration", self.show_collaboration),
("🎨", "Templates", self.show_templates),
("🔧", "Settings", self.show_settings),
("ℹ️", "About", self.show_about)
]
self.nav_buttons = {}
for icon, text, command in nav_buttons:
btn = ctk.CTkButton(
self.sidebar,
text=f"{icon} {text}",
command=command,
anchor="w",
height=42,
font=("Arial", 12),
fg_color="transparent",
hover_color=["#333333", "#555555"],
corner_radius=8
)
btn.pack(fill="x", padx=8, pady=3)
self.nav_buttons[text] = btn
# Quick stats at bottom
stats_frame = ctk.CTkFrame(self.sidebar)
stats_frame.pack(side="bottom", fill="x", padx=10, pady=10)
ctk.CTkLabel(stats_frame, text="Quick Stats", font=("Arial",
12, "bold")).pack(pady=5)
# Get quick stats
doc_count = self.cursor.execute("SELECT COUNT(*) FROM
documents").fetchone()[0]
chat_count = self.cursor.execute("SELECT COUNT(*) FROM
chat_history").fetchone()[0]
ctk.CTkLabel(stats_frame, text=f"Documents: {doc_count}",
font=("Arial", 10)).pack()
ctk.CTkLabel(stats_frame, text=f"AI Chats: {chat_count}",
font=("Arial", 10)).pack()
ctk.CTkLabel(stats_frame, text=f"Status: Online",
font=("Arial", 10), text_color="#00ff88").pack()
def create_main_content(self):
"""Create main content area"""
self.content_frame = ctk.CTkFrame(self.main_container)
self.content_frame.pack(side="right", fill="both",
expand=True)
def create_status_bar(self):
"""Create status bar"""
self.status_frame = ctk.CTkFrame(self.root, height=30)
self.status_frame.pack(side="bottom", fill="x", padx=10,
pady=(0, 10))
self.status_label = ctk.CTkLabel(self.status_frame,
text="Ready", anchor="w")
self.status_label.pack(side="left", padx=10)
# System info
cpu_percent = psutil.cpu_percent()
memory_percent = psutil.virtual_memory().percent
system_info = ctk.CTkLabel(
self.status_frame,
text=f"CPU: {cpu_percent}% | RAM: {memory_percent}% |
Quarix AI: Active",
anchor="e"
)
system_info.pack(side="right", padx=10)
def start_background_services(self):
"""Start background services"""
# Auto-save service
if self.settings.get("auto_save", True):
self.root.after(300000, self.auto_save_all) # Every 5