Get upper left and down right coordinates from zoomed image
-
Hello, I use this code: https://github.com/Axel-Erfurt/OrthoViewLite/blob/main/OrthoViewLite.py When I choose an image and then I zoom in, how can I get the coordinates of each corner of the zoomed image, printed in terminal (and stored in variables)?
-
Is it so difficult what I am asking?
-
Hi,
Please show some patience and allow at least 24 hours before bumping your own thread. This is a voluntary driven forum and people may not live in the same time zone as you.
As for your question, you might want to consider providing more information. What you do here is to tell people to go read an entire Python script, understand what it does, find where the zoom happens, understand how the zoom is applied, and then possibly answer your question. Do you really think that this is something motivating ?
-
Ok, I managed to write some code, that seems to work. However, I am thinking of putting a button(icon) on the right side of the right series of buttons that exist in the APP. The idea is to put an icon with a very small image that would change to another image when the button is pressed on/off ( like a switch) . I am trying to combine this:
select_btn = QAction("Select area on image")with this:
https://stackoverflow.com/questions/44453268/creating-custom-pyqt5-image-button
This is very general: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QIcon.html
Any ideas??
-
From memory, make your button checkable and use the On and Off state of QIcon to show your different images.
-
Ok, I searching it. The code that I want to execute when I "switch on" the button icon has methods defined inside. How can I handle this situation? I mean: I attached the "method2" obviously when the button is pressed (switch on):
button2 = QAction("area selection", self, triggered=self.method2)but: can inside method2 define other methods?
def method2(): def do_this(): . . . def do_that(): . . . -
Ok, I searching it. The code that I want to execute when I "switch on" the button icon has methods defined inside. How can I handle this situation? I mean: I attached the "method2" obviously when the button is pressed (switch on):
button2 = QAction("area selection", self, triggered=self.method2)but: can inside method2 define other methods?
def method2(): def do_this(): . . . def do_that(): . . .@john_hobbyist said in Get upper left and down right coordinates from zoomed image:
can inside method2 define other methods?
Why do you want to define functions inside a method?
-
@john_hobbyist said in Get upper left and down right coordinates from zoomed image:
can inside method2 define other methods?
Why do you want to define functions inside a method?
@jsulm I wrote the code for area selection alone to see if it works, outside the main program, in a different file. But now I need to include it to the main PyQt5 code in order to make it run when I switch on the button. Do you have a better suggestion?
-
@jsulm I wrote the code for area selection alone to see if it works, outside the main program, in a different file. But now I need to include it to the main PyQt5 code in order to make it run when I switch on the button. Do you have a better suggestion?
@john_hobbyist said in Get upper left and down right coordinates from zoomed image:
I wrote the code for area selection alone to see if it works, outside the main program, in a different file. But now I need to include it to the main PyQt5 code in order to make it run when I switch on the button. Do you have a better suggestion?
This does not explain at all why you think you need to define functions inside a method. Why don't you define those functions as normal methods in the same class?
-
@john_hobbyist said in Get upper left and down right coordinates from zoomed image:
I wrote the code for area selection alone to see if it works, outside the main program, in a different file. But now I need to include it to the main PyQt5 code in order to make it run when I switch on the button. Do you have a better suggestion?
This does not explain at all why you think you need to define functions inside a method. Why don't you define those functions as normal methods in the same class?
@jsulm I find it more easy to program it with methods.
So the idea is that I call a "method_1" when the button is pressed. This "method_1" calls an instance of the "class_1". "Class_1" includes the code for area selection. The problem is that when I run the pyqt5 code , only the "class_1" is executed!!! -
@jsulm I find it more easy to program it with methods.
So the idea is that I call a "method_1" when the button is pressed. This "method_1" calls an instance of the "class_1". "Class_1" includes the code for area selection. The problem is that when I run the pyqt5 code , only the "class_1" is executed!!!@john_hobbyist said in Get upper left and down right coordinates from zoomed image:
This "method_1" calls an instance of the "class_1"
How is this related to functions inside a method?!
If you want to call a method on a class then you need an instance of that class. -
@john_hobbyist said in Get upper left and down right coordinates from zoomed image:
This "method_1" calls an instance of the "class_1"
How is this related to functions inside a method?!
If you want to call a method on a class then you need an instance of that class.This post is deleted! -
This post is deleted!
-
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??
-
You should provide a minimal runnable script that shows what you want to do with that piece of code.
-
My code above is very simple. I need only to update x, y values (#step1), if someone can help me...
-
Your code is incomplete and without context.
It does not allow to understand the logic you want to implement. -
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?
-
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?
@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...
-
@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_cursorput the
def callbackfunction
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