diff --git a/bunkercalc.kv b/bunkercalc.kv index 2c5aba0..fd06ea6 100644 --- a/bunkercalc.kv +++ b/bunkercalc.kv @@ -17,7 +17,7 @@ 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()]] @@ -25,9 +25,10 @@ ScreenManager: orientation : "horizontal" MDLabel: id: right_action - halign: "center" + halign: "right" theme_text_color: "Custom" text_color: "#4a4939" + MDLabel: id: select_vessel halign: "right" @@ -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" @@ -220,7 +222,7 @@ 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: @@ -228,9 +230,10 @@ ScreenManager: 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" @@ -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" @@ -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 @@ -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" @@ -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() @@ -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 diff --git a/db_reading.py b/db_reading.py index 837dcc2..b85cbdc 100644 --- a/db_reading.py +++ b/db_reading.py @@ -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,\ diff --git a/main.py b/main.py index aa3aa47..b97d1d5 100755 --- a/main.py +++ b/main.py @@ -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 @@ -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" @@ -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.''' @@ -644,7 +653,7 @@ 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; @@ -652,11 +661,11 @@ def select_path(self, path: str, ): 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 = [] @@ -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", @@ -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__": diff --git a/viking_sea.db b/viking_sea.db index 9534860..b89e8b9 100644 Binary files a/viking_sea.db and b/viking_sea.db differ diff --git a/viking_sea_prev.db b/viking_sea_prev.db index f51337f..9dd5a84 100644 Binary files a/viking_sea_prev.db and b/viking_sea_prev.db differ