Skip to content

Commit

Permalink
Merge pull request #9 from Jaguar000212/refactor/v0.2.5
Browse files Browse the repository at this point in the history
refactor: changed file structure and docstrings
  • Loading branch information
Jaguar000212 authored Feb 24, 2024
2 parents e3dc199 + a5189e1 commit 206c7d8
Show file tree
Hide file tree
Showing 15 changed files with 297 additions and 101 deletions.
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
# Toodler
# <img src="https://github.com/Jaguar000212/Toodler/blob/main/toodler.ico?raw=true" width="25" /> Toodler

> The ultimate toolkit for every need!
Compilation of some of my tools which I made as a learner. This program allows you to acccess all of them of together with a single command, all centralized with a `launcher`.
I will be working on adding upo new tools and improving the existing ones as well.
Your feedback is much needed.

### ☑️ Currently available tools
1. <img src="https://github.com/Jaguar000212/Toodler/blob/main/tools/lyrically/Lyrically.ico?raw=true" width="15" /> **Lyrically** - Lyrics Generator, mage using `lyricsgenius`
1. <img src="https://github.com/Jaguar000212/Toodler/blob/main/tools/translator/Translator.ico?raw=true" width="15" /> **Translator** - Translation tool, made using `googletrans`

### ⏭️ Tools in lineup
- **Scientific Calculator**
- **Background Remover**

### 📃 Requirements
```
- Python - 3.x.x
- customtkinter - 5.2.1
- googletrans - 4.0.0rc1
- lyricsgenius - 3.0.1
- requests - 2.31.0
- tkinter - 0.1.0
```

### ⚙️ Installation
```sh
# Clone the repo
$ git clone https://github.com/Jaguar000212/Toodler.git

# Change the working directory to Toodler
$ cd Toodler

# Install the requirements
$ python3 -m pip install -r requirements.txt

# Run the launcher
$ python3 launcher.py
```
### 🧑🏻‍💻 Contribution
I would love to have you help me with the development of Toodler. 🚀
Each and every contribution is greatly valued!

Here are some things I would appreciate your help on:

- Addition of new Tools to the library.
- in Bug Hunting as well as their remedy.

New suggestions are also welcomed. You can simply open an issue if you have something to say!

---

⭐️ From [Jaguar000212](https://github.com/Jaguar000212)
50 changes: 40 additions & 10 deletions base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import customtkinter as ct
from tkinter import messagebox, Scrollbar, Listbox

import json


class BaseMain(ct.CTk):
"""
Represents the main window of the Toodler application.
Args:
tool_name (str): The name of the tool.
icon_path (str, optional): The path to the icon file. Defaults to None.
"""

def __init__(self, tool_name: str, icon_path: str = None):
"""
Initializes the BaseMain class.
Args:
tool_name (str): The name of the tool.
icon_path (str, optional): The path to the icon file. Defaults to None.
"""
super().__init__()

with open("configs.json", "r") as config_file:
Expand All @@ -16,7 +30,8 @@ def __init__(self, tool_name: str, icon_path: str = None):
self.attributes("-fullscreen", True)

self.wm_title(tool_name)
self.iconbitmap(icon_path)
if icon_path:
self.iconbitmap(icon_path)

self.messagebox = messagebox
self.scrollbar = Scrollbar
Expand All @@ -27,31 +42,42 @@ def __init__(self, tool_name: str, icon_path: str = None):
self.content_font = ct.CTkFont(family="Ariel", size=20)
self.subhead_font = ct.CTkFont(family="Ariel", size=40, weight="bold")

# Main content
# Title
ct.CTkLabel(self, text="Welcome to Toodler", font=self.head_font).pack()

# Tagline
ct.CTkLabel(
self, text="A perfect Toolkit for all your needs!", font=self.tagline_font
).pack(ipady=50)

# Tools frame
self.toolset = ct.CTkFrame(self)
self.toolset.pack()

ct.CTkLabel(
self.toolset, text="Select a tool to launch -", font=self.subhead_font
).grid(row=0, column=0, columnspan=2, sticky="n", padx=50, pady=10)

# Close Buttons
ct.CTkButton(
self, text="Close", font=self.content_font, command=self.destroy
).pack(pady=10, side="bottom")


class BaseSub(ct.CTkToplevel):
"""
Represents a sub-window of the Toodler application.
Args:
parent (ct.CTk): The parent window.
tool_name (str): The name of the tool.
icon_path (str, optional): The path to the icon file. Defaults to None.
"""

def __init__(self, parent: ct.CTk, tool_name: str, icon_path: str = None):
"""
Initializes the BaseSub class.
Args:
parent (ct.CTk): The parent window.
tool_name (str): The name of the tool.
icon_path (str, optional): The path to the icon file. Defaults to None.
"""
super().__init__()

with open("configs.json", "r") as config_file:
Expand All @@ -62,7 +88,8 @@ def __init__(self, parent: ct.CTk, tool_name: str, icon_path: str = None):
self.attributes("-fullscreen", True)

self.wm_title(tool_name)
self.iconbitmap(icon_path)
if icon_path:
self.iconbitmap(icon_path)

self.parent = parent

Expand All @@ -75,11 +102,14 @@ def __init__(self, parent: ct.CTk, tool_name: str, icon_path: str = None):
self.tagline_font = ct.CTkFont(family="RomanT", size=25)
self.content_font = ct.CTkFont(family="Ariel", size=20)

# Close Buttons
ct.CTkButton(
self, text="Close", font=self.content_font, command=self.close
).pack(pady=10, side="bottom")

def close(self):
"""
Closes the sub-window and enables the parent window.
"""
self.parent.attributes("-disabled", False)
self.destroy()
self.parent.attributes("-disabled", False)
1 change: 1 addition & 0 deletions exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from exceptions.exceptions import *
42 changes: 42 additions & 0 deletions exceptions/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from tkinter import messagebox


class InvalidLanguage(Exception):
"""
Exception raised when an invalid language is encountered.
Attributes:
type (str): The type of language that is invalid.
"""

def __init__(self, type: str, parent):
"""
Initializes a new instance of the InvalidLanguage class.
Args:
type (str): The type of language that is invalid.
parent: The parent widget for displaying the error message.
"""
self.message = f"Invalid {type} language."
messagebox.showerror("Error", self.message, parent=parent)
super().__init__(self.message)


class NoAPIKey(Exception):
"""
Exception raised when no API key is provided.
Attributes:
message (str): The error message.
"""

def __init__(self, message: str, parent):
"""
Initializes a new instance of the NoAPIKey class.
Args:
message (str): The error message.
parent: The parent widget for displaying the error message.
"""
messagebox.showerror("Error", message, parent=parent)
super().__init__(message)
15 changes: 10 additions & 5 deletions launcher.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import customtkinter as ct
from base import BaseMain

from lyrically import Lyrically
from translator import TextTranslator
from base import BaseMain
from tools import Lyrically, TextTranslator


# Commands
def launch_lyrically():
"""
Launches the Lyrically application.
Disables the 'toodler' attribute and initializes a Lyrically object.
"""
toodler.attributes("-disabled", True)
lyrically = Lyrically(toodler, toodler.configs["api_keys"]["lyricsGenius"])
lyrically.mainloop()


def launch_translator():
"""
Launches the translator application.
Disables the 'toodler' attribute and initializes a TextTranslator object.
"""
toodler.attributes("-disabled", True)
translator = TextTranslator(toodler)
translator.mainloop()


# Window setup
toodler = BaseMain("Toodler", "Toodler.ico")

ct.CTkButton(
Expand Down
1 change: 0 additions & 1 deletion lyrically/__init__.py

This file was deleted.

62 changes: 0 additions & 62 deletions lyrically/lyrically.py

This file was deleted.

5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
customtkinter==5.2.2
googletrans==4.0.0rc1
lyricsgenius==3.0.1
requests==2.31.0
tk==0.1.0
2 changes: 2 additions & 0 deletions tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from tools.translator.translator import TextTranslator
from tools.lyrically.lyrically import Lyrically
File renamed without changes.
Loading

0 comments on commit 206c7d8

Please sign in to comment.