PySimpleGUI / PySimpleGUI/PySimpleGUI
[Enhancement ] Keep graph coordinate system constant after graph element changes in size
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 13.8k
- 派生
- 1.8k
- PR 合并指标
- 30 天内没有已合并 PR
描述
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:
- Run code below
- Confirm graph size is 200x200 in console output
- Move mouse cursor to top right corner: Cursor coordinates will say roughly 200x200
- Resize window to twice the width so that the console output says roughly 400x200
- 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()
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
运行提供的 Python 复现代码,并检查 Graph 元素的 TopRight 属性以及窗口 事件的处理。确认调整大小如何改变图形坐标映射,然后验证将 TopRight 重置为 (200, 200) 后,在水平调整大小之后光标坐标仍保持在该范围内。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- desktop
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 38/100