Skip to content

Commit

Permalink
add build dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiion committed Nov 27, 2024
1 parent dde1bc2 commit e0a8cc2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ cache
trace
node_modules
result
vision_assistant.egg-info
vision_assistant.egg-info
__pycache__
tutor-next/out
tutor-next/export
*.debhelper
*.substvars
.pybuild
dev_config
1 change: 1 addition & 0 deletions debian/build-packages-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build-essential debhelper devscripts dh-python python3-all python3-setuptools python3-hatchling python3-pyqt5 python3-yaml python3-pillow python3-platformdirs nodejs npm qttools5-dev-tools python3-hatch pybuild-plugin-pyproject
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "schulstick"
version = "0.1.0"
version = "0.1.3"
description = "Interactive educational portal app for IT competency development with OER learning materials"
requires-python = ">=3.8"
dependencies = [
Expand Down
17 changes: 10 additions & 7 deletions src/core/assets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Optional
import pkg_resources
from pathlib import Path
from PyQt5.QtGui import QMovie, QPixmap
Expand All @@ -11,30 +12,32 @@ class Assets:
"""Helper class for managing static assets"""

@staticmethod
def get_asset_path(filename: str) -> Path:
def get_asset_path(filename: str, module: Optional[str] = None) -> Path:
"""Get the full path to an asset file"""
if module is None:
module = 'static'
try:
# First try to get from installed package
return Path(pkg_resources.resource_filename('vision_assistant', f'assets/{filename}'))
return Path(pkg_resources.resource_filename(module, f'assets/{filename}'))
except (ImportError, pkg_resources.DistributionNotFound):
# Fallback to local development path
local_path = Path(__file__).parent.parent / 'vision_assistant' / 'assets' / filename
local_path = Path(__file__).parent.parent / module / 'assets' / filename
if local_path.exists():
return local_path
raise AssetNotFoundError(f"Asset not found: {filename}")

@staticmethod
def load_movie(filename: str) -> QMovie:
def load_movie(filename: str, module: Optional[str] = None) -> QMovie:
"""Load an animated asset file as QMovie"""
movie = QMovie(str(Assets.get_asset_path(filename)))
movie = QMovie(str(Assets.get_asset_path(filename, module)))
if not movie.isValid():
raise AssetNotFoundError(f"Invalid movie asset: {filename}")
return movie

@staticmethod
def load_pixmap(filename: str) -> QPixmap:
def load_pixmap(filename: str, module: Optional[str] = None) -> QPixmap:
"""Load an image asset file as QPixmap"""
pixmap = QPixmap(str(Assets.get_asset_path(filename)))
pixmap = QPixmap(str(Assets.get_asset_path(filename, module)))
if pixmap.isNull():
raise AssetNotFoundError(f"Invalid image asset: {filename}")
return pixmap
15 changes: 12 additions & 3 deletions src/vision_assistant/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@
from PyQt5.QtCore import QBuffer, QByteArray
from core.assets import Assets
from core.preferences import Preferences
from portal.window import PortalWindow
from vision_assistant.vision import HighlightOverlay
from vision_assistant.tutor import TutorView
from PyQt5.QtCore import Qt, QPropertyAnimation, QEasingCurve, QRect
from PyQt5.QtGui import (QPainter, QPainterPath, QColor, QIcon, QMovie, QPixmap)

os.environ['QT_LOGGING_RULES'] = '*.debug=false;qt.qpa.*=false;qt.*=false;*.warning=false'
#maximize logging
#os.environ['QT_LOGGING_RULES'] = '*.debug=true;qt.qpa.*=true;qt.*=true;*.warning=true'

class CircularWindow(QWidget):
def __init__(self):
super().__init__()
self.tutor_view = None
self.porttal = None
self.preferences = Preferences.load()

# Setup logging
Expand Down Expand Up @@ -99,18 +103,21 @@ def hide_to_tray(self):
def initUI(self):
self.setGeometry(self.circular_geometry)


# Add background animation for circular view
try:
self.movie = Assets.load_movie('cloud.webp')
self.movie = Assets.load_movie('cloud.webp', "vision_assistant")
except Exception as e:
self.logger.error(f"Failed to load movie: {e}")
self.movie = QMovie()
self.movie.setFileName('') # Empty movie acts as black background

self.movie.frameChanged.connect(self.repaint)
self.movie.start()

# Load static background for expanded view
try:
self.night_bg = Assets.load_pixmap('night.jpg')
self.night_bg = Assets.load_pixmap('night.jpg', "vision_assistant")
except Exception:
self.night_bg = QPixmap()

Expand Down Expand Up @@ -318,7 +325,9 @@ def show_tutor(self):

def launch_portal(self):
"""Launch the portal application"""
QApplication.instance().startDetached("portal")
if not self.porttal:
self.porttal = PortalWindow()
self.porttal.show()

def cleanup_session(self):
"""Clean up API session on close"""
Expand Down

0 comments on commit e0a8cc2

Please sign in to comment.