Neither pdb or print() displays the bug

Rich Shepard rshepard at appl-ecosys.com
Tue Jun 1 16:42:30 EDT 2021


On Tue, 1 Jun 2021, Ethan Furman wrote:

> Sounds like a console issue. Try using `logging` with a file... you could
> even use `print` with a file if you wanted to.

Ethan,

Not before using logging I found a reference/example page
<https://devopslearning.medium.com/debugging-python-code-logging-pdb-a8ca08a6475e>
and modified the module to this:

# activitytypes.py
import sys
import logging

from PyQt5 import QtWidgets as qtw
from PyQt5 import QtGui as qtg
from PyQt5 import QtCore as qtc
from PyQt5 import QtSql as qts

from datasource import db

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s -%(levelname)s - %(message)s')
logging.debug("Start of Program")

class ATMainWindow(qtw.QMainWindow):

     def __init__(self):
         super().__init__()

         # Model/View here.
         self.model = qts.QSqlTableModel(db=db) # for single table
         self.model.setTable('activitytypes')
         self.model.select()

         self.table = qtw.QTableView()
         self.table.setModel(self.model)

         self.setMinimumSize(qtc.QSize(800, 600))
         self.setCentralWidget(self.table)


if __name__ == '__main__':
     app = qtw.QApplication(sys.argv)
     window = ATMainWindow()
     window.show()
     #sys.exit(app.exec())
     app.exec_()

logging.debug("End of Program")

When I run it this is the output:
$ python activitytypes.py 
2021-06-01 13:39:10,219 -DEBUG - Start of Program
2021-06-01 13:39:15,229 -DEBUG - End of Program

Obviously I have much to learn about using python's logging capabilities.
I'll keep looking.

Thanks,

Rich






More information about the Python-list mailing list