Skip to content

enabling drag_submits enables mouse_drags, but disables mouse_up events #1738

@finlay-mcwalter

Description

@finlay-mcwalter

Type of Issues (Enhancement, Error, Bug, Question)

Bug

Operating System

Ubuntu linux 19.04 (kernel 5.0.0-21) x86_64

Python version

3.7.3

PySimpleGUI Port and Version

Tk
4.0.0

Code or partial code causing the problem

enabling drag_submits on a graph stops it from receiving mouse button up events - set drag_submits False in the attached code and see the mouse up events, set it True and they're not reported. Sometimes a TIMEOUT is reported instead, but in practical examples that's not consistent. I'm using this to implement a rubber-rect drawing (with PIL in the background for double-buffering) but without reliable mouse_up, one can't know when one is done rubberbanding.

#!/usr/bin/python3

import PySimpleGUI as sg
    
layout = [
    [
        sg.Graph(
            canvas_size=(400, 400),
            graph_bottom_left=(0, 400),
            graph_top_right=(400, 0),
            key="graph",
            change_submits=True,

            # enabling drag_submits enables mouse_drags, but disables mouse_up events
            drag_submits=True 
        )
    ]
]

window = sg.Window("mouse events", layout)
window.Finalize()

graph = window.Element("graph")


while True:
    event, values = window.Read()
    if event is None:
        break # exit

    if event == "graph":
        x,y = values["graph"]
        if x is None:
            print ("UP")
        else:
            print (f"DOWN {values['graph']}")
    
    else:
        print(event, values)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions