8000 Add PyQt calculator tutorial · realpython/materials@36e6473 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36e6473

Browse files
committed
Add PyQt calculator tutorial
1 parent 5d64ca2 commit 36e6473

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Byte-compiled / optimized
2+
__pycache__/
3+
*.py[cod]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Prahlad Yeri
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# PyCalc
2+
< 8000 /div>
3+
PyCalc is a sample calculator implemented using Python 3, and with a [PyQt5](https://www.riverbankcomputing.com/static/Docs/PyQt5/introduction.html) GUI. PyCalc implements the most basic math operations, that is, division, multiplication, addition, and subtraction.
4+
5+
PyCalc is intended to be a demonstrative example on how you can implement a Python + PyQt5 GUI application using the Model-View-Controller (MVC) pattern.
6+
7+
## Screenshot
8+
9+
![Screenshot](screenshot.png)
10+
11+
## Requirements
12+
13+
For PyCalc to work, you need to have a proper installation of [Python](https://www.python.org) >= 3.6. Then you need to install the PyQt5 library in your system. This can be done by using `pip3` as follows:
14+
15+
```console
16+
$ sudo pip3 install pyqt5
17+
```
18+
19+
We don't recommend you to install PyCalc's requirements directly into your system, as PyCalc is just a sample application. So, you can use a virtual environment to test PyCalc out. To do that, you can run the following commands:
20+
21+
```console
22+
$ python3 -m venv pycalc
23+
$ source pycalc/bin/activate
24+
$ pip install pyqt5
25+
```
26+
27+
After this steps are finished, you can run and test PyCalc as described in the next section.
28+
29+
**Note**: For more information on how to install PyQt5, you can take a look at the related topic on the [project's documentation](https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html).
30+
31+
## How to Run PyCalc
32+
33+
To run PyCalc from your system's command-line and try it out, you can execute the following command:
34+
35+
```console
36+
$ python3 pycalc.py
37+
```
38+
39+
After running this command, you'll see PyCalc running on your screen.
40+
41+
## How to Use PyCalc
42+
43+
To use PyCalc, you just need to enter a valid math expression using your mouse, and then press `Enter` or click on the `=` sign:
44+
45+
![Screenshot](pycalc-howto.gif)
46+
47+
## About the Author
48+
49+
My name is Leodanis Pozo Ramos. I'm a **freelance Python Developer and [technical writer](https://realpython.com/team/lpozoramos/)**. If you need more information about me, and my work, then you can take a look at my [personal page](https://lpozo.github.com/).
50+
51+
## License
52+
53+
PyCalc is released under the [MIT License](https://opensource.org/licenses/MIT).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PyQt5==5.12.2

0 commit comments

Comments
 (0)
0