get_icons.py 2.53 KB
Newer Older
Michael Rudolf's avatar
Michael Rudolf committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python3
# This file is part of rstevaluation.

# rstevaluation is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# rstevaluation is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with rstevaluation. If not, see <https://www.gnu.org/licenses/>.
Michael Rudolf's avatar
Michael Rudolf committed
16
17
18
19
20
21
22
23
""" Provides PhotoImage objects for all images """

import tkinter as tk
from importlib import resources


def icon_rst():
    """ Returns main application icon """
24
25
26
27
28
29
30
31
32
    try:
        with resources.path(
            'rstevaluation.icons', 'rst-evaluation.png'
        ) as fpath:
            phim = tk.PhotoImage(
                file=fpath
            )
    except TypeError as _:
        phim = tk.PhotoImage(file='rstevaluation\\icons\\rst-evaluation.png')
Michael Rudolf's avatar
Michael Rudolf committed
33
34
35
36
37
    return phim


def icon_load():
    """ Returns an icon for loading from a folder """
38
39
40
41
42
43
44
    try:
        with resources.path('rstevaluation.icons', 'home.png') as fpath:
            phim = tk.PhotoImage(
                file=fpath
            )
    except TypeError as _:
        phim = tk.PhotoImage(file='rstevaluation\\icons\\home.png')
Michael Rudolf's avatar
Michael Rudolf committed
45
46
47
48
49
    return phim


def icon_save():
    """ Returns an icon for saving to a folder """
50
51
52
53
54
55
56
    try:
        with resources.path('rstevaluation.icons', 'filesave.png') as fpath:
            phim = tk.PhotoImage(
                file=fpath
            )
    except TypeError as _:
        phim = tk.PhotoImage(file='rstevaluation\\icons\\filesave.png')
Michael Rudolf's avatar
Michael Rudolf committed
57
58
59
60
61
    return phim


def icon_options():
    """ Returns an icon for options """
62
63
64
65
66
67
68
    try:
        with resources.path('rstevaluation.icons', 'subplots.png') as fpath:
            phim = tk.PhotoImage(
                file=fpath
            )
    except TypeError as _:
        phim = tk.PhotoImage(file='rstevaluation\\icons\\subplots.png')
Michael Rudolf's avatar
Michael Rudolf committed
69
70
71
72
73
    return phim


def icon_start():
    """ Returns an icon for processing """
74
75
76
77
78
79
80
81
    try:
        with resources.path(
            'rstevaluation.icons', 'qt4_editor_options.png'
        ) as fpath:
            phim = tk.PhotoImage(
                file=fpath
            )
    except TypeError as _:
Michael Rudolf's avatar
Michael Rudolf committed
82
        phim = tk.PhotoImage(
83
            file='rstevaluation\\icons\\qt4_editor_options.png')
Michael Rudolf's avatar
Michael Rudolf committed
84
    return phim