-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* minimal test * experimentation with flet * minor * MVC example * MVC example * WIP: UI components * removed requirement fints to make pyinstaller work * rename app main file * demo content * displaying demo objects * WIP: desktop app layout * WIP: app layout * WIP: app layout * WIP: app layout * WIP: invoicing page * prepare for merge
- Loading branch information
Showing
30 changed files
with
2,671 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
"python.testing.pytestEnabled": true, | ||
"python.formatting.provider": "black" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,302 @@ | ||
from loguru import logger | ||
|
||
import flet | ||
from flet import ( | ||
Page, | ||
Row, | ||
Column, | ||
Container, | ||
Text, | ||
Card, | ||
NavigationRailDestination, | ||
UserControl, | ||
ElevatedButton, | ||
TextButton, | ||
Icon, | ||
Dropdown, | ||
dropdown, | ||
) | ||
from flet import icons, colors | ||
|
||
from layout import DesktopAppLayout | ||
|
||
import views | ||
from views import ( | ||
ContactView, | ||
ContactView2, | ||
) | ||
|
||
from tuttle.controller import Controller | ||
from tuttle.model import ( | ||
Contact, | ||
Contract, | ||
Project, | ||
Client, | ||
) | ||
|
||
from tuttle_tests import demo | ||
|
||
|
||
class App: | ||
def __init__( | ||
self, | ||
controller: Controller, | ||
page: Page, | ||
): | ||
self.con = controller | ||
self.page = page | ||
|
||
|
||
class AppPage(UserControl): | ||
def __init__( | ||
self, | ||
app: App, | ||
): | ||
super().__init__() | ||
self.app = app | ||
|
||
def build(self): | ||
self.main_column = Column( | ||
scroll="auto", | ||
) | ||
# self.view = Row([self.main_column]) | ||
|
||
return self.main_column | ||
|
||
def update_content(self): | ||
pass | ||
|
||
|
||
class DemoPage(AppPage): | ||
def __init__( | ||
self, | ||
app: App, | ||
): | ||
super().__init__(app) | ||
|
||
def update(self): | ||
super().update() | ||
|
||
def add_demo_data(self, event): | ||
"""Install the demo data on button click.""" | ||
demo.add_demo_data(self.app.con) | ||
self.main_column.controls.clear() | ||
self.main_column.controls.append( | ||
Text("Demo data installed ☑️"), | ||
) | ||
self.update() | ||
|
||
def build(self): | ||
self.main_column = Column( | ||
[ | ||
ElevatedButton( | ||
"Install demo data", | ||
icon=icons.TOYS, | ||
on_click=self.add_demo_data, | ||
), | ||
], | ||
) | ||
return self.main_column | ||
|
||
|
||
class ContactsPage(AppPage): | ||
def __init__( | ||
self, | ||
app: App, | ||
): | ||
super().__init__(app) | ||
|
||
def update(self): | ||
super().update() | ||
|
||
def update_content(self): | ||
super().update_content() | ||
self.main_column.controls.clear() | ||
|
||
contacts = self.app.con.query(Contact) | ||
|
||
for contact in contacts: | ||
self.main_column.controls.append( | ||
views.make_contact_view(contact), | ||
) | ||
self.update() | ||
|
||
|
||
class ContractsPage(AppPage): | ||
def __init__( | ||
self, | ||
app: App, | ||
): | ||
super().__init__(app) | ||
|
||
def update(self): | ||
super().update() | ||
|
||
def update_content(self): | ||
super().update_content() | ||
self.main_column.controls.clear() | ||
|
||
contracts = self.app.con.query(Contract) | ||
|
||
for contract in contracts: | ||
self.main_column.controls.append( | ||
# TODO: replace with view class | ||
views.make_contract_view(contract) | ||
) | ||
self.update() | ||
|
||
|
||
class ProjectsPage(AppPage): | ||
def __init__( | ||
self, | ||
app: App, | ||
): | ||
super().__init__(app) | ||
|
||
def update(self): | ||
super().update() | ||
|
||
def update_content(self): | ||
super().update_content() | ||
self.main_column.controls.clear() | ||
|
||
projects = self.app.con.query(Project) | ||
|
||
for project in projects: | ||
self.main_column.controls.append( | ||
# TODO: replace with view class | ||
views.make_project_view(project) | ||
) | ||
self.update() | ||
|
||
|
||
class InvoicingPage(AppPage): | ||
def __init__( | ||
self, | ||
app: App, | ||
): | ||
super().__init__(app) | ||
|
||
def update(self): | ||
super().update() | ||
|
||
def update_content(self): | ||
super().update_content() | ||
|
||
self.main_column.controls.clear() | ||
|
||
projects = self.app.con.query(Project) | ||
|
||
project_select = Dropdown( | ||
label="Project", | ||
hint_text="Select the project", | ||
options=[dropdown.Option(project.title) for project in projects], | ||
autofocus=True, | ||
) | ||
|
||
self.main_column.controls.append( | ||
Row( | ||
[ | ||
project_select, | ||
] | ||
) | ||
) | ||
self.update() | ||
|
||
|
||
def main(page: Page): | ||
|
||
con = Controller( | ||
in_memory=True, | ||
verbose=False, | ||
) | ||
|
||
app = App( | ||
controller=con, | ||
page=page, | ||
) | ||
|
||
pages = [ | ||
( | ||
NavigationRailDestination( | ||
icon=icons.TOYS_OUTLINED, | ||
selected_icon=icons.TOYS, | ||
label="Demo", | ||
), | ||
DemoPage(app), | ||
), | ||
( | ||
NavigationRailDestination( | ||
icon=icons.SPEED_OUTLINED, | ||
selected_icon=icons.SPEED, | ||
label="Dashboard", | ||
), | ||
AppPage(app), | ||
), | ||
( | ||
NavigationRailDestination( | ||
icon=icons.WORK, | ||
label="Projects", | ||
), | ||
ProjectsPage(app), | ||
), | ||
( | ||
NavigationRailDestination( | ||
icon=icons.DATE_RANGE, | ||
label="Time", | ||
), | ||
AppPage(app), | ||
), | ||
( | ||
NavigationRailDestination( | ||
icon=icons.CONTACT_MAIL, | ||
label="Contacts", | ||
), | ||
ContactsPage(app), | ||
), | ||
( | ||
NavigationRailDestination( | ||
icon=icons.HANDSHAKE, | ||
label="Clients", | ||
), | ||
AppPage(app), | ||
), | ||
( | ||
NavigationRailDestination( | ||
icon=icons.HISTORY_EDU, | ||
label="Contracts", | ||
), | ||
ContractsPage(app), | ||
), | ||
( | ||
NavigationRailDestination( | ||
icon=icons.OUTGOING_MAIL, | ||
label="Invocing", | ||
), | ||
InvoicingPage(app), | ||
), | ||
( | ||
NavigationRailDestination( | ||
icon=icons.SETTINGS, | ||
label_content=Text("Settings"), | ||
), | ||
AppPage(app), | ||
), | ||
] | ||
|
||
layout = DesktopAppLayout( | ||
page=page, | ||
pages=pages, | ||
title="Tuttle", | ||
window_size=(1280, 720), | ||
) | ||
|
||
page.add( | ||
layout, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
flet.app( | ||
target=main, | ||
) |
Oops, something went wrong.