Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. signals and slots
Qt 6.11 is out! See what's new in the release blog

signals and slots

Scheduled Pinned Locked Moved Unsolved Qt for Python
7 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bono151
    wrote on last edited by
    #1

    Hi All,

    a question regarding pyqtSignal.
    in one of m threads I'm declaring a signal:
    finished = pyqtSignal(list)
    and at the end of the thread I'm emitting the signal to indicate a thread has ended and among that I'm passing a list:
    self.finished.emit(self.cmd_log)

    in my main window I'm setting :
    self.thread_ver.finished.connect(lambda log: self.on_finished(log, "ver"))
    the finished.connect is calling self.on_finished() and passing log as the cmd_log signal that was emitted in the thread and a string.
    during the run I get:
    TypeError: <lambda>() missing 1 required positional argument: 'log'

    def on_finished(self, log, type):
        if type == "ver":
            self.btub_ver.create_graph()
            self.pb_eye_ver_run.setStyleSheet('QPushButton {color: green}')
            self.btub_ver.add_lane_overlay(self.bitmap, self.label_eye_lanes_all, self.label_tab_eye_all)
        else:
            self.btub.create_graph()
            self.pb_eye_run.setStyleSheet('QPushButton {color: green}')
            self.btub.add_lane_overlay(self.bitmap, self.label_eye_lanes_all, self.label_tab_eye_all)
        for line in log:
            self.te_log.append(line)
    

    any idea why is happening? in a previous version I didnt user the extra string "ver"
    I used self.thread_ver.finished.connect(lambda: self.on_finished) and it worked OK

    Manny thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Which version of Python are you using ?
      Which version of PyQt ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Which version of Python are you using ?
        Which version of PyQt ?

        B Offline
        B Offline
        Bono151
        wrote on last edited by
        #3

        @SGaist
        PyQt5 and Python 3.9

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you provide a full minimal script that triggers this issue ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          B 1 Reply Last reply
          0
          • SGaistS SGaist

            Can you provide a full minimal script that triggers this issue ?

            B Offline
            B Offline
            Bono151
            wrote on last edited by SGaist
            #5

            @SGaist
            many thanks for assisting me. I hope you were refering to the following

            worker class:

            import constant
            from time import sleep
            from math import log10
            from plot_graph import plot_graph
            import matplotlib.pyplot as plt
            from PyQt5.QtWidgets import QLabel, QWidget, QTextEdit
            from PyQt5.QtGui import QPixmap
            from PyQt5.QtCore import QObject, pyqtSignal
            
            
            class bathtub(QObject):
                err_counters = None
                word_counters = None
                bit_counters = None
                ber_counters = None
                pi_pos = None
                done_dwelling = None
                spi_if = None
                plot_list = None
                plots = None
                progress_val = 0
                cmd_log = []
            
                finished = pyqtSignal(list)
                progress = pyqtSignal(int)
            
                def __init__(self, die_offset, d2d_ser, spi_if, eye_tab, ber_target, lanes_bitmap):
                    super().__init__()
                    self.pri_tx = die_offset.pri_tx
                    self.pri_rx = die_offset.pri_rx
                    self.sec_tx = die_offset.sec_tx
                    self.sec_rx = die_offset.sec_rx
                    self.d2d_ser = d2d_ser
                    #self.lanes = lanes
                    self.spi_if = spi_if
                    #self.te_log = te_log
                    self.eye_tab = eye_tab
                    self.ber_target = ber_target
                    self.lanes_bitmap = lanes_bitmap
            
            #    def build_bathtub(self):
                def run(self):
                    self.init_arrays()
                    self.disable_prbs_checker()  # disable automatically clear the counters
                    self.pi_override_and_record_lanes()
                    self.set_prbs32_lanes()
                    self.move_pi_to_corner_pos("dec")#decrementing the pi to PI_LEFT_MARGINS
                    self.sweep_pi_pos("inc")#sweep the pi position up to the center
                    self.move_pi_to_corner_pos("inc")  # rementing the pi to PI_LEFT_MARGINS
                    self.sweep_pi_pos("dec")  # sweep the pi position up to the center
                    self.restore_system()
                    #self.create_graph()
                    self.finished.emit(self.cmd_log)
                    self.cmd_log.clear()
            

            Main Window:

               def pb_eye_run_handler(self):
                    self.te_log.clear()# later will be replaced by writing to file
                    self.thread = QThread()
                    self.btub = bathtub(offset, self.d2d_ser, self.spi_if, self.tab_eye, float(self.le_ber_target.text()), self.lanes_bitmap)
                    self.btub.moveToThread(self.thread)
                    self.thread.started.connect(self.btub.run)
                    self.btub.finished.connect(self.thread.quit)
                    self.btub.finished.connect(self.btub.deleteLater)
                    self.btub.progress.connect(lambda progress: self.on_progress("", progress))
                    self.thread.finished.connect(self.thread.deleteLater)
                    self.pb_eye_run.setStyleSheet('QPushButton {color: red}')
                    self.thread.start()
                    self.thread.finished.connect(lambda cmd_log: self.on_finished(cmd_log, ""))
            
            
            
               def on_finished(self, log, type):
                    if type == "ver":
                        self.btub_ver.create_graph()
                        self.pb_eye_ver_run.setStyleSheet('QPushButton {color: green}')
                        self.btub_ver.add_lane_overlay(self.bitmap, self.label_eye_lanes_all, self.label_tab_eye_all)
                    else:
                        self.btub.create_graph()
                        self.pb_eye_run.setStyleSheet('QPushButton {color: green}')
                        self.btub.add_lane_overlay(self.bitmap, self.label_eye_lanes_all, self.label_tab_eye_all)
                    for line in log:
                        self.te_log.append(line)
            
                def on_progress(self, type, val):
                    if type == "ver":
                        self.progressBar_ver.setValue(val)
                    else:
                        self.progressBar.setValue(val)
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Partly, it's not exactly minimal and also does not allow to reproduce the issue.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              B 1 Reply Last reply
              0
              • SGaistS SGaist

                Partly, it's not exactly minimal and also does not allow to reproduce the issue.

                B Offline
                B Offline
                Bono151
                wrote on last edited by
                #7

                @SGaist I dont think I will be able to share minimal code for reproducing

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved