Счетчик-хуетчик
МегаМаркет говно, Валя лохunknown
python
4 months ago
4.8 kB
4
Indexable
import tkinter as tk class TranslationApp: def __init__(self, root): self.root = root self.root.title("Translation Tracker") self.non_translations_count = 0 self.translations_count = 0 self.saved_requests = [] # Левая часть self.non_translations_frame = tk.Frame(root) self.non_translations_frame.pack(side=tk.LEFT, padx=10) self.non_translations_label = tk.Label(self.non_translations_frame, text=f"Не переводы [{self.non_translations_count}]") self.non_translations_label.grid(row=0, column=0, columnspan=2) self.increment_non_translations_btn = tk.Button(self.non_translations_frame, text="+", command=self.increment_non_translations, width=5) self.increment_non_translations_btn.grid(row=1, column=0, padx=2, pady=2) self.decrement_non_translations_btn = tk.Button(self.non_translations_frame, text="-", command=self.decrement_non_translations, width=5) self.decrement_non_translations_btn.grid(row=1, column=1, padx=2, pady=2) # Правая часть self.translations_frame = tk.Frame(root) self.translations_frame.pack(side=tk.RIGHT, padx=10) self.translations_label = tk.Label(self.translations_frame, text=f"Переводы - [{self.translations_count}]") self.translations_label.grid(row=0, column=0, columnspan=2) self.increment_translations_btn = tk.Button(self.translations_frame, text="+", command=self.increment_translations, width=5) self.increment_translations_btn.grid(row=1, column=0, padx=2, pady=2) self.decrement_translations_btn = tk.Button(self.translations_frame, text="-", command=self.decrement_translations, width=5) self.decrement_translations_btn.grid(row=1, column=1, padx=2, pady=2) # Центр self.percentage_label = tk.Label(root, text="Процент переводов - 0% (Сумма: 0)") self.percentage_label.pack(side=tk.TOP, pady=20) # Кнопка для открытия нового окна self.open_requests_btn = tk.Button(root, text="Сохраненные запросы", command=self.open_requests_window) self.open_requests_btn.pack(side=tk.BOTTOM, pady=10) self.update_percentage() def increment_non_translations(self): self.non_translations_count += 1 self.update_counts() def decrement_non_translations(self): if self.non_translations_count > 0: self.non_translations_count -= 1 self.update_counts() def increment_translations(self): self.translations_count += 1 self.update_counts() def decrement_translations(self): if self.translations_count > 0: self.translations_count -= 1 self.update_counts() def update_counts(self): self.non_translations_label.config(text=f"Не переводы [{self.non_translations_count}]") self.translations_label.config(text=f"Переводы - [{self.translations_count}]") self.update_percentage() def update_percentage(self): total = self.translations_count + self.non_translations_count if total > 0: percentage = (self.translations_count / total) * 100 else: percentage = 0 self.percentage_label.config(text=f"Процент переводов - {percentage:.2f}% (Сумма: {total})") def open_requests_window(self): requests_window = tk.Toplevel(self.root) requests_window.title("Сохраненные запросы") self.request_entry = tk.Entry(requests_window, width=40) self.request_entry.pack(pady=5) label = tk.Label(requests_window, text="Не забудь задать эти вопросы наставнику") label.pack(pady=5) save_request_btn = tk.Button(requests_window, text="Сохранить запрос", command=self.save_request) save_request_btn.pack(pady=5) self.requests_listbox = tk.Listbox(requests_window, width=40, height=10) self.requests_listbox.pack(pady=5) self.update_requests_list() def save_request(self): request = self.request_entry.get() if request: self.saved_requests.append(request) self.request_entry.delete(0, tk.END) self.update_requests_list() def update_requests_list(self): self.requests_listbox.delete(0, tk.END) for request in self.saved_requests: self.requests_listbox.insert(tk.END, request) if __name__ == "__main__": root = tk.Tk() app = TranslationApp(root) root.mainloop()
Editor is loading...
Leave a Comment