AI-NO PICS

Nothing happens when I try to run this program [closed]

I have absolutely zero knowledge of coding, just trying to make this program work but nothing happens i am using python and visual studio code. code is generated by Chat GPT 3. Whenever I try to run the program or open the .py file nothing happens. Please help.

`

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QVBoxLayout, QHBoxLayout, QPushButton

class ProductCostCalculator(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Product Cost Calculator")
        self.product_costs = {}

        # Create labels and line edits for cost inputs
        self.product_name_label = QLabel("Product Name")
        self.product_name_input = QLineEdit()
        self.cost_price_label = QLabel("Cost Price")
        self.cost_price_input = QLineEdit()
        self.customs_fees_label = QLabel("Customs Fees")
        self.customs_fees_input = QLineEdit()
        self.handling_fees_label = QLabel("Handling Fees")
        self.handling_fees_input = QLineEdit()
        self.other_costs_label = QLabel("Other Costs")
        self.other_costs_input = QLineEdit()
        self.shipping_cost_label = QLabel("Shipping Cost")
        self.shipping_cost_input = QLineEdit()

        # Create "Add Product" button
        self.add_product_button = QPushButton("Add Product")
        self.add_product_button.clicked.connect(self.add_product)

        # Create markup input and label
        self.markup_label = QLabel("Markup Percentage")
        self.markup_input = QLineEdit()
        self.calculate_button = QPushButton("Calculate")
        self.calculate_button.clicked.connect(self.calculate)

        # Create layout for cost inputs
        self.cost_input_layout = QVBoxLayout()
        self.cost_input_layout.addWidget(self.product_name_label)
        self.cost_input_layout.addWidget(self.product_name_input)
        self.cost_input_layout.addWidget(self.cost_price_label)
        self.cost_input_layout.addWidget(self.cost_price_input)
        self.cost_input_layout.addWidget(self.customs_fees_label)
        self.cost_input_layout.addWidget(self.customs_fees_input)
        self.cost_input_layout.addWidget(self.handling_fees_label)
        self.cost_input_layout.addWidget(self.handling_fees_input)
        self.cost_input_layout.addWidget(self.other_costs_label)
        self.cost_input_layout.addWidget(self.other_costs_input)
        self.cost_input_layout.addWidget(self.shipping_cost_label)
        self.cost_input_layout.addWidget(self.shipping_cost_input)
        self.cost_input_layout.addWidget(self.add_product_button)

        # Create layout for markup input
        self.markup_input_layout = QHBoxLayout()
        self.markup_input_layout.addWidget(self.markup_label)
        self.markup_input_layout.addWidget(self.markup_input)
        self.markup_input_layout.addWidget(self.calculate_button)

        # Create main layout and add sub-layouts
        self.main_layout = QVBoxLayout()
        self.main_layout.addLayout(self.cost_input_layout)
        self.main_layout.addLayout(self.markup_input_layout)
        self.setLayout(self.main_layout)

        def add_product(self):
         product_name = self.product_name_input.text()
         cost_price = float(self.cost_price_input.text())
         customs_fees = float(self.customs_fees_input.text())
         handling_fees = float(self.handling_fees_input.text())
         other_costs = float(self.other_costs_input.text())
         shipping_cost = float(self.shipping_cost_input.text())

         total_cost = cost_price + customs_fees + handling_fees + other_costs + shipping_cost
         self.product_costs[product_name] = total_cost

    def calculate(self):
        markup = float(self.markup_input.text())
        for product_name, total_cost in self.product_costs.items():
            gross_profit = (markup / 100) * total_cost
            selling_price = total_cost + gross_profit
            print(f"{product_name}:")
            print(f"Total Cost: ${total_cost}")
            print(f"Gross Profit: ${gross_profit}")
            print(f"Selling Price: ${selling_price}\n")

        if __name__ == '__main__':
         app = QApplication(sys.argv)
        calculator = ProductCostCalculator()
        calculator.show()
        sys.exit(app.exec_())

Trying to make this calculator work since a very long time. Any help at all would be so appreciated

For feedback or comments, reach us on hello@newswire.ae

admin.newswire

admin.newswire

About Author

Leave a comment

Your email address will not be published. Required fields are marked *

You may also like

AI-NO PICS

Looking for best option to export data into achieved then use the data to search for best match based on the certain parameters

We have an old way of storing the archive data in SQL Server and have an algorithm to retrieve the