102 lines
3.2 KiB
Python
102 lines
3.2 KiB
Python
import tkinter as tk
|
|
from tkinter import font
|
|
from tkinter import ttk
|
|
from webpicdownloader.controller.Frames import Frames
|
|
from webpicdownloader.controller.InfoController import InfoController
|
|
from webpicdownloader.view.MainWindow import MainWindow
|
|
|
|
|
|
class InfoView(ttk.Frame):
|
|
"""
|
|
View - InfoWindow
|
|
|
|
This view displays information about the program, as well as its version and release date.
|
|
|
|
@author Jérémi Nihart / EndMove
|
|
@link https://git.endmove.eu/EndMove/WebPicDownloader
|
|
@version 1.0.0
|
|
@since 2022-09-06
|
|
"""
|
|
# Variables
|
|
__controller: InfoController = None
|
|
|
|
# Constructor
|
|
def __init__(self, parent: MainWindow, controller: InfoController):
|
|
"""
|
|
Constructor
|
|
|
|
* :parent: -> The main windows container.
|
|
* :controller: -> The view controller
|
|
"""
|
|
super().__init__(parent)
|
|
|
|
# Init view
|
|
self.__init_content()
|
|
|
|
# Save and setup controller
|
|
self.__controller = controller
|
|
controller.set_view(self)
|
|
|
|
# START Internal functions
|
|
def __init_content(self) -> None:
|
|
"""
|
|
[internal function]
|
|
=> Initialize the view content.
|
|
"""
|
|
self.columnconfigure(0, weight=4)
|
|
|
|
# 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)
|
|
|
|
# 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)
|
|
|
|
# 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
|
|
|
|
# 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
|