|
|
@ -1,13 +1,15 @@
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
import io
|
|
|
|
import io
|
|
|
|
from os import path
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
from posixpath import relpath
|
|
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
import requests
|
|
|
|
import wx
|
|
|
|
import wx
|
|
|
|
from typing import Union, Callable
|
|
|
|
from typing import Union, Callable
|
|
|
|
|
|
|
|
|
|
|
|
SIZE = wx.Size(200,135)
|
|
|
|
SIZE = wx.Size(100,68)
|
|
|
|
MYPATH = path.dirname(path.abspath(__file__))
|
|
|
|
MYPATH = path.dirname(path.abspath(__file__))
|
|
|
|
|
|
|
|
SCREEN_WIDTH = 720 /2
|
|
|
|
|
|
|
|
|
|
|
|
def get_default_logo(providerid: str = 'default') -> wx.Bitmap:
|
|
|
|
def get_default_logo(providerid: str = 'default') -> wx.Bitmap:
|
|
|
|
if providerid == 'SVT':
|
|
|
|
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_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 = 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_text.SetToolTip(text)
|
|
|
|
btn_sizer.Add(btn_text, 0, wx.BOTTOM | wx.RIGHT | wx.TOP | wx.EXPAND, 1)
|
|
|
|
btn_sizer.Add(btn_text, 0, wx.BOTTOM | wx.RIGHT | wx.TOP | wx.EXPAND, 1)
|
|
|
|
parent_pnl.Bind(wx.EVT_BUTTON, callback, btn_logo)
|
|
|
|
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 = res.content
|
|
|
|
content_bytes = io.BytesIO(content)
|
|
|
|
content_bytes = io.BytesIO(content)
|
|
|
|
image = wx.Image(content_bytes, type=wx.BITMAP_TYPE_ANY, index=-1)
|
|
|
|
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)
|
|
|
|
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:
|
|
|
|
def resolve_svt_channel(svt_id: str) -> dict:
|
|
|
|
|
|
|
|
|
|
|
|
channels = {
|
|
|
|
channels = {
|
|
|
|
"ch-barnkanalen": {
|
|
|
|
"ch-barnkanalen": {
|
|
|
|
"name":
|
|
|
|
"name":
|
|
|
|
"Barnkanalen",
|
|
|
|
"Barnkanalen",
|
|
|
|
"thumbnail": wx.Bitmap('{}/assets/Barnkanalen.png'.format(MYPATH))
|
|
|
|
"thumbnail": make_bitmap_from_file('{}/assets/Barnkanalen.png'.format(MYPATH))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"ch-svt1": {
|
|
|
|
"ch-svt1": {
|
|
|
|
"name":
|
|
|
|
"name":
|
|
|
|
"SVT 1",
|
|
|
|
"SVT 1",
|
|
|
|
"thumbnail": wx.Bitmap('{}/assets/SVT1.png'.format(MYPATH))
|
|
|
|
"thumbnail": make_bitmap_from_file('{}/assets/SVT1.png'.format(MYPATH))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"ch-svt2": {
|
|
|
|
"ch-svt2": {
|
|
|
|
"name":
|
|
|
|
"name":
|
|
|
|
"SVT 2",
|
|
|
|
"SVT 2",
|
|
|
|
"thumbnail": wx.Bitmap('{}/assets/SVT2.png'.format(MYPATH))
|
|
|
|
"thumbnail": make_bitmap_from_file('{}/assets/SVT2.png'.format(MYPATH))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"ch-svt24": {
|
|
|
|
"ch-svt24": {
|
|
|
|
"name":
|
|
|
|
"name":
|
|
|
|
"SVT 24",
|
|
|
|
"SVT 24",
|
|
|
|
"thumbnail": wx.Bitmap('{}/assets/SVT24.png'.format(MYPATH))
|
|
|
|
"thumbnail": make_bitmap_from_file('{}/assets/SVT24.png'.format(MYPATH))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"kunskapskanalen": {
|
|
|
|
"kunskapskanalen": {
|
|
|
|
"name":
|
|
|
|
"name":
|
|
|
|
"Kunskapskanalen",
|
|
|
|
"Kunskapskanalen",
|
|
|
|
"thumbnail": wx.Bitmap('{}/assets/Kunskapskanalen.png'.format(MYPATH))
|
|
|
|
"thumbnail": make_bitmap_from_file('{}/assets/Kunskapskanalen.png'.format(MYPATH))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"feed": {
|
|
|
|
"feed": {
|
|
|
|
"name": "Senaste program",
|
|
|
|
"name": "Senaste program",
|
|
|
|
"thumbnail": wx.Bitmap('{}/assets/SVT.png'.format(MYPATH))
|
|
|
|
"thumbnail": make_bitmap_from_file('{}/assets/SVT.png'.format(MYPATH))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|