Rescale
|
@ -83,7 +83,7 @@ class SVT(Channel):
|
|||
self.m_cache[key]['description'] = description
|
||||
self.m_cache[key]['published_parsed'] = published_parsed
|
||||
self.m_cache[key]['title'] = title
|
||||
thumbnail = make_bitmap_from_url(thumbnail_link,wx.Size(720,300))
|
||||
thumbnail = make_bitmap_from_url(thumbnail_link,wx.Size(self.m_screen_width,150))
|
||||
if resolved_link:
|
||||
item = Item(description, resolved_link,
|
||||
self.m_provider_name, published_parsed,
|
||||
|
|
|
@ -87,7 +87,7 @@ class YouTube(Channel):
|
|||
self.m_cache[key]['description'] = description
|
||||
self.m_cache[key]['published_parsed'] = published_parsed
|
||||
self.m_cache[key]['title'] = title
|
||||
thumbnail = make_bitmap_from_url(thumbnail_link, wx.Size(720,300))
|
||||
thumbnail = make_bitmap_from_url(thumbnail_link, wx.Size(self.m_screen_width,150))
|
||||
item = Item(description, resolved_link, self.m_provider_name,
|
||||
published_parsed, thumbnail, title)
|
||||
self.m_items.append(item)
|
||||
|
|
|
@ -18,6 +18,7 @@ class Channel:
|
|||
self.m_name = name
|
||||
self.m_feed = feed
|
||||
self.m_items: Union[list[Item], None] = None
|
||||
self.m_screen_width = 720/2
|
||||
|
||||
def get_logo_as_bitmap(self) -> wx.Bitmap:
|
||||
return self.m_logo
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
import io
|
||||
from os import path
|
||||
from posixpath import relpath
|
||||
|
||||
import requests
|
||||
import wx
|
||||
from typing import Union, Callable
|
||||
|
||||
SIZE = wx.Size(200,135)
|
||||
SIZE = wx.Size(100,68)
|
||||
MYPATH = path.dirname(path.abspath(__file__))
|
||||
SCREEN_WIDTH = 720 /2
|
||||
|
||||
def get_default_logo(providerid: str = 'default') -> wx.Bitmap:
|
||||
if providerid == 'SVT':
|
||||
|
@ -33,7 +35,7 @@ def make_sized_button(parent_pnl: wx.Panel, bitmap_or_str: Union[wx.Bitmap,str],
|
|||
btn_sizer.Add(btn_logo, 0, wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.TOP, 1)
|
||||
|
||||
btn_text = wx.Button(parent_pnl, wx.ID_ANY, text, style=wx.BORDER_NONE | wx.BU_AUTODRAW)
|
||||
btn_text.SetMinSize(wx.Size(720 - SIZE.GetWidth(),SIZE.GetHeight()))
|
||||
btn_text.SetMinSize(wx.Size(SCREEN_WIDTH - SIZE.GetWidth(),SIZE.GetHeight()))
|
||||
btn_text.SetToolTip(text)
|
||||
btn_sizer.Add(btn_text, 0, wx.BOTTOM | wx.RIGHT | wx.TOP | wx.EXPAND, 1)
|
||||
parent_pnl.Bind(wx.EVT_BUTTON, callback, btn_logo)
|
||||
|
@ -47,40 +49,54 @@ def make_bitmap_from_url(logo_url: str, size: wx.Size = SIZE ) -> wx.Bitmap:
|
|||
content = res.content
|
||||
content_bytes = io.BytesIO(content)
|
||||
image = wx.Image(content_bytes, type=wx.BITMAP_TYPE_ANY, index=-1)
|
||||
image = image.Resize(size, (0,0))
|
||||
scale_factor = image.GetWidth() / SCREEN_WIDTH
|
||||
size.SetWidth(SCREEN_WIDTH)
|
||||
height = image.GetHeight()
|
||||
size.SetHeight(height/scale_factor)
|
||||
image.Rescale(size.GetWidth(), size.GetHeight() )
|
||||
return wx.Bitmap(image)
|
||||
|
||||
|
||||
def make_bitmap_from_file(path, size: wx.Size = SIZE) -> wx.Bitmap:
|
||||
image = wx.Image(path, type=wx.BITMAP_TYPE_ANY, index=-1)
|
||||
# scale_factor = image.GetWidth() / SCREEN_WIDTH
|
||||
# size.SetWidth(SCREEN_WIDTH)
|
||||
# height = image.GetHeight()
|
||||
# size.SetHeight(height/scale_factor)
|
||||
# image.Rescale(size.GetWidth(), size.GetHeight() )
|
||||
return wx.Bitmap(image)
|
||||
|
||||
def resolve_svt_channel(svt_id: str) -> dict:
|
||||
|
||||
channels = {
|
||||
"ch-barnkanalen": {
|
||||
"name":
|
||||
"Barnkanalen",
|
||||
"thumbnail": wx.Bitmap('{}/assets/Barnkanalen.png'.format(MYPATH))
|
||||
"thumbnail": make_bitmap_from_file('{}/assets/Barnkanalen.png'.format(MYPATH))
|
||||
},
|
||||
"ch-svt1": {
|
||||
"name":
|
||||
"SVT 1",
|
||||
"thumbnail": wx.Bitmap('{}/assets/SVT1.png'.format(MYPATH))
|
||||
"thumbnail": make_bitmap_from_file('{}/assets/SVT1.png'.format(MYPATH))
|
||||
},
|
||||
"ch-svt2": {
|
||||
"name":
|
||||
"SVT 2",
|
||||
"thumbnail": wx.Bitmap('{}/assets/SVT2.png'.format(MYPATH))
|
||||
"thumbnail": make_bitmap_from_file('{}/assets/SVT2.png'.format(MYPATH))
|
||||
},
|
||||
"ch-svt24": {
|
||||
"name":
|
||||
"SVT 24",
|
||||
"thumbnail": wx.Bitmap('{}/assets/SVT24.png'.format(MYPATH))
|
||||
"thumbnail": make_bitmap_from_file('{}/assets/SVT24.png'.format(MYPATH))
|
||||
},
|
||||
"kunskapskanalen": {
|
||||
"name":
|
||||
"Kunskapskanalen",
|
||||
"thumbnail": wx.Bitmap('{}/assets/Kunskapskanalen.png'.format(MYPATH))
|
||||
"thumbnail": make_bitmap_from_file('{}/assets/Kunskapskanalen.png'.format(MYPATH))
|
||||
},
|
||||
"feed": {
|
||||
"name": "Senaste program",
|
||||
"thumbnail": wx.Bitmap('{}/assets/SVT.png'.format(MYPATH))
|
||||
"thumbnail": make_bitmap_from_file('{}/assets/SVT.png'.format(MYPATH))
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 7 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.5 KiB |
|
@ -156,7 +156,6 @@ class Cast(wx.Frame):
|
|||
self.m_sizer.Add(inner_sizer)
|
||||
self.m_sizer.AddSpacer(SPACER_HEIGHT)
|
||||
self.m_index = self.m_index + 1
|
||||
#self.m_sizer.AddStretchSpacer()
|
||||
self.m_panel.SetupScrolling()
|
||||
self.m_panel.SetSizer(self.m_sizer)
|
||||
self.m_sizer.Fit(self)
|
||||
|
|