Skip to content

Commit

Permalink
Update 0.3.4
Browse files Browse the repository at this point in the history
- Changing the icon
- The new SeaPlayer logo will now be displayed in place of <image not found>
  • Loading branch information
romanin-rf committed May 10, 2023
1 parent f77f518 commit 461d47c
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 28 deletions.
7 changes: 5 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@
"seaplayer/css": "seaplayer/css/",
"seaplayer/css/seaplayer.css": "seaplayer/css/",
"seaplayer/css/configurate.css": "seaplayer/css/",
"seaplayer/css/unknown.css": "seaplayer/css/"
"seaplayer/css/unknown.css": "seaplayer/css/",
# * 4) Assets Files
"seaplayer/assets": "seaplayer/assets/",
"seaplayer/assets/image-not-found.png": "seaplayer/assets/"
}

def localize(path: str) -> str: return os.path.join(LOCALDIR, path.replace('/', os.sep).replace('\\', os.sep))
def add_datas(data: Dict[str, str]) -> List[str]: return [f"--add-data \"{localize(path)}{ds}{data[path]}\"" for path in data]

COMMAND_LINE = [
"pyinstaller", "--noconfirm", "--console", "--clean", "--onefile",
f"--icon \"{localize('icons/sea_player-icon-200x200.ico')}\"",
f"--icon \"{localize('icons/icon.ico')}\"",
*add_datas(DATA),
f"\"{localize('SeaPlayer.py')}\""
]
Expand Down
Binary file added icons/icon.ico
Binary file not shown.
Binary file added icons/icon_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon_512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/sea_player-icon-1000x1000.png
Binary file not shown.
Binary file removed icons/sea_player-icon-16x16.png
Binary file not shown.
Binary file removed icons/sea_player-icon-200x200.ico
Binary file not shown.
Binary file removed icons/sea_player-icon-200x200.png
Binary file not shown.
Binary file added seaplayer/assets/image-not-found.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 20 additions & 20 deletions seaplayer/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,15 @@ async def update_progress_bar(self) -> None:
class StandartImageLabel(Label):
def __init__(
self,
default_image: Image.Image,
image: Optional[Image.Image]=None,
fps: int=2,
*,
resample: Resampling=Resampling.NEAREST
):
super().__init__("<image not found>", classes="image-label")
self.image_resample = resample
self.default_image: Image.Image = default_image
self.image: Optional[Image.Image] = image
self.image_text: Union[str, Pixels] = "<image not found>"
self.last_image_size: Optional[Tuple[int, int]] = None
Expand All @@ -182,33 +184,33 @@ def on_mount(self) -> None:
self.update_render = self.set_interval(1/self._fps, self.update_image_label)

async def update_image_label(self):
if self.image is not None:
new_size = (self.size[0], self.size[1])
if self.last_image_size != new_size:
self.image_text = Pixels.from_image(self.image, new_size, self.image_resample)
self.last_image_size = new_size
else:
self.image_text = "<image not found>"
image, resample = (self.default_image, Resampling.NEAREST) if (self.image is None) else (self.image, self.image_resample)

new_size = (self.size[0], self.size[1])
if self.last_image_size != new_size:
self.image_text = Pixels.from_image(image, new_size, resample)
self.last_image_size = new_size

self.update(self.image_text)

async def update_image(self, image: Optional[Image.Image]=None) -> None:
self.image = image

if self.image is not None:
new_size = (self.size[0], self.size[1])
self.image_text = Pixels.from_image(self.image, new_size, self.image_resample)
image, resample = (self.default_image, Resampling.NEAREST) if (self.image is None) else (self.image, self.image_resample)
self.image_text = Pixels.from_image(image, (self.size[0], self.size[1]), resample)

class AsyncImageLabel(Label):
def __init__(
self,
default_image: Image.Image,
image: Optional[Image.Image]=None,
fps: int=2,
*,
resample: Resampling=Resampling.NEAREST
):
super().__init__("<image not found>", classes="image-label")
self.image_resample = resample
self.default_image: Image.Image = default_image
self.image: Optional[Image.Image] = image
self.image_text: Union[str, AsyncPixels] = "<image not found>"
self.last_image_size: Optional[Tuple[int, int]] = None
Expand All @@ -218,22 +220,20 @@ def on_mount(self) -> None:
self.update_render = self.set_interval(1/self._fps, self.update_image_label)

async def update_image_label(self):
if self.image is not None:
new_size = (self.size[0], self.size[1])
if self.last_image_size != new_size:
self.image_text = await AsyncPixels.from_image(self.image, new_size, self.image_resample)
self.last_image_size = new_size
else:
self.image_text = "<image not found>"
image, resample = (self.default_image, Resampling.NEAREST) if (self.image is None) else (self.image, self.image_resample)

new_size = (self.size[0], self.size[1])
if self.last_image_size != new_size:
self.image_text = await AsyncPixels.from_image(image, new_size, resample)
self.last_image_size = new_size

self.update(self.image_text)

async def update_image(self, image: Optional[Image.Image]=None) -> None:
self.image = image

if self.image is not None:
new_size = (self.size[0], self.size[1])
self.image_text = await AsyncPixels.from_image(self.image, new_size, self.image_resample)
image, resample = (self.default_image, Resampling.NEAREST) if (self.image is None) else (self.image, self.image_resample)
self.image_text = await AsyncPixels.from_image(image, (self.size[0], self.size[1]), resample)


# ! Input Field Functions
Expand Down
20 changes: 14 additions & 6 deletions seaplayer/seaplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@

# ! Metadata
__title__ = "SeaPlayer"
__version__ = "0.3.4-unrelease.1"
__version__ = "0.3.4"
__author__ = "Romanin"
__email__ = "[email protected]"
__url__ = "https://github.com/romanin-rf/SeaPlayer"

# ! Contains
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): LOCALDIR = os.path.dirname(sys.executable)
else: LOCALDIR = os.path.dirname(os.path.dirname(__file__))
# ! Paths
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
LOCALDIR = os.path.dirname(sys.executable)
else:
LOCALDIR = os.path.dirname(os.path.dirname(__file__))

CONFIG_PATH = os.path.join(LOCALDIR, "config.properties")
CSS_LOCALDIR = os.path.join(os.path.dirname(__file__), "css")
ASSETS_DIRPATH = os.path.join(os.path.dirname(__file__), "assets")

# ! Assets Paths
IMGPATH_IMAGE_NOT_FOUND = os.path.join(ASSETS_DIRPATH, "image-not-found.png")

# ! Constants
RESAMPLING_SAFE = {
Expand Down Expand Up @@ -147,11 +153,13 @@ def compose(self) -> ComposeResult:
self.music_play_screen = Static(classes="screen-box")
self.music_play_screen.border_title = "Player"

img_image_not_found = Image.open(IMGPATH_IMAGE_NOT_FOUND)

self.music_selected_label = Label(self.get_sound_selected_label_text(), classes="music-selected-label")
if self.config.image_update_method == "sync":
self.music_image = StandartImageLabel(resample=RESAMPLING_SAFE[self.config.image_resample_method])
self.music_image = StandartImageLabel(img_image_not_found, resample=RESAMPLING_SAFE[self.config.image_resample_method])
elif self.config.image_update_method == "async":
self.music_image = AsyncImageLabel(resample=RESAMPLING_SAFE[self.config.image_resample_method])
self.music_image = AsyncImageLabel(img_image_not_found, resample=RESAMPLING_SAFE[self.config.image_resample_method])
else:
raise RuntimeError("The configuration 'image_update_method' is incorrect.")

Expand Down

0 comments on commit 461d47c

Please sign in to comment.