Skip to content

Commit

Permalink
improved a little bit admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
c4pointer committed Feb 4, 2023
1 parent e14c16b commit 6d0efd2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 37 deletions.
33 changes: 21 additions & 12 deletions bunkercalc.kv
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ ScreenManager:
# anchor_title: "center"
md_bg_color: "#e7e4c0"
specific_text_color: "#4a4939"
left_action_items: [["calculator-variant", lambda x:app.screen2()],["account-arrow-left-outline", lambda x:app.admin_panel()]]
left_action_items: [["calculator-variant", lambda x:app.screen2(), "Total"],["account-arrow-left-outline", lambda x:app.admin_panel(), "Admin"]]
right_action_items: [["ship-wheel", lambda x: app.choose_vessel(x)]]

# right_action_items: [["menu", lambda x:app.screen2()]]
MDBoxLayout:
orientation : "horizontal"
MDLabel:
id: right_action
halign: "center"
halign: "right"
theme_text_color: "Custom"
text_color: "#4a4939"

MDLabel:
id: select_vessel
halign: "right"
Expand Down Expand Up @@ -71,13 +72,14 @@ ScreenManager:
#md_bg_color: "#e7e4c0"
specific_text_color: "#4a4939"
# right_action_items: [["menu", lambda x:(x)]]
left_action_items: [["calculator-variant", lambda x:app.screen2()],["account-arrow-left-outline", lambda x:app.admin_panel()]]
left_action_items: [["calculator-variant", lambda x:app.screen2(), "Sounding"],["account-arrow-left-outline", lambda x:app.admin_panel(), "Admin Panel"]]

MDLabel:
id: right_action
halign: "center"
theme_text_color: "Custom"
text_color: "#4a4939"
pos_hint_x: .5

MDFloatLayout:
orientation: "vertical"
Expand Down Expand Up @@ -220,17 +222,18 @@ ScreenManager:
# anchor_title: "center"
md_bg_color: "#e7e4c0"
specific_text_color: "#4a4939"
left_action_items: [["calculator-variant", lambda x:app.screen2()],["account-arrow-left-outline", lambda x:app.admin_panel()]]
left_action_items: [["calculator-variant", lambda x:app.screen2(), "Sounding Screen"],["account-arrow-left-outline", lambda x:app.admin_panel(), "Admin Panel"]]


MDBoxLayout:
orientation : "horizontal"
MDLabel:
id: right_action_admin
text: "Admin Panel"
halign: "center"
halign: "right"
theme_text_color: "Custom"
text_color: "#4a4939"
pos_hint_x: .5
MDLabel:
id: select_vessel_admin
# text: "Vessel"
Expand Down Expand Up @@ -305,16 +308,17 @@ ScreenManager:
# anchor_title: "center"
md_bg_color: "#e7e4c0"
specific_text_color: "#4a4939"
left_action_items: [["calculator-variant", lambda x:app.screen2()],["account-arrow-left-outline", lambda x:app.admin_panel()]]
left_action_items: [["calculator-variant", lambda x:app.screen2(), "Sounding Screen"],["account-arrow-left-outline", lambda x:app.admin_panel(), "Back to Admin"]]

MDBoxLayout:
orientation : "horizontal"
MDLabel:
id: right_action_admin
text: "Admin Panel"
halign: "center"
halign: "right"
theme_text_color: "Custom"
text_color: "#4a4939"
pos_hint_x: .5
MDLabel:
id: select_vessel_admin
# text: "Vessel"
Expand Down Expand Up @@ -384,7 +388,7 @@ ScreenManager:
name: 'add_tank_screen'
MDBoxLayout:
orientation : 'vertical'
size_hint_y: 1

# md_bg_color: "#e7d4d0"
MDTopAppBar:
id: top_menu_admin
Expand All @@ -393,16 +397,17 @@ ScreenManager:
# anchor_title: "center"
md_bg_color: "#e7e4c0"
specific_text_color: "#4a4939"
left_action_items: [["calculator-variant", lambda x:app.screen2()],["account-arrow-left-outline", lambda x:app.admin_panel()]]
left_action_items: [["calculator-variant", lambda x:app.screen2(), "Sounding Screen"],["account-arrow-left-outline", lambda x:app.admin_panel(), "Back to Admin"]]

MDBoxLayout:
orientation : "horizontal"
MDLabel:
id: right_action_admin
text : "Total"
halign: "center"
text : "Add Tank to Vessel"
halign: "right"
theme_text_color: "Custom"
text_color: "#4a4939"
pos_hint_x: .5
MDLabel:
id: select_vessel_admin
# text: "Vessel"
Expand All @@ -413,9 +418,10 @@ ScreenManager:
MDBoxLayout:
orientation : "vertical"
# md_bg_color: "#ccccd0"

MDDropDownItem:
id: drop_vessels
pos_hint: {'center_x': .5, 'center_y': .8}
pos_hint: {'center_x': .5, 'center_y': .9}
text: 'Select the Vessel'
on_release: app.choose_vessel_admin()

Expand All @@ -430,6 +436,9 @@ ScreenManager:
# text_color_focus: "white"
max_text_length: 10
disabled: 'True'
# required: "True"
theme_text_color: "Hint"


MDFlatButton:
id : btn_add
Expand Down
2 changes: 1 addition & 1 deletion db_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def sort_tanks_mdo(v):


def import_data(file, db, tk):
conn = sqlite3.connect(str(db))
conn = sqlite3.connect(db)
cur = conn.cursor()
try:
cur.execute("CREATE TABLE IF NOT EXISTS '"+tk+"' (sound_id INT,volume FLOAT NULL,density FLOAT DEFAULT 0.9855 NULL,\
Expand Down
59 changes: 35 additions & 24 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def on_start(self):
self.j = 0

# Label for toggle screens between the total screen and Tabs
self.root.get_screen("tab_screen").ids.right_action.text = "Total result"
self.root.get_screen("tab_screen").ids.right_action.text = "Sounding Screen"
self.root.get_screen("tab_screen").ids.select_vessel.text = "Select vessel"
# self.root.get_screen("tab_screen").ids.calc.disabled = True

Expand Down Expand Up @@ -214,14 +214,18 @@ def screen2(self):
total figure
"""
if self.root.current != "total_screen":
self.root.current = "total_screen"
self.calculate_total()
# Display total results for MDO and HFO
self.root.get_screen("total_screen").ids.right_action.text = "Tank sounding"
self.root.get_screen("total_screen").ids.total_hfo.text = str(round(self.sum_hfo, 3)) + str(" m3 HFO") \
+ str(f"\n {round((self.sum_hfo_tons),2)} MT HFO"+f"\n___________________")
self.root.get_screen("total_screen").ids.total_mdo.text = str(round(self.sum_mdo, 3)) + str(" m3 MDO") \
+ str(f"\n {round((self.sum_mdo_tons),2)} MT MDO")
if self.root.current == "tab_screen":
self.root.current = "total_screen"
self.calculate_total()
# Display total results for MDO and HFO
self.root.get_screen("total_screen").ids.right_action.text = "Total Screen"
self.root.get_screen("total_screen").ids.total_hfo.text = str(round(self.sum_hfo, 3)) + str(" m3 HFO") \
+ str(f"\n {round((self.sum_hfo_tons),2)} MT HFO"+f"\n___________________")
self.root.get_screen("total_screen").ids.total_mdo.text = str(round(self.sum_mdo, 3)) + str(" m3 MDO") \
+ str(f"\n {round((self.sum_mdo_tons),2)} MT MDO")
else:
self.root.current = "tab_screen"

else:
self.root.current = "tab_screen"

Expand Down Expand Up @@ -628,13 +632,18 @@ def create_vessel(self, name):
print(str(e)+str("593"))

def file_manager_open(self):
self.manager_open = False
self.file_manager = MDFileManager(
exit_manager=self.exit_manager, select_path=self.select_path,
ext = ['.csv', ], selection = []
)
self.file_manager.show(os.path.expanduser("~")) # output manager to the screen
self.manager_open = True
# print(self.tk)
if len(self.tk) != 0:
self.manager_open = False
self.file_manager = MDFileManager(
exit_manager=self.exit_manager, select_path=self.select_path,
ext = ['.csv', ], selection = []
)
self.file_manager.show(os.path.expanduser("~")) # output manager to the screen
self.manager_open = True
else:
self.tk=self.root.get_screen("add_tank_screen").ids.new_tank.text = "Enter name of Tank"
pass

def exit_manager(self, *args):
'''Called when the user reaches the root of the directory tree.'''
Expand All @@ -644,19 +653,19 @@ def exit_manager(self, *args):

def select_path(self, path: str, ):
'''
It will be called when you click on the file name
It will be called when you click on the file nameF
or the catalog selection button.
:param path: path to the selected directory or file;
'''

self.selected_tank_import = path
self.exit_manager()
print(self.selected_tank_import)
print(self.root.get_screen("add_tank_screen").ids.new_tank.text)
tk=self.root.get_screen("add_tank_screen").ids.new_tank.text
# print(self.selected_tank_import)
# print(self.root.get_screen("add_tank_screen").ids.new_tank.text)
self.tk=self.root.get_screen("add_tank_screen").ids.new_tank.text
toast(path)
db_reading.import_data(self.selected_tank_import, self.vessel_for_import, tk)
db_reading.import_data(self.selected_tank_import, self.vessel_for_import, self.tk)

def choose_vessel_admin(self):
vessels_admin = []
Expand All @@ -682,7 +691,7 @@ def choose_vessel_admin(self):

for v in iter(vessels_admin):
self.the_DB_admin[v]=vessels_admin[0]
print(vessels_admin)
# print(vessels_admin)
menu_items= [(
{
"viewclass": "OneLineListItem",
Expand All @@ -704,12 +713,14 @@ def choose_vessel_admin(self):
print("Error on choose vessel")

def selected_vessel_import(self, vessel: str):
print(str(vessel).lower()+".db")
self.root.get_screen("add_tank_screen").ids.drop_vessels.text = vessel
self.menu_admin.dismiss()
self.vessel_for_import = (str(vessel).lower()+".db")
self.root.get_screen("add_tank_screen").ids.btn_add.disabled = False

self.root.get_screen("add_tank_screen").ids.new_tank.disabled = False

self.root.get_screen("add_tank_screen").ids.btn_add.disabled = False
self.tk=self.root.get_screen("add_tank_screen").ids.new_tank.text = str()


if __name__ == "__main__":
Expand Down
Binary file modified viking_sea.db
Binary file not shown.
Binary file modified viking_sea_prev.db
Binary file not shown.

0 comments on commit 6d0efd2

Please sign in to comment.