Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

[Enhancement ] Keep graph coordinate system constant after graph element changes in size

Aberta
#6,451 6 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
38/100
Tipo de issue
Funcionalidade
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
desktop

Direção de pesquisa

Execute a reprodução em Python fornecida e inspecione a propriedade TopRight do elemento Graph juntamente com o tratamento do evento da janela. Confirme como o redimensionamento altera o mapeamento das coordenadas do gráfico e, em seguida, verifique se redefinir TopRight para (200, 200) mantém as coordenadas do cursor nesse intervalo após um redimensionamento horizontal.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

enhancement Port - TK Question
Question

Operating System

Windows 11

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter


Versions

Python version (sg.sys.version)

3.10.11

PySimpleGUI Version (sg.__version__)

4.60.4

GUI Version (tkinter (sg.tclversion_detailed), PySide2, WxPython, Remi)

8.6.12


Troubleshooting

These items may solve your problem. Please check those you've done by changing - [ ] to - [X]

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demos.PySimpleGUI.org
  • None of your GUI code was generated by an AI algorithm like GPT
  • If not tkinter - looked for Demo Programs for specific port
  • For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
  • Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description

I have a graph element with expand_x=True and expand_y=True and want to keep a constant coordinate system 0 <= x,y <= 200 even after the graph size changes. I set the TopRight attribute to (200, 200) every time the window size changes (configure event). Unfortunately the coordinate system does not respect the new TopRight value and instead scales proportionally with the graph element size.

Steps to reproduce:

  1. Run code below
  2. Confirm graph size is 200x200 in console output
  3. Move mouse cursor to top right corner: Cursor coordinates will say roughly 200x200
  4. Resize window to twice the width so that the console output says roughly 400x200
  5. Move mouse cursor to top right corner: Cursor coordinates will say roughly 400x200

Expected results:

After resizing and explicitly setting TopRight = (200, 200) I would expect the top right cursor coordinates to be 200x200. Instead the top right cursor coordinates are 400x200.

Code To Duplicate

import PySimpleGUI as sg


def main():
    layout = [
        [sg.Graph(canvas_size=(200, 200),
                  graph_bottom_left=(0, 0),
                  graph_top_right=(200, 200),
                  key="-GRAPH-",
                  motion_events=True,
                  enable_events=True,
                  background_color="white",
                  expand_x=True,
                  expand_y=True,
                  drag_submits=True)],
    ]

    window = sg.Window("Window", layout, finalize=True, resizable=True)
    window.bind("<Configure>", "-CONFIGURE-")

    while True:
        event, values = window.read()
        if event == sg.WIN_CLOSED:
            break

        graph = window["-GRAPH-"]

        if event == "-CONFIGURE-":
            print("New graph size:", graph.get_size())
            graph.TopRight = (200, 200)
        elif event == "-GRAPH-+MOVE":
            print("Mouse position:", values["-GRAPH-"])

    window.close()


if __name__ == "__main__":
    main()

Linguagem predominante
Python
Estrelas
13.8k
Forks
1.8k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de PySimpleGUI/PySimpleGUI

Todas as issues de PySimpleGUI/PySimpleGUI

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.