Here's a simple example of how to create a software with an executable (.exe) file using Python and PyInstaller. This example creates a basic calculator application:
- Create a Python script named
calculator.py with the following content:
import tkinter as tk
def add():
try:
num1 = float(entry1.get())
num2 = float(entry2.get())
result.set(num1 + num2)
except ValueError:
result.set("Invalid input")
def subtract():
try:
num1 = float(entry1.get())
num2 = float(entry2.get())
result.set(num1 - num2)
except ValueError:
result.set("Invalid input")
def multiply():
try:
num1 = float(entry1.get())
num2 = float(entry2.get())
result.set(num1 * num2)
except ValueError:
result.set("Invalid input")
def divide():
try:
num1 = float(entry1.get())
num2 = float(entry2.get())
if num2 == 0:
result.set("Cannot divide by zero")
else:
result.set(num1 / num2)
except ValueError:
result.set("Invalid input")
root = tk.Tk()
root.title("Simple Calculator")
root.geometry("400x300")
tk.Label(root, text="Number 1:").pack(pady=5)
entry1 = tk.Entry(root)
entry1.pack(pady=5)
tk.Label(root, text="Number 2:").pack(pady=5)
entry2 = tk.Entry(root)
entry2.pack(pady=5)
tk.Button(root, text="Add", command=add).pack(pady=5)
tk.Button(root, text="Subtract", command=subtract).pack(pady=5)
tk.Button(root, text="Multiply", command=multiply).pack(pady=5)
tk.Button(root, text="Divide", command=divide).pack(pady=5)
result = tk.StringVar()
tk.Label(root, text="Result:").pack(pady=5)
tk.Label(root, textvariable=result).pack(pady=5)
root.mainloop()
-
Install PyInstaller by running the following command in your terminal or command prompt:
pip install pyinstaller
-
Navigate to the directory where calculator.py is saved and run the following command to create the .exe file:
pyinstaller --onefile --windowed calculator.py
-
The executable file calculator.exe will be created in the dist folder within the same directory.
This will create a standalone executable file for a simple calculator application. If you need a different functionality or a more complex software, please provide more details about what "ab tutore" refers to and what specific features you need in your software.
For a more tailored solution, additional information about the desired functionality would be helpful.