-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
110 lines (85 loc) · 3.11 KB
/
data.py
File metadata and controls
110 lines (85 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Módulos
import customtkinter
from tkinter import *
import tkinter as tk
from PIL import Image, ImageTk
import pickle
import webbrowser
# Sistema de temas
def change_theme(value):
if value == 'Escuro':
# Configuração para o tema escuro
customtkinter.set_appearance_mode("dark")
elif value == 'Claro':
# Configuração para o tema claro
customtkinter.set_appearance_mode("light")
else:
# Configuração para o tema do sistema
customtkinter.set_appearance_mode("system")
# Sistema de cache das imagens
image_cache = {}
# Salvar o cache
def save_cache():
with open('image_cache.pickle', 'wb') as handle:
pickle.dump(image_cache, handle)
print('Cache salvo com sucesso!')
# Carregar o cache
def load_cache():
global image_cache
try:
with open('image_cache.pickle', 'rb') as handle:
global image_cache
image_cache = pickle.load(handle)
print("Cache carregado com sucesso!")
return image_cache
except FileNotFoundError:
open_error_window('Arquivo de cache não encontrado, reinicie o programa!')
image_cache = {}
save_cache()
except:
open_error_window('ERRO AO CARREGAR O CACHE!')
return {}
# Sistema da notificação interativa
notification_update = None
status = 'default'
# Abrir o Github
def url(event):
webbrowser.open_new('https://github.com/Dimitri-Matheus')
# Mudança do status da mensagem
def notification_change(label, status):
if status == 'default':
label.configure(text="Créditos: Dimitri")
label.unbind('<Button-1>')
status = 'theme' #Mudança da variável status 1
elif status == 'theme':
label.configure(text="Altere a aparência da sua pokedex!")
status = 'github' #Mudança da variável status 2
elif status == 'github':
label.configure(text="Se você gostou do meu projeto me siga no github :)")
status = 'link' #Mudança da variável status 3
elif status == 'link':
label.configure(text='GITHUB')
label.bind('<Button-1>', url)
status = 'default' #Mudança da variável status 1
return status
# Sistema de erro
def open_error_window(message):
# Janela de erro
window_2 = customtkinter.CTkToplevel()
window_2.title('')
window_2.resizable(width=False, height=False)
window_2.geometry("445x130")
# Carregando a imagem
image = customtkinter.CTkImage(Image.open('images/alert.png'), size=(48, 48))
# Adicionando a imagem ao programa
image_place = customtkinter.CTkLabel(master=window_2, image=image, text='')
image_place.pack(padx=10, pady=0.1)
# A mensagem do erro
msg_erro = customtkinter.CTkLabel(master=window_2, text=message, font=('Fixedsys', 10), text_color=('#E7B60C'))
msg_erro.pack(padx=10, pady=0.3)
# O botão para sair
exit = customtkinter.CTkButton(master=window_2, text='Sair', font=('Fixedsys', 10), text_color=('#feffff', '#333432'), fg_color='#E7B60C', command=window_2.destroy)
exit.pack(padx=10, pady=10)
window_2.mainloop()
# Tests
#open_error_window('Test!')