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. Get upper left and down right coordinates from zoomed image
Qt 6.11 is out! See what's new in the release blog

Get upper left and down right coordinates from zoomed image

Scheduled Pinned Locked Moved Unsolved Qt for Python
25 Posts 3 Posters 4.2k Views 2 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.
  • J Offline
    J Offline
    john_hobbyist
    wrote on last edited by
    #14

    After a lot of google searching and experiments I resulted in this concept:

    class area:
        def __call__(self):
            x = 0, y = 0  # step 1
        
            def read_cursor(action):
                x = read_x
                y = read_y
                . . .
            def do_something(action):
                . . .
    

    The problem that x,y are not being updated when I move mouse. How do I pass the new updated mouse coordinates from read_cursor() function to ones in # step 1??

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

      You should provide a minimal runnable script that shows what you want to do with that piece of code.

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

      1 Reply Last reply
      1
      • J Offline
        J Offline
        john_hobbyist
        wrote on last edited by
        #16

        My code above is very simple. I need only to update x, y values (#step1), if someone can help me...

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

          Your code is incomplete and without context.
          It does not allow to understand the logic you want to implement.

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

          1 Reply Last reply
          1
          • J Offline
            J Offline
            john_hobbyist
            wrote on last edited by john_hobbyist
            #18

            The idea is that I have a function embedded to another function. Generally speaking, how can I pass values from the inner function to the outer function?

            jsulmJ 1 Reply Last reply
            0
            • J john_hobbyist

              The idea is that I have a function embedded to another function. Generally speaking, how can I pass values from the inner function to the outer function?

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

              @john_hobbyist said in Get upper left and down right coordinates from zoomed image:

              how can I pass values from the inner function to the outer function?

              By returning them

              def __call__(self):
                  def read_cursor(action):
                      x = read_x
                      y = read_y
                      return (x, y)
              
                  x, y = read_cursor(action)
              

              I still don't understand why you need nested functions...

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

              1 Reply Last reply
              2
              • J Offline
                J Offline
                john_hobbyist
                wrote on last edited by john_hobbyist
                #20

                @jsulm I need to get the returned values when I call the function like this:

                frame.bind("<Button-1>", callback)
                

                So, in the position of

                def read_cursor
                

                put the

                def callback
                

                function

                Please look here: https://web.archive.org/web/20201111211515id_/https://effbot.org/tkinterbook/tkinter-events-and-bindings.htm

                How can I achieve that? I use tkinter auxiliary to PyQt5

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

                  Why are you needing to add tkinter to your Qt application ?

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

                  J 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    Why are you needing to add tkinter to your Qt application ?

                    J Offline
                    J Offline
                    john_hobbyist
                    wrote on last edited by john_hobbyist
                    #22

                    @SGaist I tried qrubberband in the past (https://stackoverflow.com/questions/13840289/how-to-use-qrubberband-with-qrect-class-in-pyqt and https://stackoverflow.com/questions/34220275/how-to-select-a-region-with-qrubberband-on-a-qlabel-like-in-ksnapshot) but it didn't work! Also I need to get coordinates of the corners of the selected area and tkinter is very easy on this...

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      john_hobbyist
                      wrote on last edited by
                      #23
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        john_hobbyist
                        wrote on last edited by john_hobbyist
                        #24

                        Ok, never mind, I solved it 80%. Another point, in the previously mentioned code (https://github.com/Axel-Erfurt/OrthoViewLite/blob/main/OrthoViewLite.py) in which part does the "store image" button be related? I have put "prints" in the entire code, nowhere I see an action on prints, when I zoom in and store the current image...

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          john_hobbyist
                          wrote on last edited by john_hobbyist
                          #25

                          Alternatively, how can I have access to the current image each time that it is depicted? so that when I zoom the image with zoom button to get the current zoomed image and not the initial one that I have loaded when I run the app... I am always referring to the above mentioned github code... Anyone???

                          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