class EvidentaApp(QtWidgets.QTabWidget): def init(self, parent=None): super(EvidentaApp,…
- User
class EvidentaApp(QtWidgets.QTabWidget): def init(self, parent=None): super(EvidentaApp, self).init(parent) self.setWindowTitle("Evidenta Incasari/Depuneri") self.setStyleSheet(""" QTabBar::tab { padding: 10px 15px; border-radius: 5px; border: 1px solid #cccccc; }
QTabBar::tab:hover { background: #5499C7; border-color: #3677b0; } QTabBar::tab:selected { background: #AED6F1; border-color: #97cdde; } """) self.tabs = { 'Cash': CashTab(self), 'Depunere': QtWidgets.QLabel('Aici poți gestiona depunerile.'), 'Monetar': QtWidgets.QLabel('Aici poți gestiona aspecte monetare.'), 'Centralizator': QtWidgets.QLabel('Aici poți accesa centralizatorul.'), 'Bani Loc': QtWidgets.QLabel('Aici poți gestiona banii locali.') } for tab, widget in self.tabs.items(): self.addTab(widget, tab) # Set a fixed width self.setFixedWidth(800) # Change 800 to the width you wantdef main(): app = QtWidgets.QApplication([]) window = EvidentaApp() window.show() app.exec_()
if name == "main": main() ; vreau sa rescrii codul centrand taburile
- Assistant
- User
- Assistant
- User
Traceback (most recent call last): File "C:\Users\Costin\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Costin\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 88, in run_code exec(code, run_globals) File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy_main.py", line 39, in cli.main() File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main run() File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file runpy.run_path(target, run_name="") File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 320, in run_path code, fname = _get_code_from_file(run_name, path_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 294, in _get_code_from_file code = compile(f.read(), fname, 'exec') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Costin\Documents\PythonApplication1\PythonApplication1.py", line 11 self.table.setHorizontalHeaderLabels([‘Bancnota’, ‘Cantitate’, ‘Subtotal’]) ^ SyntaxError: invalid character '‘' (U+2018) The thread 0x1 has exited with code 0 (0x0). The program 'python.exe' has exited with code 4294967295 (0xffffffff).
- Assistant
It looks like the issue you're facing is with the characters used for quotes in your Python code. In Python, you need to use straight single quotes
'or double quotes"for string literals, not the curly quotes‘or’that you have in your code snippet.To correct the syntax error, replace the curly quotes with straight quotes like this:
self.table.setHorizontalHeaderLabels(['Bancnota', 'Cantitate', 'Subtotal'])I will also include the entire corrected
CashTabclass and relevant portions of your script here for clarity:from PyQt5 import QtWidgets, QtGui, QtCore import pandas as pd import os class CashTab(QtWidgets.QWidget): def __init__(self, parent=None): super().__init__(parent) layout = QtWidgets.QVBoxLayout(self) self.table = QtWidgets.QTableWidget(0, 3) # NOTICE: straight single quotes are used here self.table.setHorizontalHeaderLabels(['Bancnota', 'Cantitate', 'Subtotal']) layout.addWidget(self.table) self.loadButton = QtWidgets.QPushButton('Load') self.loadButton.clicked.connect(self.loadFromFile) layout.addWidget(self.loadButton) self.saveButton = QtWidgets.QPushButton('Save') self.saveButton.clicked.connect(self.saveToFile) layout.addWidget(self.saveButton) def loadFromFile(self): # ... your existing code ... def saveToFile(self): # ... your existing code ... # ... rest of your EvidentaApp and main ... if __name__ == "__main__": main() - User
- Assistant
- User
Traceback (most recent call last): File "C:\Users\Costin\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Costin\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 88, in run_code exec(code, run_globals) File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy_main.py", line 39, in cli.main() File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main run() File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file runpy.run_path(target, run_name="") File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 320, in run_path code, fname = _get_code_from_file(run_name, path_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 294, in _get_code_from_file code = compile(f.read(), fname, 'exec') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^The thread 0x1 has exited with code 0 (0x0). ^ File "C:\Users\Costin\Documents\PythonApplication1\PythonApplication1.py", line 11 self.table.setHorizontalHeaderLabels([‘Bancnota’, ‘Cantitate’, ‘Subtotal’]) ^ SyntaxError: invalid character '‘' (U+2018) The program 'python.exe' has exited with code 4294967295 (0xffffffff).
- Assistant
The error you've provided indicates that there are still curly quotes present in the code at line 11. It seems like the section of the code around
setHorizontalHeaderLabelsstill contains invalid curly quotes (‘ and ’), which need to be replaced with straight quotes (' or ").Here is the corrected line:
self.table.setHorizontalHeaderLabels(['Bancnota', 'Cantitate', 'Subtotal'])This is how the
CashTabclass should look after replacing all the curly quotes with straight ones:class CashTab(QtWidgets.QWidget): def __init__(self, parent=None): super().__init__(parent) layout = QtWidgets.QVBoxLayout(self) self.table = QtWidgets.QTableWidget(0, 3) # Straight quotes used here self.table.setHorizontalHeaderLabels(['Bancnota', 'Cantitate', 'Subtotal']) layout.addWidget(self.table) self.loadButton = QtWidgets.QPushButton('Load') self.loadButton.clicked.connect(self.loadFromFile) layout.addWidget(self.loadButton) self.saveButton = QtWidgets.QPushButton('Save') self.saveButton.clicked.connect(self.saveToFile) layout.addWidget(self.saveButton) # ... rest of CashTab class methods without curly quotes ... - User
scrie un cod complet si detaliat in wpf in care creezi o fereastra cu 4 butoane laterale in stanga
- Assistant