-
Notifications
You must be signed in to change notification settings - Fork 3
python editor #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
f0rdprefect
wants to merge
3
commits into
Brixel:main
Choose a base branch
from
f0rdprefect:ft-python-editor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,2 @@ | ||
| .pyc | ||
| __pycache__ |
This file contains hidden or 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,158 @@ | ||
| # Hacker Jeopardy Editor | ||
|
|
||
| A simple GUI editor for creating and editing Hacker Jeopardy quiz files. This replaces the clunky Unity editor with a user-friendly Python/Tkinter interface. | ||
|
|
||
| ## Features | ||
|
|
||
| ### Core Functionality | ||
| - **Load/Save JSON files** - Open existing quiz files or create new ones | ||
| - **Category Management** - Add, edit, and delete quiz categories with custom colors | ||
| - **Question Management** - Add, edit, and delete questions within categories | ||
| - **Simple Form UI** - Easy-to-use text fields and controls for all properties | ||
| - **Basic Validation** - Ensures required fields are filled and values are valid | ||
|
|
||
| ### Advanced Features | ||
| - **Color Picker** - Visual color selection for categories and questions | ||
| - **Media File Browser** - Easy selection of question and answer media files | ||
| - **Question Type Support** - Text, image, audio, and video question types | ||
| - **Real-time Updates** - Changes are reflected immediately in the interface | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Python 3.8 or higher | ||
| - Tkinter (included with Python) | ||
| - No additional dependencies required! | ||
|
|
||
| ## Installation | ||
|
|
||
| 1. Clone or download the project files | ||
| 2. Ensure Python 3.8+ is installed | ||
| 3. Run the editor: | ||
|
|
||
| ```bash | ||
| cd hackerjeopardy_editor | ||
| python3 main.py | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Getting Started | ||
|
|
||
| 1. **Create a New Quiz**: Use File → New to start with a blank quiz | ||
| 2. **Load Sample Data**: Use File → Open and select `example_quiz.json` to see a working example | ||
| 3. **Edit Quiz Info**: Update the game name and tagline at the top of the window | ||
|
|
||
| ### Working with Categories | ||
|
|
||
| 1. **Add Category**: Click "Add Category" in the Categories pane | ||
| 2. **Edit Category**: Select a category from the list, then use the Category tab in the Editor pane | ||
| 3. **Change Color**: Click "Choose Color" to pick a custom category color | ||
| 4. **Delete Category**: Select a category and click "Delete Category" | ||
|
|
||
| ### Working with Questions | ||
|
|
||
| 1. **Add Question**: Select a category, then click "Add Question" in the Questions pane | ||
| 2. **Edit Question**: Select a question from the list, then use the Question tab in the Editor pane | ||
| 3. **Set Properties**: Fill in value, type, question text, answer, and optional note | ||
| 4. **Add Media**: Use the Browse buttons to select question or answer media files | ||
| 5. **Change Color**: Click "Choose Color" to pick a custom question color | ||
| 6. **Delete Question**: Select a question and click "Delete Question" | ||
|
|
||
| ### File Operations | ||
|
|
||
| - **New**: File → New (creates blank quiz) | ||
| - **Open**: File → Open (loads existing JSON or .jeopardy file) | ||
| - **Save**: File → Save (saves to current file) | ||
| - **Save As**: File → Save As (saves to new file) | ||
| - **Export as .jeopardy**: File → Export as .jeopardy (exports Unity-compatible format) | ||
|
|
||
| ## File Formats | ||
|
|
||
| ### JSON Format (.json) | ||
|
|
||
| The editor's native format creates JSON files compatible with the Hacker Jeopardy Unity game. The format includes: | ||
|
|
||
| ```json | ||
| { | ||
| "gameName": "Quiz Title", | ||
| "tagline": "Quiz Description", | ||
| "categories": [ | ||
| { | ||
| "name": "Category Name", | ||
| "color": {"r": 1.0, "g": 0.0, "b": 0.0, "a": 1.0}, | ||
| "hint": "Category hint text", | ||
| "questions": [ | ||
| { | ||
| "value": 100, | ||
| "type": "text", | ||
| "question": "Question text", | ||
| "answer": "Answer text", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Optional note", | ||
| "questionColor": {"r": 0.8, "g": 0.2, "b": 0.2, "a": 1.0} | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### Unity .jeopardy Format (.jeopardy) | ||
|
|
||
| The editor also supports Unity's native .jeopardy format for seamless integration with the Unity game. This format uses a 3-line structure: | ||
|
|
||
| ``` | ||
| Game Name | ||
| Tagline | ||
| [{"categoryName":"Category","categoryColorR":255,"categoryColorG":0,"categoryColorB":0,"categoryHint":"Hint","questions":[...]}] | ||
| ``` | ||
|
|
||
| **Key differences from JSON format:** | ||
| - Line 1: Game name (plain text) | ||
| - Line 2: Tagline (plain text) | ||
| - Line 3+: JSON array of categories with Unity-specific field names | ||
| - Colors are RGB integers (0-255) instead of floats (0-1) | ||
| - Field names use Unity conventions (`categoryName` vs `name`, etc.) | ||
|
|
||
| **Workflow Support:** | ||
| - **Import**: Open .jeopardy files created in Unity for editing | ||
| - **Export**: Save editor projects as .jeopardy files for Unity | ||
| - **Round-trip**: Full data integrity between editor and Unity formats | ||
|
|
||
| ## Tips | ||
|
|
||
| - **Save Frequently**: Use Ctrl+S or File → Save to avoid losing work | ||
| - **Use the Sample**: Load `example_quiz.json` to see how a complete quiz is structured | ||
| - **Color Coding**: Use different colors for categories and questions to make them visually distinct | ||
| - **Media Paths**: Media file paths can be relative or absolute | ||
| - **Question Values**: Typically use 100, 200, 300, 400, 500 for Jeopardy-style scoring | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Common Issues | ||
|
|
||
| 1. **Application won't start**: Ensure Python 3.8+ is installed and Tkinter is available | ||
| 2. **Can't load file**: Check that the JSON file is valid and follows the expected format | ||
| 3. **Colors not showing**: Make sure color values are between 0.0 and 1.0 | ||
| 4. **Media files not found**: Use absolute paths or ensure relative paths are correct | ||
|
|
||
| ### Error Messages | ||
|
|
||
| - **"Question text is required"**: Fill in the question field before saving | ||
| - **"Answer text is required"**: Fill in the answer field before saving | ||
| - **"Question value must be positive"**: Enter a number greater than 0 for the question value | ||
|
|
||
| ## Development | ||
|
|
||
| The editor consists of three main files: | ||
|
|
||
| - `models.py`: Data classes for Quiz, Category, Question, and Color | ||
| - `main.py`: Main GUI application with Tkinter interface | ||
| - `example_quiz.json`: Sample quiz data for testing | ||
|
|
||
| The code is designed to be simple and maintainable, focusing on core functionality over advanced features. | ||
|
|
||
| ## License | ||
|
|
||
| This project is part of the Hacker Jeopardy game system. Use and modify as needed for your quiz creation needs. | ||
This file contains hidden or 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,114 @@ | ||
| { | ||
| "gameName": "Security Fundamentals", | ||
| "tagline": "Test your cybersecurity knowledge", | ||
| "categories": [ | ||
| { | ||
| "name": "Passwords", | ||
| "color": {"r": 1.0, "g": 0.0, "b": 0.0, "a": 1.0}, | ||
| "questions": [ | ||
| { | ||
| "value": 100, | ||
| "type": "text", | ||
| "question": "What is the recommended minimum password length?", | ||
| "answer": "12 characters", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Some sources say 8, but 12 is better practice", | ||
| "questionColor": {"r": 0.8, "g": 0.2, "b": 0.2, "a": 1.0} | ||
| }, | ||
| { | ||
| "value": 200, | ||
| "type": "text", | ||
| "question": "What type of attack tries many password combinations automatically?", | ||
| "answer": "Brute force attack", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Dictionary attacks are a subset of brute force", | ||
| "questionColor": {"r": 0.8, "g": 0.2, "b": 0.2, "a": 1.0} | ||
| }, | ||
| { | ||
| "value": 300, | ||
| "type": "text", | ||
| "question": "What authentication method uses something you know, have, and are?", | ||
| "answer": "Multi-factor authentication (MFA)", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Also called 2FA when using two factors", | ||
| "questionColor": {"r": 0.8, "g": 0.2, "b": 0.2, "a": 1.0} | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "Network Security", | ||
| "color": {"r": 0.0, "g": 0.8, "b": 0.0, "a": 1.0}, | ||
| "questions": [ | ||
| { | ||
| "value": 100, | ||
| "type": "text", | ||
| "question": "What port does HTTPS typically use?", | ||
| "answer": "443", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "HTTP uses port 80, HTTPS uses 443", | ||
| "questionColor": {"r": 0.2, "g": 0.6, "b": 0.2, "a": 1.0} | ||
| }, | ||
| { | ||
| "value": 200, | ||
| "type": "text", | ||
| "question": "What does VPN stand for?", | ||
| "answer": "Virtual Private Network", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Creates encrypted tunnel over public networks", | ||
| "questionColor": {"r": 0.2, "g": 0.6, "b": 0.2, "a": 1.0} | ||
| }, | ||
| { | ||
| "value": 300, | ||
| "type": "text", | ||
| "question": "What type of attack intercepts communications between two parties?", | ||
| "answer": "Man-in-the-middle attack", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Also abbreviated as MITM attack", | ||
| "questionColor": {"r": 0.2, "g": 0.6, "b": 0.2, "a": 1.0} | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "Malware", | ||
| "color": {"r": 0.5, "g": 0.0, "b": 0.8, "a": 1.0}, | ||
| "questions": [ | ||
| { | ||
| "value": 100, | ||
| "type": "text", | ||
| "question": "What type of malware encrypts files and demands payment?", | ||
| "answer": "Ransomware", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Famous examples: WannaCry, CryptoLocker", | ||
| "questionColor": {"r": 0.4, "g": 0.1, "b": 0.6, "a": 1.0} | ||
| }, | ||
| { | ||
| "value": 200, | ||
| "type": "text", | ||
| "question": "What malware appears legitimate but contains malicious code?", | ||
| "answer": "Trojan horse", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Named after the Greek mythology story", | ||
| "questionColor": {"r": 0.4, "g": 0.1, "b": 0.6, "a": 1.0} | ||
| }, | ||
| { | ||
| "value": 300, | ||
| "type": "text", | ||
| "question": "What type of malware spreads automatically across networks?", | ||
| "answer": "Worm", | ||
| "questionMediaPath": null, | ||
| "answerMediaPath": null, | ||
| "note": "Unlike viruses, worms don't need host files", | ||
| "questionColor": {"r": 0.4, "g": 0.1, "b": 0.6, "a": 1.0} | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that tkinter is NOT installed by default in the majority of Linux distro's. For Windows, it's required to install tkinter when installing Python (this is a checkbox in the installer). See error message below (this is on Linux Mint 22.2 Zara)
Suggestion: Amend installation instruction in README.md to include tkinter installation