Python Forum
mouse move event/cinfiguration ttk/python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mouse move event/cinfiguration ttk/python
#1
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
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.
Reply


Messages In This Thread
mouse move event/cinfiguration ttk/python - by janeik - Jul-03-2023, 02:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python311 tkinter moving mouse event. janeik 1 989 Jul-01-2023, 02:00 PM
Last Post: deanhystad
  python move specific files from source to destination including duplicates mg24 3 1,138 Jan-21-2023, 04:21 AM
Last Post: deanhystad
  python move folders and subfolders not working mg24 5 2,269 Nov-09-2022, 02:24 PM
Last Post: Larz60+
  help with python mouse script z4rxxxx 0 1,159 Jan-15-2022, 04:39 PM
Last Post: z4rxxxx
  Move mouse and click in particular position biprabu 3 2,538 Sep-01-2020, 08:23 PM
Last Post: deanhystad
  Change mouse move speed in guibot script rulltartan 1 2,764 Mar-30-2020, 01:51 PM
Last Post: pevogam
  how difficult its to move to Python 3.8 from Python 2.7 dkirandasari 4 3,241 Jan-23-2020, 07:42 PM
Last Post: DeaD_EyE
  mouse 0.7.0 - mouse polling hate 125-1000hz penahuse 1 2,559 Dec-06-2019, 09:51 PM
Last Post: Larz60+
  Python 3+ kybd and mouse control keycodes ineuw 5 2,963 Aug-20-2019, 07:51 AM
Last Post: ineuw
  How can I move in an external program via Python? Pythoner 0 2,291 Dec-29-2018, 12:43 PM
Last Post: Pythoner

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020