Add support for custom header logo image within assets dir
should avoid external URL for header logo where possible
This commit is contained in:
parent
cd392fa432
commit
e1dcd7d4ed
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
WuttaPOS.egg-info/
|
||||
wuttapos/assets/custom_header_logo.png
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
WuttaPOS - flet views (base class)
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from rattail.files import resource_path
|
||||
|
||||
import flet as ft
|
||||
|
||||
from wuttapos.controls.header import WuttaHeader
|
||||
|
@ -66,9 +70,17 @@ class WuttaView(ft.View):
|
|||
pass
|
||||
|
||||
def make_logo_image(self, **kwargs):
|
||||
logo = self.config.get('wuttapos', 'header.logo')
|
||||
if not logo:
|
||||
|
||||
# we have a default header logo, but prefer custom if present
|
||||
custom = resource_path('wuttapos:assets/custom_header_logo.png')
|
||||
if os.path.exists(custom):
|
||||
logo = '/custom_header_logo.png'
|
||||
else:
|
||||
logo = '/header_logo.png'
|
||||
|
||||
# but config can override in any case
|
||||
logo = self.config.get('wuttapos', 'header.logo', default=logo)
|
||||
|
||||
kwargs.setdefault('height', 100)
|
||||
return ft.Image(src=logo, **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in a new issue