2022-08-30 12:28:59 +02:00
|
|
|
from controller.MainController import MainController
|
|
|
|
|
|
|
|
|
|
|
|
class HomeController:
|
|
|
|
"""
|
2022-08-30 21:12:04 +02:00
|
|
|
Controller - HomeController
|
2022-08-30 12:28:59 +02:00
|
|
|
|
|
|
|
desc...
|
2022-08-30 21:12:04 +02:00
|
|
|
|
|
|
|
@author Jérémi Nihart / EndMove
|
|
|
|
@link https://git.endmove.eu/EndMove/WebPicDownloader
|
|
|
|
@version 1.0.0
|
|
|
|
@since 2022-08-30
|
2022-08-30 12:28:59 +02:00
|
|
|
"""
|
|
|
|
# Variables
|
2022-08-30 21:12:04 +02:00
|
|
|
__main_controller = None
|
|
|
|
__view = None
|
2022-08-31 21:05:20 +02:00
|
|
|
__webpic = None
|
2022-08-30 12:28:59 +02:00
|
|
|
|
|
|
|
# Constructor
|
2022-08-31 21:05:20 +02:00
|
|
|
def __init__(self, controller: MainController, webpic) -> None:
|
2022-08-30 21:12:04 +02:00
|
|
|
self.__main_controller = controller
|
2022-08-31 21:05:20 +02:00
|
|
|
self.__webpic = webpic
|
2022-08-30 12:28:59 +02:00
|
|
|
|
2022-08-30 21:12:04 +02:00
|
|
|
# START View methods
|
2022-08-30 12:28:59 +02:00
|
|
|
def set_view(self, view) -> None:
|
|
|
|
"""
|
|
|
|
[function for view]
|
|
|
|
|
|
|
|
:view: -> The view that this controller manage.
|
|
|
|
"""
|
2022-08-30 21:12:04 +02:00
|
|
|
self.__view = view
|
|
|
|
# END View method
|
|
|
|
|
|
|
|
# START View events
|
|
|
|
def on_change_view(self, frame) -> None:
|
|
|
|
"""
|
|
|
|
[event function for view]
|
|
|
|
|
|
|
|
:frame: -> The frame we want to launch.
|
|
|
|
"""
|
2022-08-31 12:07:43 +02:00
|
|
|
#self.__main_controller.change_frame(frame)
|
|
|
|
self.__view.add_log("Salut comment vas tu ? 1")
|
|
|
|
self.__view.add_log("Salut comment vas tu ? 2")
|
2022-08-31 21:05:20 +02:00
|
|
|
self.__view.show_success_message("Super tu as réussi la quête !")
|
|
|
|
|
|
|
|
def on_download_requested(self, url: str, name: str) -> None:
|
2022-08-30 21:12:04 +02:00
|
|
|
"""
|
|
|
|
[event function for view]
|
|
|
|
|
|
|
|
:url: -> The url of the website to use for pic-download.\n
|
|
|
|
:name: -> The name of the folder in which put pictures.
|
|
|
|
"""
|
2022-08-31 21:05:20 +02:00
|
|
|
if url.strip() and name.strip() :
|
|
|
|
# TODO use webpic here to download files
|
|
|
|
print(f"url : {url} -- name : {name}")
|
|
|
|
else:
|
|
|
|
self.__view.show_error_message("Opss, the url or folder name are not valid!")
|
2022-08-31 12:07:43 +02:00
|
|
|
# END View events
|