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. Jog Pushbuttons Like Bind in Tkinter
Qt 6.11 is out! See what's new in the release blog

Jog Pushbuttons Like Bind in Tkinter

Scheduled Pinned Locked Moved Unsolved Qt for Python
9 Posts 3 Posters 734 Views
  • 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.
  • P Offline
    P Offline
    Pinks32
    wrote on last edited by
    #1

    I'm to create robot jog pushbuttons that once a PB is pressed will start a function (jog X+) and once the PB is released, will cause a stopjog function. I've tried using .pressed and .released (ref below) but those calls do not work. Any ideas on how to bind the function like in tkinter?

        # Check for Coords Jog pushbuttons
        if self.pushButton_Xplus.pressed:self.move_jog(text="X+")
        if self.pushButton_Xplus.released: self.move_stop
    
    jsulmJ 1 Reply Last reply
    0
    • P Pinks32

      I'm to create robot jog pushbuttons that once a PB is pressed will start a function (jog X+) and once the PB is released, will cause a stopjog function. I've tried using .pressed and .released (ref below) but those calls do not work. Any ideas on how to bind the function like in tkinter?

          # Check for Coords Jog pushbuttons
          if self.pushButton_Xplus.pressed:self.move_jog(text="X+")
          if self.pushButton_Xplus.released: self.move_stop
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Pinks32 Please read https://wiki.qt.io/Qt_for_Python_Signals_and_Slots
      There is an example how to connect a function to a signal:

      import sys
      from PySide2.QtWidgets import QApplication, QPushButton
      
      def func():
       print("func has been called!")
      
      app = QApplication(sys.argv)
      button = QPushButton("Call func")
      button.clicked.connect(func)
      button.show()
      sys.exit(app.exec_())
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • P Offline
        P Offline
        Pinks32
        wrote on last edited by
        #3

        Thanks! I've done that on other PB's where only clicked is required. Here I want to run func: move_jog() when the PB is held down continuously and then run stop_jog() when that same PB is released after being pushed. The two lines of code above don't work, i.e. the .pressed does not start the move_jog() func.

        JonBJ 1 Reply Last reply
        0
        • P Pinks32

          Thanks! I've done that on other PB's where only clicked is required. Here I want to run func: move_jog() when the PB is held down continuously and then run stop_jog() when that same PB is released after being pushed. The two lines of code above don't work, i.e. the .pressed does not start the move_jog() func.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Pinks32
          QPushButton.pressed/released are signals, needing to be connect()ed. In the code you show you are using them as though they were variables.

          1 Reply Last reply
          1
          • P Offline
            P Offline
            Pinks32
            wrote on last edited by
            #5

            Thanks. I changed code to reflect a connect:
            self.pushButton_J1plus.pressed.connect(lambda event:self.move_jog(text="J1+"))
            self.pushButton_J1plus.released.connect(self.move_stop)

            Seems the .pressed works ok, but the .released function doesn't work as expected, and doesn't get called. The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?

            jsulmJ JonBJ 3 Replies Last reply
            0
            • P Pinks32

              Thanks. I changed code to reflect a connect:
              self.pushButton_J1plus.pressed.connect(lambda event:self.move_jog(text="J1+"))
              self.pushButton_J1plus.released.connect(self.move_stop)

              Seems the .pressed works ok, but the .released function doesn't work as expected, and doesn't get called. The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Pinks32 said in Jog Pushbuttons Like Bind in Tkinter:

              but the .released function doesn't work as expected

              You mean self.move_stop is never called?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • P Pinks32

                Thanks. I changed code to reflect a connect:
                self.pushButton_J1plus.pressed.connect(lambda event:self.move_jog(text="J1+"))
                self.pushButton_J1plus.released.connect(self.move_stop)

                Seems the .pressed works ok, but the .released function doesn't work as expected, and doesn't get called. The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @Pinks32
                As @jsulm asks, have you checked by connecting a print() statement lambda to the signal to verify whether it ever gets called?

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Pinks32
                  wrote on last edited by
                  #8

                  Thanks for the advice. Placed print() statements in both move_jog & move_stop and sure enough move_stop was not getting called. There was a tkinter remanent left over in the move_stop module. Once removed, Now my jog PB's work as expected! Thanks again! Onto the next issue...

                  1 Reply Last reply
                  0
                  • P Pinks32

                    Thanks. I changed code to reflect a connect:
                    self.pushButton_J1plus.pressed.connect(lambda event:self.move_jog(text="J1+"))
                    self.pushButton_J1plus.released.connect(self.move_stop)

                    Seems the .pressed works ok, but the .released function doesn't work as expected, and doesn't get called. The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #9

                    @Pinks32 said in Jog Pushbuttons Like Bind in Tkinter:

                    The jog & jog stop functions have worked w/tkinter so I'm ruling out the functions as any issue. Ideas?

                    There was a tkinter remanent left over in the move_stop module. Once removed, Now my jog PB's work as expected!

                    :)

                    Don't make assumptions. Put in debug messages.

                    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