Skip to content

Commit

Permalink
Fix flet linting and directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkolenc committed Nov 26, 2024
1 parent 7487a2a commit e798f97
Show file tree
Hide file tree
Showing 55 changed files with 191 additions and 172 deletions.
1 change: 1 addition & 0 deletions environment/configuration/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ docopt
matplotlib
networkx[default]
pyside6>=6.6
flet==0.22.*
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sections = "FUTURE,STDLIB,THIRDPARTY,AP,FIRSTPARTY,LOCALFOLDER"
profile = "black"

[tool.pylint]
disable = "C0103, C0114, C0115, C0116, C0302, E0401, W0212, W0511, R0801"
disable = "C0103, C0114, C0115, C0116, C0302, E0401, W0212, W0511, R0801, R0903, R0917"
extension-pkg-allow-list = [
"matplotlib",
"PySide6",
Expand Down
124 changes: 0 additions & 124 deletions source/package/adaptation_pathways/app/main.py

This file was deleted.

1 change: 0 additions & 1 deletion source/package/adaptation_pathways/app/requirements.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions source/package/pathways_app/controls/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Customized Flet controls
"""
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
# pylint: disable=too-many-arguments
import flet as ft
import theme


class Header(ft.Container):
def __init__(
self,
icon=None,
text="",
size=16,
self,
icon=None,
text="",
size=16,
expand=True,
color=theme.colors.primary_dark,
padding=0,
border_radius=0,
padding=0,
border_radius=0,
border: ft.Border | None = None,
bgcolor:str | None = None
bgcolor: str | None = None,
):
super().__init__(
height=(size + 2*padding),
height=(size + 2 * padding),
padding=padding,
expand=expand,
bgcolor=bgcolor,
border_radius=border_radius,
border=border
border=border,
)

header_text_style = ft.TextStyle(
size=size,
height=1,
Expand All @@ -35,16 +37,12 @@ def __init__(
expand=expand,
controls=[
ft.Image(icon, width=size, height=size, color=color),
ft.Text(text, style=header_text_style)
],
spacing=4,
vertical_alignment=ft.CrossAxisAlignment.CENTER
ft.Text(text, style=header_text_style),
],
spacing=4,
vertical_alignment=ft.CrossAxisAlignment.CENTER,
)
else:
self.content=ft.Row(
expand=True,
controls=[
ft.Text(text, style=header_text_style)
]
self.content = ft.Row(
expand=True, controls=[ft.Text(text, style=header_text_style)]
)

Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import flet as ft
import theme


class Panel(ft.Container):
def __init__(self, content=None):
super().__init__(
expand=True,
expand=True,
margin=0,
padding=ft.padding.symmetric(8,8),
padding=ft.padding.symmetric(8, 8),
bgcolor=theme.colors.primary_white,
border = ft.border.all(1, theme.colors.primary_light),
border_radius = theme.variables.small_radius,
border=ft.border.all(1, theme.colors.primary_light),
border_radius=theme.variables.small_radius,
content=content,
)
# [
Expand All @@ -25,5 +26,5 @@ def __init__(self, content=None):
# right=0,
# top=0,
# bottom=0
# )
# )
# ]
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import flet as ft
import theme
import logging
from controls.header import Header


class TabbedPanel(ft.Column):
selected_index: int = 0
tab_buttons: list[ft.TextButton]
content: ft.Container

def __init__(self, tabs: list[tuple[Header,ft.Control]], selected_index: int):
def __init__(self, tabs: list[tuple[Header, ft.Control]], selected_index: int):
def get_tab_bgcolor(index: int):
return theme.colors.primary_white if self.selected_index == index else theme.colors.primary_lighter
if self.selected_index == index:
return theme.colors.primary_white
return theme.colors.primary_lighter

def on_click(e):
self.selected_index=self.tab_buttons.index(e.control)
self.selected_index = self.tab_buttons.index(e.control)
for [index, tab] in enumerate(self.tab_buttons):
tab.content.bgcolor=get_tab_bgcolor(index)
tab.content.bgcolor = get_tab_bgcolor(index)
tab.content.update()
self.content.content=tabs[self.selected_index][1]
self.content.content.update()
self.content.content = tabs[self.selected_index][1]
self.content.content.update()

super().__init__(
expand=True,
spacing=0,
horizontal_alignment=ft.CrossAxisAlignment.STRETCH
expand=True, spacing=0, horizontal_alignment=ft.CrossAxisAlignment.STRETCH
)

self.selected_index=selected_index
self.selected_index = selected_index

self.tab_buttons=[
self.tab_buttons = [
ft.TextButton(
expand=True,
content=ft.Container(
Expand All @@ -37,21 +37,22 @@ def on_click(e):
padding=10,
bgcolor=get_tab_bgcolor(index),
border_radius=ft.border_radius.only(
top_left=theme.variables.small_radius,
top_left=theme.variables.small_radius,
top_right=theme.variables.small_radius,
),
border = ft.border.only(
border=ft.border.only(
left=ft.BorderSide(1, theme.colors.primary_light),
right=ft.BorderSide(1, theme.colors.primary_light),
top=ft.BorderSide(1, theme.colors.primary_light),
),
),
style=ft.ButtonStyle(
padding=0,
padding=0,
shape=ft.RoundedRectangleBorder(0),
),
on_click=on_click,
) for [index, tab] in enumerate(tabs)
)
for [index, tab] in enumerate(tabs)
]

self.content = ft.Container(
Expand All @@ -66,7 +67,7 @@ def on_click(e):
),
border_radius=ft.border_radius.only(
bottom_left=theme.variables.small_radius,
bottom_right=theme.variables.small_radius
bottom_right=theme.variables.small_radius,
),
)

Expand All @@ -77,4 +78,3 @@ def on_click(e):
),
self.content,
]

Loading

0 comments on commit e798f97

Please sign in to comment.