Skip to content

Commit 148eaea

Browse files
authored
Merge pull request #2631 from tanujbordikar/screenshot
feat: Screenshot Gui added with documentation
2 parents 8890205 + 0ad6ecc commit 148eaea

File tree

6 files changed

+173
-77
lines changed

6 files changed

+173
-77
lines changed

Diff for: GST Calculator/Readme.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
## GST Calculator Functionalities : 🚀
66

7-
- This is a GST Calculator where the user enters the original price and net price and the script returns the GST percentage.
7+
- This is a GST Calculator where the user enters the original price and net price
8+
- And the script returns the GST percentage with SGST and CGST percent value and the Total GST Value.
9+
- This code uses Tkinter as a User Interface and python as its main language.
810

911
## GST Calculator Instructions: 👨🏻‍💻
1012

@@ -22,7 +24,11 @@
2224

2325
### Step 4:
2426

25-
Sit back and Relax. Let the Script do the Job. ☕
27+
Let the Script do the Job and after that the tkinter UI will automatically be opened. ☕
28+
29+
### Step 5:
30+
31+
Now, enter the value of the total Value with GST and MRP of the product. And select the Calculate GST button.
2632

2733
## Requirements
2834

@@ -38,3 +44,7 @@
3844
## Author
3945

4046
[Amit Kumar Mishra](https://github.com/Amit366)
47+
48+
## Editor (Improvements adder)
49+
50+
[Tanuj Bordikar](https://github.com/tanujbordikar)

Diff for: GST Calculator/script.py

+46-43
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,76 @@
11
from tkinter import *
22

3-
# Function for finding GST rate
4-
5-
3+
# Function for finding CGST, SGST, and Total GST rates
64
def GST_Calc():
7-
8-
gst_percentField.delete(0, END)
9-
5+
cgst_percentField.delete(0, END)
6+
sgst_percentField.delete(0, END)
7+
total_gstField.delete(0, END)
8+
109
org_cost = int(original_priceField.get())
11-
1210
N_price = int(net_priceField.get())
13-
14-
gst_rate = ((N_price - org_cost) * 100) / org_cost
15-
16-
gst_percentField.insert(10, str(gst_rate) + " % ")
17-
11+
total_gst_rate = ((N_price - org_cost) * 100) / org_cost
12+
cgst_rate = total_gst_rate / 2
13+
sgst_rate = total_gst_rate / 2
14+
15+
cgst_percentField.insert(10, str(cgst_rate) + " % ")
16+
sgst_percentField.insert(10, str(sgst_rate) + " % ")
17+
18+
total_gst = (N_price - org_cost)
19+
total_gstField.insert(10, f"₹ {total_gst:.2f}")
1820

1921
def clearAll():
20-
2122
original_priceField.delete(0, END)
22-
2323
net_priceField.delete(0, END)
24-
25-
gst_percentField.delete(0, END)
26-
24+
cgst_percentField.delete(0, END)
25+
sgst_percentField.delete(0, END)
26+
total_gstField.delete(0, END)
2727

2828
# Driver Code
2929
if __name__ == "__main__":
30-
3130
gui = Tk()
32-
3331
gui.configure(background="light blue")
34-
3532
gui.title("GST Calculator")
33+
gui.geometry("500x300")
34+
35+
label_font = ('Arial', 14)
36+
entry_font = ('Arial', 12)
37+
button_font = ('Arial', 12, 'bold')
3638

37-
gui.geometry("500x500")
39+
original_price = Label(gui, text="Original Price:", font=label_font)
40+
original_price.grid(row=1, column=0, padx=10, pady=10, sticky='w')
3841

39-
original_price = Label(gui, text="Original Price",
40-
font=(None, 18))
42+
original_priceField = Entry(gui, font=entry_font)
43+
original_priceField.grid(row=1, column=1, padx=10, pady=10, sticky='w')
4144

42-
original_price.grid(row=1, column=1, padx=10, pady=10, sticky='w')
45+
net_price = Label(gui, text="Net Price:", font=label_font)
46+
net_price.grid(row=2, column=0, padx=10, pady=10, sticky='w')
4347

44-
original_priceField = Entry(gui)
48+
net_priceField = Entry(gui, font=entry_font)
49+
net_priceField.grid(row=2, column=1, padx=10, pady=10, sticky='w')
4550

46-
original_priceField.grid(row=1, column=2, padx=10, pady=10, sticky='w')
51+
find = Button(gui, text="Calculate GST", fg="black", bg="light yellow", font=button_font, command=GST_Calc)
52+
find.grid(row=3, column=1, padx=10, pady=10, sticky='w')
4753

48-
net_price = Label(gui, text="Net Price",
49-
font=(None, 18))
54+
cgst_percent = Label(gui, text="CGST Rate:", font=label_font)
55+
cgst_percent.grid(row=4, column=0, padx=10, pady=10, sticky='w')
5056

51-
net_price.grid(row=2, column=1, padx=10, pady=10, sticky='w')
52-
net_priceField = Entry(gui)
53-
net_priceField.grid(row=2, column=2, padx=10, pady=10, sticky='w')
57+
cgst_percentField = Entry(gui, font=entry_font)
58+
cgst_percentField.grid(row=4, column=1, padx=10, pady=10, sticky='w')
5459

55-
find = Button(gui, text="Find", fg="Black",
56-
bg="light yellow",
57-
command=GST_Calc)
58-
find.grid(row=3, column=2, padx=10, pady=10, sticky='w')
60+
sgst_percent = Label(gui, text="SGST Rate:", font=label_font)
61+
sgst_percent.grid(row=5, column=0, padx=10, pady=10, sticky='w')
5962

60-
gst_percent = Label(gui, text="Gst Rate", font=(None, 18))
61-
gst_percent.grid(row=4, column=1, padx=10, pady=10, sticky='w')
62-
gst_percentField = Entry(gui)
63+
sgst_percentField = Entry(gui, font=entry_font)
64+
sgst_percentField.grid(row=5, column=1, padx=10, pady=10, sticky='w')
6365

64-
gst_percentField.grid(row=4, column=2, padx=10, pady=10, sticky='w')
66+
total_gst_label = Label(gui, text="Total GST Amount:", font=label_font)
67+
total_gst_label.grid(row=6, column=0, padx=10, pady=10, sticky='w')
6568

66-
clear = Button(gui, text="Clear", fg="Black",
67-
bg="light yellow",
68-
command=clearAll)
69+
total_gstField = Entry(gui, font=entry_font)
70+
total_gstField.grid(row=6, column=1, padx=10, pady=10, sticky='w')
6971

70-
clear.grid(row=5, column=2, padx=10, pady=10, sticky='w')
72+
clear = Button(gui, text="Clear All", fg="black", bg="light yellow", font=button_font, command=clearAll)
73+
clear.grid(row=7, column=1, padx=10, pady=10, sticky='w')
7174

7275
# Start the GUI
7376
gui.mainloop()

Diff for: Screenshot/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Description
2+
The code above creates a simple screenshot tool using the Python tkinter library. The tool allows users to specify a delay in seconds before taking a screenshot. The screenshot is then saved as a PNG file with a timestamped name.
3+
4+
## Setup Instruction
5+
To run the code, you will need to have the Python tkinter and pyautogui libraries installed. You can install them using the following commands:
6+
7+
Here are the steps on how to run the code:
8+
9+
1. Install the Python tkinter and pyautogui libraries.<br/>
10+
``pip install tkinter pyautogui``
11+
12+
2. Save the code as a Python file.<br/>``screenshot.py``
13+
3. Run the code from the command line and write this command:<br/>``python screenshot.py``
14+
4. Specify the delay in seconds before taking a screenshot.
15+
5. Click the "Take Screenshot" button to capture the screenshot.
16+
17+
I hope this helps! Let me know if you have any other questions.
18+
19+
## Requirements
20+
1. python and its libararies like:
21+
- tkinter
22+
- pyautogui
23+
24+
## Screenshots save
25+
- When the screenshot is taken, it is saved as a PNG file with a timestamped name. For example, if the delay is set to 5 seconds and the screenshot is taken at 12:34 PM, the screenshot will be saved as 1234567890.png.

Diff for: Screenshot/screenshot.py

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
import time
22
import pyautogui
3+
import tkinter as tk
4+
from tkinter import ttk
35

4-
5-
def screenshot():
6+
def take_screenshot(delay):
67
name = int(round(time.time() * 1000))
78
name = '{}.png'.format(name) # To name the file
8-
time.sleep(5) # Time Wait Before Taking Screenshot
9+
time.sleep(delay) # Time Wait Before Taking Screenshot
910
img = pyautogui.screenshot(name)
1011
img.show() # To Show the Screenshot After Being Taken
1112

13+
def on_take_screenshot():
14+
delay = float(delay_entry.get())
15+
take_screenshot(delay)
16+
17+
# Create the tkinter GUI
18+
root = tk.Tk()
19+
root.title("Screenshot Tool")
20+
root.geometry("300x150")
21+
22+
# Label and Entry for specifying the time delay
23+
delay_label = ttk.Label(root, text="Delay (in seconds):")
24+
delay_label.pack(pady=10)
25+
delay_entry = ttk.Entry(root)
26+
delay_entry.pack(pady=5)
27+
delay_entry.insert(0, "5.0") # Default value
28+
29+
# Button to trigger the screenshot capture
30+
screenshot_button = ttk.Button(root, text="Take Screenshot", command=on_take_screenshot)
31+
screenshot_button.pack(pady=20)
1232

13-
screenshot()
33+
root.mainloop()

Diff for: hexCalculator/README.md

+8-13
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22

33
The aim of a decimal to hexadecimal (hex) calculator is to provide a tool that allows users to convert decimal numbers into their equivalent hexadecimal representation.
44

5-
Decimal to hexadecimal calculator takes a decimal number as input and converts it into a hexadecimal number.
6-
The following steps are involved in the conversion process:
7-
- User input
8-
- Validation
9-
- Conversion algorithm
10-
- Hexadecimal Output
5+
The code above creates a simple hex calculator using the Python tkinter library. The calculator allows users to add, subtract, multiply, and divide two hexadecimal numbers. The input fields are two text boxes where users can enter the hexadecimal numbers. The buttons at the bottom of the window perform the four operations. The output label displays the result of the operation.
116

127
## Language
13-
- [x] Python
8+
- Python
9+
- Tkinter
1410

1511
## Setup instructions
1612
Run the below command to show output
@@ -20,12 +16,11 @@ python hexCalculator.py
2016

2117
## Output
2218
```
23-
Enter decimal value: 10
24-
Decimal Value: 10
25-
Hexadecimal Value: A
19+
Here is the output of the code when the user enters 0x12 in the first text box, 0x34 in the second text box, and then clicks the Add button:
20+
Result: 0x46
2621
```
2722
```
28-
Enter decimal value: 50
29-
Decimal Value: 50
30-
Hexadecimal Value: 32
23+
If the user enters 0x12 in the first text box and 0x34 in the second text box, and then clicks the Add button.
24+
output: 0x46.
25+
This is the hexadecimal representation of the decimal number 56.
3126
```

Diff for: hexCalculator/hexCalculator.py

+58-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,64 @@
1-
conversion_table = {0: '0', 1: '1', 2: '2', 3: '3', 4: '4',
2-
5: '5', 6: '6', 7: '7',
3-
8: '8', 9: '9', 10: 'A', 11: 'B', 12: 'C',
4-
13: 'D', 14: 'E', 15: 'F'}
1+
import tkinter as tk
52

3+
def hex_add():
4+
try:
5+
num1 = int(entry1.get(), 16)
6+
num2 = int(entry2.get(), 16)
7+
result = hex(num1 + num2)
8+
output.config(text="Result: " + result.upper())
9+
except ValueError:
10+
output.config(text="Invalid Input")
611

7-
def decimalToHexadecimal(a):
8-
b = ''
9-
while (a > 0):
10-
remainder = a % 16
11-
b = conversion_table[remainder] + b
12-
a = a // 16
12+
def hex_subtract():
13+
try:
14+
num1 = int(entry1.get(), 16)
15+
num2 = int(entry2.get(), 16)
16+
result = hex(num1 - num2)
17+
output.config(text="Result: " + result.upper())
18+
except ValueError:
19+
output.config(text="Invalid Input")
1320

14-
return b
21+
def hex_multiply():
22+
try:
23+
num1 = int(entry1.get(), 16)
24+
num2 = int(entry2.get(), 16)
25+
result = hex(num1 * num2)
26+
output.config(text="Result: " + result.upper())
27+
except ValueError:
28+
output.config(text="Invalid Input")
1529

30+
def hex_divide():
31+
try:
32+
num1 = int(entry1.get(), 16)
33+
num2 = int(entry2.get(), 16)
34+
result = hex(num1 // num2)
35+
output.config(text="Result: " + result.upper())
36+
except (ValueError, ZeroDivisionError):
37+
output.config(text="Invalid Input")
1638

17-
decimal = int(input("Enter decimal value: "))
18-
hexadecimal = decimalToHexadecimal(decimal)
39+
# Main tkinter window
40+
root = tk.Tk()
41+
root.title("Hex Calculator")
42+
43+
# Entry fields
44+
entry1 = tk.Entry(root, width=15)
45+
entry1.grid(row=0, column=0, padx=10, pady=5)
46+
entry2 = tk.Entry(root, width=15)
47+
entry2.grid(row=0, column=1, padx=10, pady=5)
48+
49+
# Buttons
50+
add_button = tk.Button(root, text="Add", command=hex_add)
51+
add_button.grid(row=1, column=0, padx=10, pady=5)
52+
subtract_button = tk.Button(root, text="Subtract", command=hex_subtract)
53+
subtract_button.grid(row=1, column=1, padx=10, pady=5)
54+
multiply_button = tk.Button(root, text="Multiply", command=hex_multiply)
55+
multiply_button.grid(row=2, column=0, padx=10, pady=5)
56+
divide_button = tk.Button(root, text="Divide", command=hex_divide)
57+
divide_button.grid(row=2, column=1, padx=10, pady=5)
58+
59+
# Output Label
60+
output = tk.Label(root, text="Result: ")
61+
output.grid(row=3, columnspan=2)
62+
63+
root.mainloop()
1964

20-
print("Decimal Value:", decimal)
21-
print("Hexadecimal Value:", hexadecimal)

0 commit comments

Comments
 (0)