Passed
Push — dev ( b084e9...585a6c )
by Andreas
54s
created

w_about   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 44
dl 0
loc 57
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A goto_url() 0 3 1
B popup_about() 0 46 2
1
"""Окно с описанием."""
2
import webbrowser
3
from tkinter import Toplevel, PhotoImage, Label
4
5
6
def goto_url(url):
7
    """Переходит по предоставленной ссылке."""
8
    webbrowser.open_new(url)
9
10
11
def popup_about(window, vers: str) -> None:
12
    """Открывает окно 'О программе'."""
13
# Центровка окна
14
    main_width = 350
15
    main_height = 150
16
    center_x_pos = int(window.winfo_screenwidth() / 2) - main_width
17
    center_y_pos = int(window.winfo_screenheight() / 2) - main_height
18
19
    popup = Toplevel()
20
    popup.geometry(f'{main_width}x{main_height}+{center_x_pos}+{center_y_pos}')
21
    popup.title(_('About'))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable _ does not seem to be defined.
Loading history...
22
    imagepath = 'data/imgs/main.png'
23
    img = PhotoImage(file = imagepath)
24
    poplabel1 = Label(popup, image = img)
25
    poplabel1.grid(sticky = 'W', column = 0, row = 0, rowspan = 3)
26
27
    progname = 'Car Music Sorter'
28
    name_vers_str = _('Version: ') + vers
29
    prog_author = _('\nAuthor: ') + 'Intervision'
30
    author_github = 'https://github.com/intervisionlord'
31
    poplabel_progname = Label(popup,
32
                              text = progname,
33
                              justify = 'left')
34
    poplabel_progname.config(font = ('16'))
35
    poplabel_progname.grid(column = 1, row = 0)
36
    poplabel_maindesc = Label(popup,
37
                              text = name_vers_str + prog_author,
38
                              justify = 'left')
39
    poplabel_maindesc.grid(sticky = 'W', column = 1, row = 1)
40
41
    poplabel_giturl = Label(popup,
42
                            text = author_github,
43
                            justify = 'left',
44
                            fg = 'blue',
45
                            cursor = 'hand2')
46
    poplabel_giturl.bind('<Button-1>',
47
                         lambda u: goto_url(author_github))
48
    poplabel_giturl.grid(sticky = 'W', column = 1, row = 2)
49
# Автор иконок
50
    icons_author = _('Icons: ') + 'icon king1 ' + _('on') + ' freeicons.io'
51
    poplabel_icons = Label(popup, text = icons_author, justify = 'left')
52
    poplabel_icons.grid(sticky = 'W', column = 1, row = 3)
53
54
    popup.grab_set()
55
    popup.focus_set()
56
    popup.wait_window()
57