Jul-03-2023, 02:58 PM
(This post was last modified: Jul-03-2023, 04:06 PM by janeik.
Edit Reason: Mod. notice
)
hello and thank for help given.
I have a goal:
When mousepointer moves,write its coordinates into text field of an allready existing label.
In order to achieve that, I need:
1) a mouse movement event to register movements
2) code to change/config text of an allready existing label
As a nearly beginner in codeing, code should be "stright forward"
re 1: found and understand,this code:
https://stackoverflow.com/questions/2292...on-tkinter
My,so fare, label control:(I probably use frames instead of place, later on.
My 2 questions are:
1) how is this done without creating a new layer, but in the root?
2) I have tried to use configure, its quite convinient using a "helpbutton" to trigger the config. Doing this from an event seemes a bit more difficult,to me.
Which type of configure would You suggest for the above task?
I have read for 4 days without finding any clear answers, mainly howto
configure the text of a label,viewing x and y mouse coordinates, triggered by a moving mouse event.
Any help, hopefully with example code would be greatly appreciated. Thank You.
(I didnt post code in codetags as it probably would break the float of undertanding).
I have a goal:
When mousepointer moves,write its coordinates into text field of an allready existing label.
In order to achieve that, I need:
1) a mouse movement event to register movements
2) code to change/config text of an allready existing label
As a nearly beginner in codeing, code should be "stright forward"
re 1: found and understand,this code:
https://stackoverflow.com/questions/2292...on-tkinter
from textholders import * from tkinter import ttk from tkinter import * import pyautogui import tkinter as tk window = tk.Tk() # window.geometry(f"{1920}x{1200}") window.geometry("1920x1200+0+0") window.minsize(1920, 1200) window.resizable(False, False) window.title("map_view_example.py") window.state("normal") window.title("ROOT") window.config(background="blue") # hwnd = win32gui.GetForegroundWindow() # win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE) inp_posskjerm = tk.Label(window, text ="original txt", font=("Ariel",9,"bold"), justify=("left"), relief="flat").place(x=115,y=277) def motion(event): x, y = event.x, event.y print('{}, {}'.format(x, y)) window.bind('<Motion>', motion) window.mainloop()I should be able to use all but the formatting.
My,so fare, label control:(I probably use frames instead of place, later on.
inp_posskjerm = tk.Label(window, text ="original txt", font=("Ariel",9,"bold"), justify=("left"), relief="flat").place(x=115,y=277)The x and y coordinate above should be input to a label configure function.
My 2 questions are:
1) how is this done without creating a new layer, but in the root?
2) I have tried to use configure, its quite convinient using a "helpbutton" to trigger the config. Doing this from an event seemes a bit more difficult,to me.
Which type of configure would You suggest for the above task?
I have read for 4 days without finding any clear answers, mainly howto
configure the text of a label,viewing x and y mouse coordinates, triggered by a moving mouse event.
Any help, hopefully with example code would be greatly appreciated. Thank You.
(I didnt post code in codetags as it probably would break the float of undertanding).
deanhystad write Jul-03-2023, 03:13 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.