[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    test code for crash reports on mac
From:       Mel Tearle <mel.tearle () gmail ! com>
Date:       2024-04-22 3:31:29
Message-ID: 7ECBD2FB-3FC3-493F-A93F-B5CD3B9AA789 () gmail ! com
[Download RAW message or body]

Hello,

I found a better way to format the traceback so it's
more like the built in one.

The vscode person didn't have any the problem running this, 
but then again, they didn't know what Rosetta was.

Thank you once more  for the suggestion.

Mel Tearle


import sys
import traceback

from PyQt6.QtCore import *
from PyQt6.QtGui import *
from PyQt6.QtWidgets import * 

class Window(QWidget):
def __init__(self):
super().__init__()
self.scene = QGraphicsScene(self)
self.view = QGraphicsView(self.scene)

self.scene.setSceneRect(0, 0, 400, 400)
## if you comment this line out and run this on a laptop without a mouse you should a \
qt.pointer.dispatch error \
self.view.viewport().setAttribute(Qt.WidgetAttribute.WA_AcceptTouchEvents, False) \
self.button = QPushButton("close") self.button.clicked.connect(self.bye)
layout = QVBoxLayout(self)
layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
layout.addWidget(self.view)
layout.addWidget(self.button)
self.setGeometry(550, 50, 400, 400)
self.show()

def bye(self):
1 + '1'
self.close()

def hook(type, value, tb): ## thanks to phil thompson and dev.to
err = '\t'.join(traceback.extract_tb(tb).format())
print(f'\n{type} \n{value} \n{err}')
sys.exit()

sys.excepthook = hook
if __name__ == '__main__':
app = QApplication(sys.argv)
test = Window()
sys.exit(app.exec())=


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic