This repository has been archived on 2023-11-29. You can view files and clone it, but cannot push or open issues or pull requests.
WebPicDownloader/view/InfoView.py

102 lines
3.1 KiB
Python
Raw Normal View History

2022-08-30 21:12:04 +02:00
import tkinter as tk
from tkinter import font
2022-08-30 21:12:04 +02:00
from tkinter import ttk
from controller.Frames import Frames
from controller.InfoController import InfoController
from view.MainWindow import MainWindow
2022-08-30 21:12:04 +02:00
class InfoView(ttk.Frame):
"""
View - InfoWindow
2022-08-30 21:12:04 +02:00
This view displays information about the program, as well as its version and release date.
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-09-06
2022-08-30 21:12:04 +02:00
"""
# Variables
__controller: InfoController = None
# Constructor
def __init__(self, parent: MainWindow, controller: InfoController):
2022-09-04 17:38:45 +02:00
"""
Constructor
* :parent: -> The main windows container.
* :controller: -> The view controller
"""
2022-08-30 21:12:04 +02:00
super().__init__(parent)
# Init view
self.__init_content()
2022-08-30 21:12:04 +02:00
# Save and setup controller
self.__controller = controller
controller.set_view(self)
2022-08-30 21:12:04 +02:00
# START Internal functions
def __init_content(self) -> None:
"""
[internal function]
=> Initialize the view content.
"""
self.columnconfigure(0, weight=4)
2022-08-30 21:12:04 +02:00
# Back button
self.back_button = ttk.Button(self, text="Back", command=self.__event_button_back)
self.back_button.grid(row=0, column=0, sticky=tk.E, padx=5, pady=5, ipadx=1, ipady=1)
2022-08-30 21:12:04 +02:00
# About title
self.title_label_font = font.Font(self, size=16, weight=font.BOLD)
self.title_label = ttk.Label(self, text="A title", font=self.title_label_font)
self.title_label.grid(row=1, column=0, sticky=tk.NS, padx=2, pady=2)
2022-08-30 21:12:04 +02:00
# About content
self.content_label_font = font.Font(self, size=10)
self.content_label = ttk.Label(self, wraplength=400, justify='center', text='A long text', font=self.content_label_font, foreground='blue')
self.content_label.grid(row=2, column=0, sticky=tk.NS)
# About version
self.version_label = ttk.Label(self, text='version : 1.0.0 - 02-02-2022')
self.version_label.grid(row=3, column=0, sticky=tk.NS, pady=15)
def __event_button_back(self) -> None:
"""
[internal function]
=> Function called when back button pressed.
"""
self.__controller.on_change_view(Frames.HOME)
# END Internal functions
2022-08-30 21:12:04 +02:00
# START Controller methods
def set_title(self, title: str) -> None:
"""
[function for controller]
=> Define view/page info : title
* :title: -> Title for the view.
"""
self.title_label.configure(text=title)
def set_content(self, content: str) -> None:
"""
[function for controller]
=> Define view/page info : content
* :content: -> Content for the view.
"""
self.content_label.configure(text=content)
def set_version(self, version: str) -> None:
"""
[function for controller]
=> Define view/page info : version
* :version: -> Version for the view.
"""
self.version_label.configure(text=version)
# END Controller methods