-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
418 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
name = "Adi1090x" | ||
background = "#131b20" | ||
text = "#283039" | ||
accent = "#a8bf3e" | ||
accent = "#a8bf3e" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
name = "Cherry" | ||
background = "#ffdcdc" | ||
text = "#fda8ac" | ||
accent = "#ef5e81" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
name = "Midnight Abyss" | ||
background = "#000000" | ||
text = "#272c38bd" | ||
accent = "#30b962" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ pillow==9.3.0 | |
inquirer==3.1.3 | ||
toml==0.10.2 | ||
importlib==1.0.4 | ||
textual==0.38.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* Wtf ????? Terminal CSS ??? >:0 */ | ||
|
||
Wizard { | ||
padding: 1 4; | ||
width: auto; | ||
margin: 0 2; | ||
border: solid $primary-background-lighten-3; | ||
} | ||
|
||
BackNextButtons { | ||
margin-top: 1; | ||
layout: horizontal; | ||
width: auto; | ||
} | ||
|
||
Screen { | ||
align: center middle; | ||
} | ||
|
||
.full-width { | ||
width: 100%; | ||
} | ||
|
||
Input, Select { | ||
border: round skyblue; | ||
background: transparent; | ||
} | ||
|
||
.invalid { | ||
border: round tomato; | ||
} | ||
|
||
.hidden { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,88 @@ | ||
import inquirer as inq | ||
from importlib import import_module | ||
import os | ||
from time import time | ||
from utils import * | ||
|
||
# Look for DEBUG in the environment variables | ||
DEBUG = os.environ.get("DEBUG", "false").lower() == "true" | ||
from textual.app import App | ||
from textual.widgets import Header, Footer, Label, LoadingIndicator | ||
from textual.validation import Length | ||
from textual import log | ||
from textual.events import Key | ||
|
||
def main(): | ||
VERSION = "1.0.0" | ||
|
||
from wizard import * | ||
|
||
# Load the styles in the styles directory | ||
styles = dict() | ||
for style in os.listdir(os.path.join(BASE_DIR, "src", "styles")): | ||
# Only keep .py files | ||
if not style.endswith(".py"): | ||
continue | ||
|
||
# Try to import the script | ||
# If it fails, ignore it | ||
if DEBUG: | ||
module = import_module(f"styles.{remove_ext(style)}") | ||
else: | ||
try: | ||
module = import_module(f"styles.{remove_ext(style)}") | ||
except: | ||
print(f"Error while importing {style}, ignoring...") | ||
continue | ||
|
||
# Only keep files with the active attribute set to True | ||
# This allows to ignore some scripts that may be in the styles directory | ||
if not module.active: | ||
continue | ||
|
||
styles[module.name] = module | ||
|
||
questions = [ | ||
inq.Text("name", message="Project's name"), | ||
inq.List("style", message="Select a style", choices=list(styles.keys())) | ||
class OctoLogoApp(App): | ||
BINDINGS = [ | ||
("ctrl+q", "quit", "Quit"), | ||
("ctrl+t", "toggle_dark", "Toggle Dark Mode") | ||
] | ||
answers = dict() | ||
|
||
CSS_PATH = os.path.join(BASE_DIR, "src", "app.tcss") | ||
TITLE = "Octo Logo Wizard" | ||
finished: bool = False | ||
save_to: str | None = None | ||
result: Image.Image | None = None | ||
loading_wid: LoadingIndicator = LoadingIndicator(classes="hidden") | ||
|
||
async def on_key(self, event: Key): | ||
if event.key == "enter" and self.finished: | ||
await self.action_quit() | ||
elif event.key == "v" and self.finished: | ||
self.result.show() | ||
|
||
|
||
answers = inq.prompt(questions) | ||
def on_wizard_finished(self, message: Wizard.Finished): | ||
# Get the wizard answers and the wizard's id | ||
self.answers.update(message.answers) | ||
finished_wizard_id = message.wizard_id | ||
|
||
# Force the user to enter a name | ||
if not len(answers["name"]) > 0: | ||
print("Error : You must enter a name") | ||
quit() | ||
# remove the wizard | ||
self.query_one(f"#{finished_wizard_id}").remove() | ||
|
||
selected_style = styles[answers["style"]] | ||
# When the basic info wizard is finished, mount the style-specific wizard | ||
if finished_wizard_id == "basic_info_wizard": | ||
style_wizard = Wizard(id="style_wizard") | ||
style_wizard.questions = styles[self.answers['style']].module.questions | ||
style_wizard.title = "Style Settings" | ||
self.mount(style_wizard) | ||
# When the style-specific wizard is finished, create the image and save it | ||
elif finished_wizard_id == "style_wizard": | ||
style = styles[self.answers['style']].module | ||
self.result = style.get_image(self.answers) | ||
self.save_to = f'output/{self.answers["name"]}_{int(time())}.png' | ||
self.loading_wid.remove_class("hidden") | ||
self.set_timer(2, self.final_message) | ||
|
||
image = selected_style.get_image(answers["name"]) | ||
# Final message | ||
def final_message(self): | ||
self.loading_wid.add_class("hidden") | ||
self.mount(Label(f"Logo saved to [bold]{self.save_to}[/bold].\n[blue blink]-> Press v to view the result[/blue blink]\n[red]Press enter to quit[/red]")) | ||
self.result.save(self.save_to) | ||
self.finished = True | ||
|
||
|
||
def compose(self): | ||
self.app.title = f"Octo Logo v{VERSION}" | ||
|
||
yield Header(show_clock=True) | ||
yield Footer() | ||
|
||
basic_info_wizard = Wizard(id="basic_info_wizard") | ||
basic_info_wizard.questions = [ | ||
TextQuestion("name", "Your project's name", [Length(1, failure_description="Your project's name cannot be blank")], "super-octo-project" ), | ||
SelectQuestion("style", "Logo Style", style_names, "first_letter_underlined") | ||
] | ||
basic_info_wizard.title = "Basic Information" | ||
yield basic_info_wizard | ||
yield self.loading_wid | ||
|
||
def main(): | ||
|
||
# Save result or show if debug is enabled | ||
save_to = f'output/{answers["name"]}_{int(time())}.png' | ||
image.show() if DEBUG else image.save(save_to) | ||
print(f"Logo saved to {save_to}") | ||
app = OctoLogoApp() | ||
app.run() | ||
quit(0) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from . import underline_core | ||
|
||
name = "All text underlined" | ||
display_name = "All text underlined" | ||
active = True | ||
questions = underline_core.questions | ||
|
||
def get_image(name): | ||
return underline_core.get_image(name, "all") | ||
def get_image(answers): | ||
return underline_core.get_image(answers, "all") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from . import underline_core | ||
|
||
name = "First letter underlined" | ||
display_name = "First letter underlined" | ||
active = True | ||
questions = underline_core.questions | ||
|
||
def get_image(name): | ||
return underline_core.get_image(name, "first_letter") | ||
def get_image(answers): | ||
return underline_core.get_image(answers, "first_letter") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.