Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[ Enhancement] Add dash line and dotted line for graph element draw_line and draw_lines

Đang mở
#6,604 7 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
desktop

Hướng nghiên cứu

Bắt đầu với các điểm vào draw_line và draw_lines của phần tử Graph cùng hành vi của delete_figure, sau đó chạy ví dụ đường nét đứt được cung cấp. Công việc được xem là hoàn tất khi các phương thức vẽ này hỗ trợ kiểu nét đứt và nét chấm, đồng thời toàn bộ đường đã được tạo kiểu có thể được xóa như một hình duy nhất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement Port - TK
Type of Issue (Enhancement, Error, Bug, Question)

Enhancement


Operating System

Operating System: openSUSE Tumbleweed 20231114
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.112.0
Qt Version: 5.15.11
Kernel Version: 6.6.1-1-default (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 4600H with Radeon Graphics
Memory: 7.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1650 Ti/PCIe/SSE2
Manufacturer: LENOVO
Product Name: 82B5
System Version: Lenovo Legion 5 15ARH05

PySimpleGUI Port (tkinter, Qt, Wx, Web)

Versions

Python version: 3.11.5 (main, Nov 10 2011, 15:00:00) [GCC 13.2.0]
port: tkinter
tkinter version: 8.6.13
PySimpleGUI version: 4.60.5


Your Experience In Months or Years (optional)

1
Years Python programming experience
1
Years Programming experience overall
1
Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
no
Anything else you think would be helpful?


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

From my knowledge, the draw_line and draw_lines graph elements do not have an option to draw a dash line.
I think it would be convenient to have an option similar to Matplotlib.
Something like this

graph.draw_line((x1,y1),(x2,y2),width=3,color='red',linestyle='--')

The code below is my attempt to replicate a dash line.
However, the downside is that I could not delete the whole dash line. The dash line is made of many smaller lines; only the latest small line was deleted.

Code To Duplicate

A short program that isolates and demonstrates the problem (Do not paste your massive program, but instead 10-20 lines that clearly show the problem)

This pre-formatted code block is all set for you to paste in your bit of code:

import PySimpleGUI as sg
import numpy as np

layout = [
    [sg.Graph(canvas_size=(400, 400), graph_bottom_left=(-1, -1), graph_top_right=(1, 1), background_color='white', key='graph', enable_events=True)],
    [sg.Button('Delete Dash Line')]
]

window = sg.Window('Dashed Line Example', layout,finalize=True)

start = (-0.8,-0.6)
end = (0.5,0.7)  

dash_length = 0.05

graph = window['graph']
window_key = 'graph'
def dash_line(window_key,start,end,dash_length):
    slope = (end[1]-start[1])/(end[0]-start[0])
    b = start[1] - slope*start[0]
    for x1 in np.linspace(start[0], end[0],num=10):
        x2 = x1 + dash_length
        y1 = slope*x1+b
        y2 = slope*x2+b  
        id_name = window[window_key].draw_line((x1,y1),(x2,y2),width=3,color='red')
    return id_name

id_name = dash_line(window_key,start,end,dash_length)

# window['graph'].erase()

while True:
    event, values = window.read()
    if event in (sg.WIN_CLOSED, 'Exit'):
        break
    if event == 'Delete Dash Line':
       graph.delete_figure(id_name) 
window.close()
Screenshot, Sketch, or Drawing

Watcha Makin?

If you care to share something about your project, it would be awesome to hear what you're building.
PySimpleCV
https://github.com/kevinsmia1939/PySimpleCV

Ngôn ngữ chính
Python
Star
13.8k
Fork
1.8k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PySimpleGUI/PySimpleGUI

Tất cả issue của PySimpleGUI/PySimpleGUI

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.