Open program in the center of the window at launch

This commit is contained in:
Jérémi N ‘EndMove’ 2022-09-06 12:59:37 +02:00
parent f8f7832dd7
commit 25f10a8c50
Signed by: EndMove
GPG Key ID: 65C4A02E1F5371A4
7 changed files with 31 additions and 27 deletions

1
.gitignore vendored
View File

@ -13,6 +13,7 @@ __pycache__/
# Distribution / packaging
.Python
build/
output/
develop-eggs/
dist/
downloads/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -65,7 +65,7 @@ class MainController:
=> Event launched when a check for available updates is requested.
"""
# TODO write the function
print("on_check_for_update")
self.show_information_dialog(self.get_config('app_name'), "Oupss, this functionality isn't available yet!\nTry it again later.")
def on_about(self) -> None:
"""
@ -102,11 +102,22 @@ class MainController:
[function for controller]
=> Ask a question to the user and block until he answers with yes or no.
* :title: ->
* :message: ->
* :icon: ->
* :title: -> Title of the dialogue.
* :message: -> Message of the dialogue.
* :icon: -> Icon of the dialogue
"""
return self.__view.show_question_dialog(title, message, icon)
def show_information_dialog(self, title: str='title', message: str='informations!', icon: str='info') -> bool:
"""
[function for controller]
=> Display a pop-up information dialog to the user.
* :title: -> Title of the dialogue.
* :message: -> Message of the dialogue.
* :icon: -> Icon of the dialogue
"""
return self.__view.show_information_dialog(title, message, icon)
# END Controller methods
# START Controller events

10
main.py
View File

@ -33,15 +33,7 @@ def get_config() -> dict:
'sys_directory': get_sys_directory(),
'about_title': 'About WebPicDownloader',
'about_content':
"""This scraping software has been developed by EndMove
and is fully open-source. The source code is available
here: https://git.endmove.eu/EndMove/WebPicDownloader
EndMove is available at the following address for any
request contact@endmove.eu. In case of problemsplease
open an issue on the repository.
The logo of the software was made by Gashila"""
'about_content': "This scraping software has been developed by EndMove\nand is fully open-source. The source code is available\nhere: https://git.endmove.eu/EndMove/WebPicDownloader\nEndMove is available at the following address for any\nrequest contact@endmove.eu. In case of problemsplease\nopen an issue on the repository.\n\nThe logo of the software was made by Gashila"
}
if __name__ == '__main__':

View File

@ -45,9 +45,7 @@ class AsyncTask(threading.Thread):
[Internal function of (threading.Thread)]
[!] : This function must not be used! Start the task with {AsyncTask.start()} !
"""
print("runn")
self.__run_callback(*self.__run_args)
print("stopp")
def stop(self) -> None:
"""

View File

@ -8,14 +8,14 @@ from view.MainWindow import MainWindow
class InfoView(ttk.Frame):
"""
View - MainWindow
View - InfoWindow
dec...
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-08-30
@since 2022-09-06
"""
# Variables
__controller: InfoController = None

View File

@ -1,5 +1,3 @@
import os
import sys
import tkinter as tk
from tkinter import messagebox
from controller.Frames import Frames
@ -50,11 +48,13 @@ class MainWindow(tk.Tk):
[internal function]
=> Initialize window parameters
"""
# self.title('My tkinter app')
self.geometry('430x310')
self.resizable(False, False)
self.iconbitmap(f"{self.__controller.get_config('sys_directory')}\\assets\logo.ico")
# self.config(bg='#f7ef38')
self.iconbitmap(f"{self.__controller.get_config('sys_directory')}\\assets\logo.ico") # App logo
window_width = 430 # App width
window_height = 305 # App height
x_cordinate = int((self.winfo_screenwidth()/2) - (window_width/2))
y_cordinate = int((self.winfo_screenheight()/2) - (window_height/2))
self.geometry(f"{window_width}x{window_height}+{x_cordinate}+{y_cordinate}") # App size and middle centering
self.resizable(False, False) # Disable app resizing
def __init_top_menu(self) -> None:
"""
@ -63,12 +63,14 @@ class MainWindow(tk.Tk):
"""
main_menu = tk.Menu(self)
# Top menu File item
col1_menu = tk.Menu(main_menu, tearoff=0)
col1_menu.add_command(label="Open app folder", command=self.__controller.on_open_folder)
col1_menu.add_separator()
col1_menu.add_command(label="Quit", command=self.__controller.on_quite)
main_menu.add_cascade(label="File", menu=col1_menu)
# Top menu Help item
col2_menu = tk.Menu(main_menu, tearoff=0)
col2_menu.add_command(label="Check for update", command=self.__controller.on_check_for_update)
col2_menu.add_command(label="About", command=self.__controller.on_about)
@ -139,7 +141,7 @@ class MainWindow(tk.Tk):
"""
return True if (messagebox.askquestion(title, message, icon=icon) == "yes") else False
def show_information_dialog(self, title: str, message: str, icon: str='information') -> None:
def show_information_dialog(self, title: str, message: str, icon: str='info') -> None:
"""
[function for controller]
=> Display an information dialog to the user.
@ -148,5 +150,5 @@ class MainWindow(tk.Tk):
* :message: -> Message of the dialogue displayed to the user.
* :icon: -> Icon of the dialogue displayed to the user.
"""
messagebox.showinfo(self, title, message, icon=icon)
messagebox.showinfo(title, message, icon=icon)
# END Controller methods