{"id":19460000,"url":"https://github.com/hamed-gharghi/basic-calculator","last_synced_at":"2026-04-29T10:03:10.105Z","repository":{"id":250929829,"uuid":"835853389","full_name":"Hamed-Gharghi/Basic-Calculator","owner":"Hamed-Gharghi","description":"Basic Calculator using PyQt5 with EXE and Python file","archived":false,"fork":false,"pushed_at":"2024-07-31T04:08:30.000Z","size":36153,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T23:01:52.630Z","etag":null,"topics":["basic-calculator","basic-calculator-app","calculator-python","dark-theme","gui","gui-application","pyqt5","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hamed-Gharghi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-30T16:55:58.000Z","updated_at":"2024-07-31T04:41:14.000Z","dependencies_parsed_at":"2024-11-10T17:49:16.611Z","dependency_job_id":null,"html_url":"https://github.com/Hamed-Gharghi/Basic-Calculator","commit_stats":null,"previous_names":["hamed-gharghi/basic-calculator"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Hamed-Gharghi/Basic-Calculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hamed-Gharghi%2FBasic-Calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hamed-Gharghi%2FBasic-Calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hamed-Gharghi%2FBasic-Calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hamed-Gharghi%2FBasic-Calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hamed-Gharghi","download_url":"https://codeload.github.com/Hamed-Gharghi/Basic-Calculator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hamed-Gharghi%2FBasic-Calculator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32420356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["basic-calculator","basic-calculator-app","calculator-python","dark-theme","gui","gui-application","pyqt5","python"],"created_at":"2024-11-10T17:35:10.023Z","updated_at":"2026-04-29T10:03:10.088Z","avatar_url":"https://github.com/Hamed-Gharghi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Basic Calculator Application\n\n![Python](https://img.shields.io/badge/Python-3.8%2B-blue)\n![PyQt5](https://img.shields.io/badge/PyQt5-5.15.4-green)\n![License](https://img.shields.io/badge/License-MIT-yellow)\n\n## Description\n\nThis is a basic calculator application built using PyQt5. It includes functionality for basic arithmetic operations and can be operated using both on-screen buttons and keyboard input. This project demonstrates a simple GUI application with event handling in Python. The UI now supports a dark theme for a modern look and reduced eye strain. An application icon is also included.\n\n## Features\n\n- Basic arithmetic operations: addition, subtraction, multiplication, and division.\n- Clear and backspace functionalities.\n- Keyboard input for calculator operations.\n- User-friendly graphical interface with dark theme.\n- Application icon for a polished look.\n\n## Installation\n\n1. Clone the repository:\n   ```sh\n   git clone https://github.com/your-username/Basic-Calculator.git\n   ```\n2. Change to the project directory:\n   ```sh\n   cd Basic-Calculator\n   ```\n3. Install the required packages:\n   ```sh\n   pip install PyQt5\n   ```\n\n## Usage\n\n1. Run the Python script:\n   ```sh\n   python Basic-Calculator.py\n   ```\n\n2. Use the on-screen buttons or the keyboard to perform calculations.\n\n### Keyboard Shortcuts\n\n- `0-9`: Enter numbers\n- `+`: Addition\n- `-`: Subtraction\n- `*`: Multiplication\n- `/`: Division\n- `(`: Open parenthesis\n- `)`: Close parenthesis\n- `.`: Decimal point\n- `Enter`: Calculate result\n- `Backspace`: Remove last character\n- `ESC`: Clear input\n\n## How It Works\n\n### Code Explanation\n\nThe `Basic-Calculator.py` script is the main Python file for this application. It uses the PyQt5 library to create the GUI. Here is a brief explanation of the code:\n\n1. **Importing Libraries**: The code starts by importing the necessary modules from PyQt5.\n\n    ```python\n    from PyQt5 import QtCore, QtGui, QtWidgets\n    ```\n\n2. **UI Setup**: The `Ui_Form` class contains the setup for the UI. It defines all the buttons and the input field, and now includes a dark theme and an application icon.\n\n    ```python\n    class Ui_Form(object):\n        def setupUi(self, Form):\n            Form.setObjectName(\"Form\")\n            Form.resize(400, 300)\n            self.setWindowIcon(QtGui.QIcon('icon.png'))  # Set application icon\n            self.setStyleSheet(\"background-color: #2e2e2e; color: #f0f0f0;\")  # Dark theme\n\n            self.lineEdit = QtWidgets.QLineEdit(Form)\n            self.lineEdit.setGeometry(QtCore.QRect(10, 10, 381, 41))\n            self.lineEdit.setObjectName(\"lineEdit\")\n            self.lineEdit.setStyleSheet(\"background-color: #1e1e1e; color: #ffffff;\")\n            ...\n    ```\n\n3. **Button Initialization**: Each button is initialized with a specific geometry and text label, and styled for the dark theme.\n\n    ```python\n    self.pushButton = QtWidgets.QPushButton(Form, text=\"7\")\n    self.pushButton.setGeometry(QtCore.QRect(10, 60, 61, 51))\n    self.pushButton.setStyleSheet(\"background-color: #3e3e3e; color: #ffffff;\")\n    ```\n\n4. **Connecting Buttons to Methods**: Each button is connected to a method that handles its functionality.\n\n    ```python\n    self.pushButton.clicked.connect(lambda: self.button_clicked(\"7\"))\n    ```\n\n5. **Button Click Handler**: The `button_clicked` method updates the input field with the button's text.\n\n    ```python\n    def button_clicked(self, text):\n        current_text = self.lineEdit.text()\n        self.lineEdit.setText(current_text + text)\n    ```\n\n6. **Calculation and Clear Functions**: The `calculate` method evaluates the expression in the input field, while the `clear` method resets it.\n\n    ```python\n    def calculate(self):\n        try:\n            result = eval(self.lineEdit.text())\n            self.lineEdit.setText(str(result))\n        except Exception as e:\n            self.lineEdit.setText(\"Error\")\n\n    def clear(self):\n        self.lineEdit.setText(\"\")\n    ```\n\n7. **Keyboard Input Handling**: The `keyPressEvent` method allows the user to use the keyboard for input.\n\n    ```python\n    def keyPressEvent(self, event):\n        key = event.key()\n        ...\n    ```\n\n### UI and EXE Files\n\n- **UI File**: The user interface is defined within the Python script itself using PyQt5 widgets and layouts.\n- **EXE File**: The executable file (`Basic-Calculator.exe`) allows users to run the application without needing to install Python or the required libraries.\n\n## Files\n\n- `Basic-Calculator.py`: The main Python script for the application.\n- `icon.png`: The icon file for the application.\n- `Basic-Calculator.exe`: The executable file for the application (if provided).\n\n## Author\n\n**Hamed Gharghi**\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- PyQt5 Documentation: [https://www.riverbankcomputing.com/static/Docs/PyQt5/](https://www.riverbankcomputing.com/static/Docs/PyQt5/)\n\n## Tags\n\n- `Python`\n- `PyQt5`\n- `Calculator`\n- `GUI`\n- `Basic Arithmetic`\n- `Keyboard Input`\n- `Event Handling`\n- `Open Source`\n- `MIT License`\n- `Dark Theme`\n- `Icon`\n\n---\n\n\u003e **Stickers:**\n\u003e \n\u003e ![Python](https://img.shields.io/badge/Python-3.8%2B-blue)\n\u003e ![PyQt5](https://img.shields.io/badge/PyQt5-5.15.4-green)\n\u003e ![License](https://img.shields.io/badge/License-MIT-yellow)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamed-gharghi%2Fbasic-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhamed-gharghi%2Fbasic-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamed-gharghi%2Fbasic-calculator/lists"}