diff --git a/INSTALLING.md b/INSTALLING.md index fedfe5f..36f4435 100644 --- a/INSTALLING.md +++ b/INSTALLING.md @@ -84,4 +84,70 @@ Get your development environment ready by installing Visual Studio Code for your * **macOS:** Follow the official macOS Setup Guide. * **Linux:** Follow the official Linux Setup Guide for .deb, .rpm, or Snap packages. -Contributed by @Ericwasepic127 \ No newline at end of file +Contributed by @Ericwasepic127 +### Method 2: Using the Direct Executable Installer +> ⚠️ **Note:** Standard `.exe` direct installers are deprecated starting from Python 3.15. For newer versions, please use Method 1. + +1. Navigate to the official [Python Downloads page](https://python.org/downloads/). +2. Select the latest release, or download the [recommended Python 3.13 version](https://www.python.org/downloads/release/python-313/). +3. Download the **Windows installer** executable (`.exe`). +4. Double-click the downloaded file to run the installer. +5. **Crucial:** Ensure you check the box that says **"Add Python to PATH"** before clicking install, then follow the remaining prompts. + +--- + +## macOS Installation + +1. **Download the Installer:** Visit the official [Python Downloads page](https://python.org/downloads/) and download the macOS installer package (`.pkg`). The [recommended version is 3.13](https://www.python.org/downloads/release/python-313/). +2. **Run the Installer:** Open the downloaded `.pkg` file and follow the on-screen installation steps. You will be prompted to enter your Mac's administrator password. +3. **Install Certificates:** + - Once complete, open your `Applications` folder and locate the newly created `Python 3.x` directory. + - Double-click the `Install Certificates.command` file. *This step is required to ensure Python can securely connect to the internet.* + +--- + +## Linux Installation (using pyenv) + +For Linux distributions, we recommend using `pyenv`, a robust Python environment manager that functions similarly to Windows' Install Manager. + +### 1. Install Dependencies +Open your terminal and run the appropriate command for your package manager to install the required build dependencies: + +* **Ubuntu / Debian / Mint:** + ```bash + sudo apt update + sudo apt install -y git make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev``` + + +* **Fedora / RHEL / CentOS:** + ```bash + sudo dnf groupinstall "Development Tools" + sudo dnf install git openssl-devel bzip2-devel libffi-devel readline-devel sqlite-devel xz-devel tk-devel``` + +* **Arch Linux:** + ```bash + sudo pacman -S --needed base-devel + sudo pacman -S git openssl zlib bzip2 readline sqlite3 libffi xz tk + ``` +### 2. Install and Configure pyenv + 1. Run the automatic installer script: + ```bash + curl [https://pyenv.run](https://pyenv.run) | bash + ``` +2. Follow the instructions printed in the terminal to add pyenv to your shell profile configurations (e.g., .bashrc or .zshrc). +3. Restart your terminal or source your profile to apply the changes. + +### 3. Install Python +Install your desired version using pyenv. We recommend version 3.13: +```bash +pyenv install 3.13 +pyenv global 3.13 +``` + +## Visual Studio Code Installation +Get your development environment ready by installing Visual Studio Code for your platform: + * **Windows:** Download via the Microsoft Store Link. + * **macOS:** Follow the official macOS Setup Guide. + * **Linux:** Follow the official Linux Setup Guide for .deb, .rpm, or Snap packages. + +Contributed by @Ericwasepic127 diff --git a/Intermediate/14_alarm.py b/Intermediate/14_alarm.py new file mode 100644 index 0000000..8c9d883 --- /dev/null +++ b/Intermediate/14_alarm.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +# Made by @Ericwasepic127 - with helpful comments + +import datetime # Imports module of datetime for gather current datetime +import time # Imports module of time for poll + +def get_hour_min(): + # Defines reusable function for getting hour & minute + current = datetime.datetime.now() # Gets datetime object with current date and time + hour = current.hour # Extract Hour + minute = current.minute # Extract Minute + second = current.second # Extract Seconds + now = (hour, minute, second) # Combine into tuple + return now # Give the tuple + +def get_int(prompt=""): + # Defines function to get integer from input + user = input(prompt) # Get input + if not user.isdigit(): # Detect is it only has digits (even dot isn't allowed) + print("Not a number") + return # Return nothing + return int(user) + +def get_hour(): + # Hour getting function - makes pretty reusable + hour_get = False # let's make variable for our while loop + while not hour_get: # Create while loop + hour = get_int("Enter hour to alarm: ") + if hour is None: # in case user didn't gave integer + print() + continue + if hour >= 24: + # Can't be above 24 hour + print("Exceeded hour!\n") + continue + elif hour < 0: + # Can't below 0 + print("Decreased hour!\n") + continue + else: + hour_get = True # Say I got the hour to our while loop! + return hour + +def get_min(): + # Minute getting function - makes pretty reusable + min_get = False # let's make variable for our while loop + while not min_get: # Create while loop + minute = get_int("Enter minute to alarm: ") + if minute is None: # in case user didn't gave integer + print() + continue + if minute >= 60: + # Can't be above 60 minute + print("Exceeded hour!\n") + continue + elif minute < 0: + # Can't below 0 + print("Decreased hour!\n") + continue + else: + min_get = True # Say I got the minute to our while loop! + return minute + +def get_alarm(): + # Reusable function to get tuple of alarm time! + alarm = ( + get_hour(), # Get hour using our function + get_min(), # Get minute too! + 0 # for second + ) + # Let's make confirmation system to avoid unwanted alarm time! + print(f"Set alarm to {alarm[0]}:{alarm[1]}!") + user_confirm = input("Is this correct (y/n)? ") + user_confirm = user_confirm.strip() # Clean any blank spaces + if user_confirm != "y" or not user_confirm.startswith("y"): # Not y + print("\nGetting again ...") + alarm = get_alarm() # Do recursive call + return alarm + +def time_left(alarm): + # Reusable function for time left calculation + now = get_hour_min() # Get current staticmethod + # Convert everything to seconds + now_sec = now[0]*3600 + now[1]*60 + now[2] + alarm_sec = alarm[0]*3600 + alarm[1]*60 + alarm[2] + diff = alarm_sec - now_sec # Calculate difference + if diff <= 0: # Negative + diff += 86400 # Next day + h = diff // 3600 # Hour + if h == 24: # As 24 Hour + h = 0 # go to 0 + m = (diff % 3600) // 60 # Minute + s = diff % 60 # Second + diff_tuple = (h, m, s) # Make into one tuple + return diff_tuple + +def main(): + # Main section + print("===Welcome to Alarm app!===") + print("Please set alarm!") + alarm = get_alarm() + print("Ctrl-C to stop alarm!\n") + while True: + # Make while loop but infinity + left = time_left(alarm) # Get left-time + left_hour = left[0] # Get Hour + left_min = left[1] # Get Minute + left_sec = left[2] # Get Seconds + if left_hour == 0 and left_min == 0 and left_sec == 0: + print("ALARM!!!!!!!!!!!!\007") # \007 is bell chapter + break + formatted_left = f"{left_hour:02d}:{left_min:02d}:{left_sec:02d}" # Format left-time + print(f"Left: {formatted_left}", end="\r") + time.sleep(1) # Sleep to rest CPU + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + print("Exitted! Goodbye") + diff --git a/Tkinter/1_hello_tk.py b/Tkinter/1_hello_tk.py new file mode 100644 index 0000000..60d152e --- /dev/null +++ b/Tkinter/1_hello_tk.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# Made by @Ericwasepic127 - With guided comments + +import tkinter as tk # Imports Tkinter module, shortcuts to tk + +root = tk.Tk() # Make window + +label = tk.Label( # Make Label widget + root, # Say to THIS window + text="Hello, World!" # Display THIS string given +) +label.pack() # Show the widget in window + +button = tk.Button( # Make Button widget + root, # Say to THIS window + text="Quit", # Display THIS string + command=root.destroy # Run THIS command on click +) +button.pack( # Show widget in window + fill=tk.BOTH # Fill Left and Right +) + +root.mainloop() # Run until window closes +# If you don't add root.mainloop(), the python program ends, causing window close immediately diff --git a/Tkinter/2_text_box.py b/Tkinter/2_text_box.py new file mode 100644 index 0000000..458f662 --- /dev/null +++ b/Tkinter/2_text_box.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# Made by @Ericwasepic127 - with Helpful comments + +import tkinter as tk # Imports Tkinter module shortcuting as tk + +root = tk.Tk() # Make window object + +button = tk.Button( # Make Button + root, # to this window + text="Disable" # Display this string +) +button.pack(fill=tk.BOTH) # Show button + +text = tk.Text( # Make text box + root # to this window +) +text.pack(fill=tk.BOTH) # Show text box + +def toggle(btn, txt): # Let's make function to toggle + # To avoid any local and global thing mess up, + # let's make a wrapper-like function + def func(): + if btn["text"] == "Disable": # Get text from button, and if it's Disable + # Instead using dict-like setting, you can use .config method + # I prefer dict-like setting + # You can see usage below + btn["text"] = "Enable" + txt["state"] = "disabled" + else: # in case disabled + btn["text"] = "Disable" + txt["state"] = "normal" # means editable + return func + +# instead dict-like setting +button.config(command=toggle(button, text)) + +root.mainloop()