def qtdb_trace(): """Make ``PDB`` usable by calling :func:`pyqtRemoveInputHook`. Otherwise, ``PDB`` is useless as the message:: > QCoreApplication::exec: The event loop is already running is spammed to the console. When done, call qtdb_resume from the PDB prompt to return things back to normal. Note that ``PDB`` will drop you into the current frame (this function) and hitting 'n' is required to return to the frame you wanted ``PDB`` originally. This could probably be optimized at some point to manipulate the frame PDB starts in. """ if False: logger.info('No debug') return else: import pdb from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() pdb.set_trace()
def remove_inputhook(): """Remove the PyQt input hook. Doing this means we can't use the interactive shell anymore (which we don't anyways), but we can use pdb instead.""" from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook()
def info(type, value, tb) -> None: # type: ignore for line in traceback.format_exception(type, value, tb): sys.stdout.write(line) pyqtRemoveInputHook() from pdb import pm pm()
def debug_trace(self): """Set a tracepoint in the Python debugger that works with Qt""" from PyQt5.QtCore import pyqtRemoveInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace()
def debug_trace( self ): # for debugging, you have to call pyqtRemoveInputHook before set_trace() from PyQt5.QtCore import pyqtRemoveInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace()
def set_trace(): '''Set a tracepoint in the Python debugger that works with Qt''' import pdb if QT_VERSION == "PyQt5": from PyQt5.QtCore import pyqtRemoveInputHook, pyqtRestoreInputHook pyqtRemoveInputHook() pdb.set_trace()
def info(type, value, tb): from PyQt5.QtCore import pyqtRemoveInputHook for line in traceback.format_exception(type, value, tb): sys.stdout.write(line) pyqtRemoveInputHook() from pdb import pm pm()
def main(): from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() logger.add("cucu_{time}.log", enqueue=True) logger.debug("logger add") app = QApplication(sys.argv) DBChoice() main_window = AppWindow() _controller = FilesCrt() main_window.scan_files_signal.connect(_controller.on_scan_files) # when data changed on any widget main_window.change_data_signal.connect(_controller.on_change_data) # signal from open_dialog=dlg main_window.open_dialog.DB_connect_signal.connect( _controller.on_db_connection) main_window.first_open_data_base() main_window.show() sys.exit(app.exec_())
def debug_trace(): """Set a tracepoint in the Python debugger that works with Qt""" from PyQt5.QtCore import pyqtRemoveInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace()
def _enable_pdb(): # pragma: no cover """Enable a Qt-aware IPython debugger.""" from IPython.core import ultratb logger.debug("Enabling debugger.") from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() sys.excepthook = ultratb.FormattedTB(mode='Verbose', color_scheme='Linux', call_pdb=True)
def debug(*args): pyqtRemoveInputHook() result = function(*args) pyqtRestoreInputHook() return result
def debug_trace(): """ Helper to allow debugging with pyqt application. After debugging call PyQt4.QtCore.pyqtRestoreInputHook """ from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() import pdb pdb.set_trace()
def set_trace(): pyqtRemoveInputHook() # set up the debugger debugger = pdb.Pdb() debugger.reset() # custom next to get outside of function scope debugger.do_next(None) # run the next command users_frame = sys._getframe().f_back # frame where the user invoked `pyqt_set_trace()` debugger.interaction(users_frame, None)
def main(): pyqtRemoveInputHook() app = QApplication(sys.argv) app.setWindowIcon(QIcon(":/icon.svg")) app.setApplicationName(progname) main = MainWindow() main.resize(1280, 1024) main.show() return app.exec()
def __init__(self, args: argparse.Namespace): self._args = args self._splash: Optional[QSplashScreen] = None pyqtRemoveInputHook() self._app = QApplication(sys.argv) self._app.setApplicationName("bubblesub") self._loop = quamash.QEventLoop(self._app) asyncio.set_event_loop(self._loop)
def main(): pyqtRemoveInputHook() app = QApplication(sys.argv) handler, account = init_dc(app, addr=sys.argv[1], mail_pw=sys.argv[2]) window = MainWindow(account) handler.incoming_message.connect(window.on_incoming_message) window.show() app.exec_()
def debug_trace(): '''Set a tracepoint in the Python debugger that works with Qt''' from PyQt5.QtCore import pyqtRemoveInputHook # Or for Qt5 #from PyQt5.QtCore import pyqtRemoveInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace()
def guardar(self,obj_N_datos_personales): engine=create_engine('postgresql://*****:*****@localhost:5432/psicologos') Session= sessionmaker(bind=engine) session=Session() pyqtRemoveInputHook() import pdb; pdb.set_trace() new_record = E_party_contacto(1,1) new_record.id = 1 new_record.id_party =1 new_record.create_uid = 1 new_record.create_date = func.now() new_record.write_date = func.now() new_record.value = obj_N_datos_personales.telefono_personal new_record.comment= "" new_record.type_contacto= "telefono personal" session.add(new_record) session.commit() new_record2 = E_party_contacto(1,1) new_record2.id = 2 new_record2.id_party =1 new_record2.create_uid = 1 new_record2.create_date = func.now() new_record2.write_date = func.now() new_record2.value = obj_N_datos_personales.email_personal new_record2.comment= "" new_record2.type_contacto= "email personal" session.add(new_record2) session.commit() new_record3 = E_party_contacto(1,1) new_record3.id = 3 new_record3.id_party =1 new_record3.create_uid = 1 new_record3.create_date = func.now() new_record3.write_date = func.now() new_record3.value = obj_N_datos_personales.telefono_profesional new_record3.comment= "" new_record3.type_contacto= "telefono profesional" session.add(new_record3) session.commit() new_record4 = E_party_contacto(1,1) new_record4.id = 4 new_record4.id_party =1 new_record4.create_uid = 1 new_record4.create_date = func.now() new_record4.write_date = func.now() new_record4.value = obj_N_datos_personales.telefono_profesional new_record4.comment= "" new_record4.type_contacto= "email profesional" session.add(new_record4) session.commit()
def set_trace(): pyqtRemoveInputHook() try: import pdb debugger = pdb.Pdb() debugger.reset() debugger.do_next(None) frame = sys._getframe().f_back debugger.interaction(frame, None) finally: pass
def debug_trace(): """ Set a tracepoint in the Python debugger that works with Qt. Removes "QCoreApplication::exec: The event loop is already running" messages while in pdb :return: """ from PyQt5.QtCore import pyqtRemoveInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace()
def get_config_as_dict(self): dictionary = self.config.as_dict() for key, value in dictionary.items(): from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() # import ipdb; ipdb.set_trace() # noqa BREAKPOINT if type(value) == QString: value = str(value) dictionary[key] = value return dictionary
def debugTrace(): from PyQt5.QtCore import pyqtRemoveInputHook, pyqtRestoreInputHook import pdb import sys pyqtRemoveInputHook() try: debugger = pdb.Pdb() debugger.reset() debugger.do_next(None) user_frame = sys._getframe().f_back debugger.interaction(user_frame, None) finally: pyqtRestoreInputHook()
def run(self): pyqtRemoveInputHook() # to prevent Qt conflicting with pdb debug self.loop = asyncio.get_event_loop() self.loop.set_debug(False) main = MainWindow(self.loop, self.log, self) self.main_finished = main.finished try: self.loop.add_signal_handler(signal.SIGINT, main.shutdown, None) except NotImplementedError: # for Windows pass self.loop.run_until_complete(self.process_events()) qCleanupResources()
def pyqt_set_trace(): '''Set a tracepoint in the Python debugger that works with Qt''' from PyQt5.QtCore import pyqtRemoveInputHook import pdb import sys pyqtRemoveInputHook() # set up the debugger debugger = pdb.Pdb() debugger.reset() # custom next to get outside of function scope debugger.do_next(None) # run the next command # frame where the user invoked `pyqt_set_trace()` users_frame = sys._getframe().f_back debugger.interaction(users_frame, None)
def configure_pyqt(): """Remove the PyQt input hook and enable overflow checking. Doing this means we can't use the interactive shell anymore (which we don't anyways), but we can use pdb instead. """ from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() import sip try: # Added in sip 4.19.4 sip.enableoverflowchecking(True) except AttributeError: pass
def debug_trace(): """Helper to allow debugging with pyqt application. The standard way of using "import pdb; pdb.set_trace()" does not work with Qt application as the Qt fills the terminal with messages. Using this bypasses it: from meggie.utilities.debug import debug_trace; debug_trace() When stopped, use "u" to go to parent function. After debugging should call PyQt4.QtCore.pyqtRestoreInputHook, though often one just quits and restarts. """ from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() import pdb pdb.set_trace()
def main(): # create application pyqtRemoveInputHook() app = QApplication(sys.argv) app.setApplicationName('15ID-C XFNTR Analyzer') # create widget w = MainWindow() w.setWindowTitle('15ID-C XFNTR Analyzer') # w.setWindowIcon(QIcon('logo.png')) w.show() # connection app.lastWindowClosed.connect(app.quit) # execute application sys.exit(app.exec_())
def buscar(self): pyqtRemoveInputHook() import pdb pdb.set_trace() #self.limpiar() if self.obj_form.lne_cuit.text() != "": cuit = self.obj_form.lne_cuit.text() obj_e_cliente = E_cliente() self.obj_cliente = obj_e_cliente.get_cliente_cuit_cuil(cuit) if self.obj_cliente == False: msgBox = QMessageBox() msgBox.setWindowTitle("Atencion") msgBox.setText('No se encontro el cliente') msgBox.exec_() else: msgBox = QMessageBox() msgBox.setWindowTitle("Atencion") msgBox.setText('Cliente se encontra') msgBox.exec_() self.obj_form.lne_razon_social.setText( self.obj_cliente.razon_social) obj_e_ejercicio = E_ejercicio() self.lista_ejercicio = obj_e_ejercicio.get_ejercicio_id_cliente( self.obj_cliente.id_cliente) for item in self.lista_ejercicio: self.obj_form.cbx_ejercicio.addItem(item.descripcion) obj_e_plan_cuenta = E_plan_cuentas() self.lista_plancuenta = obj_e_plan_cuenta.get_cuentas_id_cliente( self.obj_cliente.id_cliente) for item in self.lista_plancuenta: self.obj_form.cbx_cuenta.addItem(item.descripcion) elif self.obj_form.lne_razon_social.text() != "": razon_social = self.obj_form.lne_razon_social.text() obj_e_cliente = E_proveedor() self.obj_cliente = obj_e_cliente.get_cliente_razon_social( razon_social) if self.obj_cliente == False: #"cliente encontrado" a = 1 else: a = 2
def __onDebugger(self): """Brings up a debugger""" heap = self.hpy.heap() unreachable = self.hpy.heapu() logging.error( "Use 'heap' and 'unreachable' objects. Type 'c' when finished.") QApplication.processEvents() oldstdin = sys.stdin oldstdout = sys.stdout oldstderr = sys.stderr sys.stdin = sys.__stdin__ sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ pyqtRemoveInputHook() pdb.set_trace() pyqtRestoreInputHook() sys.stdin = oldstdin sys.stdout = oldstdout sys.stderr = oldstderr
def seleccion_item_tabla(self, clickedIndex): w = QWidget() result = QMessageBox.question(w, 'Alerta', " Desea eliminar el cargo?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) obj_E_cargos = E_cargos() if result == QMessageBox.Yes: pyqtRemoveInputHook() import pdb pdb.set_trace() twi2 = self.obj_form.tw_nomina_cargos.item(clickedIndex, 7) obj_E_cargos.borrar_cargo(twi2.text()) while (self.obj_form.tw_nomina_cargos.rowCount() > 0): self.obj_form.tw_nomina_cargos.removeRow(0) lista_cargos = obj_E_cargos.get_grilla_form_cargos() for item in lista_cargos: rowPosition = self.obj_form.tw_nomina_cargos.rowCount() self.obj_form.tw_nomina_cargos.insertRow(rowPosition) self.obj_form.tw_nomina_cargos.setItem( rowPosition, 0, QTableWidgetItem(str(item.apellido))) self.obj_form.tw_nomina_cargos.setItem( rowPosition, 1, QTableWidgetItem(str(item.nro_doc))) self.obj_form.tw_nomina_cargos.setItem( rowPosition, 2, QTableWidgetItem(str(item.nro_asociado))) self.obj_form.tw_nomina_cargos.setItem( rowPosition, 3, QTableWidgetItem(str(item.cargo))) self.obj_form.tw_nomina_cargos.setItem( rowPosition, 4, QTableWidgetItem(str(item.fec_desde))) self.obj_form.tw_nomina_cargos.setItem( rowPosition, 5, QTableWidgetItem(str(item.fec_hasta))) self.obj_form.tw_nomina_cargos.setItem( rowPosition, 6, QTableWidgetItem(str(item.observacion))) self.obj_form.tw_nomina_cargos.setItem( rowPosition, 7, QTableWidgetItem(str(item.id)))
def calcular_cuotas(self): capital = self.obj_form.lne_capital.text() pyqtRemoveInputHook() import pdb pdb.set_trace() if capital != "": self.obj_form.lne_cta_3.setText(str(self.valor_cuota(3))) self.obj_form.lne_cta_4.setText(str(self.valor_cuota(4))) self.obj_form.lne_cta_5.setText(str(self.valor_cuota(5))) self.obj_form.lne_cta_6.setText(str(self.valor_cuota(6))) self.obj_form.lne_cta_7.setText(str(self.valor_cuota(7))) self.obj_form.lne_cta_8.setText(str(self.valor_cuota(8))) self.obj_form.lne_cta_9.setText(str(self.valor_cuota(9))) self.obj_form.lne_cta_10.setText(str(self.valor_cuota(10))) self.obj_form.lne_cta_11.setText(str(self.valor_cuota(11))) self.obj_form.lne_cta_12.setText(str(self.valor_cuota(12))) self.obj_form.lne_cta_13.setText(str(self.valor_cuota(13))) self.obj_form.lne_cta_14.setText(str(self.valor_cuota(14))) self.obj_form.lne_cta_15.setText(str(self.valor_cuota(15))) self.obj_form.lne_cta_16.setText(str(self.valor_cuota(16))) self.obj_form.lne_cta_17.setText(str(self.valor_cuota(17))) self.obj_form.lne_cta_18.setText(str(self.valor_cuota(18))) self.obj_form.lne_cta_19.setText(str(self.valor_cuota(19))) self.obj_form.lne_cta_20.setText(str(self.valor_cuota(20))) self.obj_form.lne_cta_21.setText(str(self.valor_cuota(21))) self.obj_form.lne_cta_22.setText(str(self.valor_cuota(22))) self.obj_form.lne_cta_23.setText(str(self.valor_cuota(23))) self.obj_form.lne_cta_24.setText(str(self.valor_cuota(24))) else: msgBox = QMessageBox() msgBox.setWindowTitle("Atencion") msgBox.setText( 'Verificar que el campo Capital y Nro de cuota vacios') msgBox.exec_()
def calcular_cuotas(self): capital = self.obj_form.lne_capital.text() pyqtRemoveInputHook() import pdb; pdb.set_trace() if capital != "": self.obj_form.lne_cta_3.setText(str(self.valor_cuota(3))) self.obj_form.lne_cta_4.setText(str(self.valor_cuota(4))) self.obj_form.lne_cta_5.setText(str(self.valor_cuota(5))) self.obj_form.lne_cta_6.setText(str(self.valor_cuota(6))) self.obj_form.lne_cta_7.setText(str(self.valor_cuota(7))) self.obj_form.lne_cta_8.setText(str(self.valor_cuota(8))) self.obj_form.lne_cta_9.setText(str(self.valor_cuota(9))) self.obj_form.lne_cta_10.setText(str(self.valor_cuota(10))) self.obj_form.lne_cta_11.setText(str(self.valor_cuota(11))) self.obj_form.lne_cta_12.setText(str(self.valor_cuota(12))) self.obj_form.lne_cta_13.setText(str(self.valor_cuota(13))) self.obj_form.lne_cta_14.setText(str(self.valor_cuota(14))) self.obj_form.lne_cta_15.setText(str(self.valor_cuota(15))) self.obj_form.lne_cta_16.setText(str(self.valor_cuota(16))) self.obj_form.lne_cta_17.setText(str(self.valor_cuota(17))) self.obj_form.lne_cta_18.setText(str(self.valor_cuota(18))) self.obj_form.lne_cta_19.setText(str(self.valor_cuota(19))) self.obj_form.lne_cta_20.setText(str(self.valor_cuota(20))) self.obj_form.lne_cta_21.setText(str(self.valor_cuota(21))) self.obj_form.lne_cta_22.setText(str(self.valor_cuota(22))) self.obj_form.lne_cta_23.setText(str(self.valor_cuota(23))) self.obj_form.lne_cta_24.setText(str(self.valor_cuota(24))) else: msgBox = QMessageBox() msgBox.setWindowTitle("Atencion") msgBox.setText('Verificar que el campo Capital y Nro de cuota vacios') msgBox.exec_()
def unhooked_func(*args, **kwargs): pyqtRemoveInputHook() out = func(*args, **kwargs) pyqtRestoreInputHook() return out
self.t0 = 1.0 self.t1 = self.Konstant self.values = [0 for x in range(100)] def next(self): Tnext = ((self.Konstant * self.t1) * 2) - self.t0 if len(self.values) % 100 > 70: self.values.append(pylab.random() * 2 - 1) else: self.values.append(Tnext) self.t0 = self.t1 self.t1 = Tnext return self.values[-1] pyqtRemoveInputHook() app = QApplication(sys.argv) connector = TestConnector() connector.add_tag(Tag("Signal 1", 1000)) connector.add_tag(Tag("Signal 2", 2000)) connector.start_autopoll(100) hmi_plot = HMIPlot(connector) hmi_plot.add_observer(Observer(connector.tags["Signal 1"], 50)) hmi_plot.add_observer(Observer(connector.tags["Signal 2"], 200)) hmi_plot.delta_x = 100 hmi_plot.fig.autofmt_xdate() hmi_plot.axes[0].legend(("Test", "Test2")) hmi_plot.axes[0].set_ylim(-5, 5) hmi_plot.axes[0].grid(True)
def debug(): from PyQt5.QtCore import pyqtRemoveInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace()
def debug_trace(cls): from PyQt5.QtCore import pyqtRemoveInputHook, pyqtRestoreInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace() pyqtRestoreInputHook()
def __init__(self): from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() ibp()
def import_pdb_set_trace(): from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() import pdb;pdb.set_trace()
def debug_trace(): pyqtRemoveInputHook() set_trace()
def debug(): from PyQt5.QtCore import pyqtRemoveInputHook; pyqtRemoveInputHook() import ipdb; ipdb.set_trace()
def __enter__(self): from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() ibp() return self
def debugMode(): from PyQt5.QtCore import pyqtRemoveInputHook pyqtRemoveInputHook() import pdb pdb.set_trace()
def import_pdb_set_trace(): '''Set a tracepoint in the Python debugger that works with Qt''' from PyQt5.QtCore import pyqtRemoveInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace()