[Python] Imported module returns to main module unexpectedly

Discussão em 'Python' iniciado por Stack, Abril 27, 2025.

  1. Stack

    Stack Membro Participativo

    I import a module expecting the imported module to handle some database maintenance based on variables passed from the main menu and display a customer maintenance window. The imported menu does not display the window. It executes the print on line #36 but not the print on line #43 nor any others before returning to the main module.

    Below is the code for the imported module.

    import os
    import sys
    import sqlite3
    import PySide6
    import passed

    print("Customer Maint Execution has begun")
    #QUiLoader allows screen created in QT Designer to be loaded
    from PySide6.QtUiTools import QUiLoader
    from PySide6.QtCore import QSize
    from PySide6.QtSql import QSqlDatabase, QSqlQuery, QSqlQueryModel
    from PySide6.QtWidgets import (
    QApplication,
    QComboBox,
    QDataWidgetMapper,
    QDoubleSpinBox,
    QFormLayout,
    QLabel,
    QLineEdit,
    QMainWindow,
    QSpinBox,
    QWidget,
    )
    print("passed.action = ", passed.action)
    print("passed.cust_code = ", passed.cust_code)

    loader = QUiLoader()
    basedir = os.path.dirname(__file__)
    print("Defining Widget")
    class CM(QWidget):
    def __init__(self):
    super().__init__()
    self.cust_maint = loader.load(
    os.path.join(basedir, "windows/cust_maint.ui"), None
    )
    print("cust_maint show about to be executed")
    self.cust_maint.show()
    print("cust_maint show executed")
    self.cust_maint.setWindowTitle("Integrity Customer Maintenance")
    self.db = QSqlDatabase("QSQLITE")
    self.db.setDatabaseName(os.path.join(basedir, "databases/integrity.db"))
    self.db.open()
    self.connection_obj = sqlite3.connect('databases/integrity.db')
    self.cursor_obj = self.connection_obj.cursor()
    self.cursor_obj.execute('SELECT * FROM customer WHERE cust_code = ?',
    (main_menu(sys_cust_code,)))
    self.customer_rec = self.cursor_obj.fetchone() # holds data from customer
    database
    self.code = self.customer_rec[0]
    self.name = self.customer_rec[1]
    self.bill_street1 = self.customer_rec[2]
    self.bill_street2 = self.customer_rec[3]
    self.bill_city = self.customer_rec[4]
    self.bill_state = self.customer_rec[5]
    self.bill_zip = self.customer_rec[6]
    print ("Key = ",self.sys_cust_code)
    print(self.customer_rec)
    print("")
    print("Printing Individual Fields")
    x=0
    while x < 16:
    print("Field", x,"Code = ", self.customer_rec[x])
    x=x+1
    self.cust_maint.code
    #self.cust_maint.code.setText(f'{self.code}: {self.name}')
    self.cust_maint.code.setText(f'{self.customer_rec [0]}')
    self.cust_maint.name.setText(f'{self.customer_rec[1]}')
    self.cust_maint.bill_street_1.setText(f'{self.customer_rec[2]}')
    self.cust_maint.bill_street_2.setText(f'{self.customer_rec[3]}')
    self.cust_maint.bill_city.setText(f'{self.customer_rec[4]}')
    self.cust_maint.bill_state.setText(f'{self.customer_rec[5]}')
    self.cust_maint.bill_zip.setText(f'{self.customer_rec[6]}')
    self.cust_maint.bill_zip_plus.setText(f'{self.customer_rec[7]}')
    self.cust_maint.ship_street_1.setText(f'{self.customer_rec[8]}')
    self.cust_maint.ship_street_2.setText(f'{self.customer_rec[9]}')
    self.cust_maint.ship_city.setText(f'{self.customer_rec[10]}')
    self.cust_maint.ship_state.setText(f'{self.customer_rec[11]}')
    self.cust_maint.ship_zip.setText(f'{self.customer_rec[12]}')
    self.cust_maint.ship_zip_plus.setText(f'{self.customer_rec[13]}')
    self.cust_maint.last_order.setText(f'{self.customer_rec[14]}')
    self.cust_maint.terms.setText(f'{self.customer_rec[15]}')
    mu = int(self.customer_rec[16])
    print('Type = ',type(mu))
    self.cust_maint.mark_up.setValue(mu)
    self.cust_maint.show()


    Thanks in advance for your assistance.

    Continue reading...

Compartilhe esta Página