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

[Question] - Extending tkinter table to drag rows around

Đang mở
#6,514 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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
20/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
desktop

Hướng nghiên cứu

Payload không nêu tên tệp hoặc bài kiểm thử nào của repository; hãy bắt đầu bằng cách chạy bản tái hiện được cung cấp với sg.Table(..., enable_click_events=True) và vòng lặp window.read() của nó. So sánh hành vi đó với ví dụ kéo và thả bằng tkinter được liên kết, bao gồm cả edge scrolling được yêu cầu. Để được xem là hoàn tất, cần có một cách tiếp cận được xác định và được hỗ trợ cho việc kéo các hàng và cập nhật tabledata khi thả.

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

Mô tả

Port - TK Question

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

Question


Environment

Operating System

Windows version ('7', '6.1.7601', 'SP1', 'Multiprocessor Free')

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter


Versions

Python version (sg.sys.version)

3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)]

PySimpleGUI Version (sg.__version__)

4.61.0.196

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

8.6.9


Your Experience In Months or Years (optional)

Years Python programming experience
Years Programming experience overall
No Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)


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
  • 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
  • Upgraded to the latest official release of PySimpleGUI on PyPI
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released

Detailed Description

I've provided some mock code where I'm using a table and want to drag rows around. I found this code and it works when I just copy over the functions and bindings, but I'm unsure how to get it working with the other code and updating tabledata when the mouse button is released, since PSG's table only generates the click event when mouse is released.

EDIT

Also, I can't get it to scroll up/down when i move up/down to the end of the table, either.

Code To Duplicate
import PySimpleGUI as sg


row_num_clicked = None


menu_def = [
    [
        "File",
        [
            "Open",
            "Save",
            "Exit",
        ],
    ],
    [
        "Edit",
        [
            "Paste",
            "Undo",
        ],
    ],
    ["Help", "About..."],
]

layout0 = [
    [sg.Button(sg.SYMBOL_UP)],
    [sg.Button(sg.SYMBOL_DOWN)],
]

tabledata = [
    ["One", "name1", "loc1"],
    ["Two", "name2", "loc2"],
    ["Three", "name3", "loc3"],
    ["Four", "name4", "loc4"],
    ["Five", "name5", "loc5"],
    ["Six", "name6", "loc6"],
    ["Seven", "name7", "loc7"],
    ["Eight", "name8", "loc8"],
    ["Nine", "name9", "loc9"],
    ["Ten", "name10", "loc10"],
    ["Eleven", "name11", "loc11"],
    ["Twelve", "name12", "loc12"],
    ["Thirteen", "name13", "loc13"],
    ["Fourteen", "name14", "loc14"],
]

layout1 = [
    [
        sg.Table(
            tabledata,
            headings=["Title", "Names", "Locations"],
            enable_click_events=True,
            key="-TABLE-",
            display_row_numbers=True,
            starting_row_number=1,
        ),
        sg.Column(layout0),
    ],
]

layout2 = [
    [sg.Text("Selected: "), sg.Text("None", key="-ROWSELECT-")],
    [sg.Text("Move to:"), sg.Spin([0, 1, 2], initial_value=0)],
]

layout = [
    [
        sg.Titlebar(
            "Playlist Editor",
            background_color="#141417",
            font=(
                "Gill Sans MT",
                18,
            ),
        )
    ],
    [
        sg.MenubarCustom(
            menu_def,
            bar_background_color="#2d2d30",
            bar_font=(
                "Gill Sans MT",
                12,
            ),
            font=(
                "Gill Sans MT",
                12,
            ),
            bar_text_color="#f1f1f1",
            key="-MENUBAR-",
        )
    ],
    [sg.Text("Load a file")],
    [sg.Column(layout1)],
    [sg.Column(layout2), sg.Button("Add entries")],
]

window = sg.Window("Demo", layout, finalize=True)


while True:
    event, values = window.read()
    print(event)
    if event in (sg.WIN_CLOSED, "Exit"):
        break
    if isinstance(event, tuple):
        if event[2][0] != -1 and event[2][0] is not None:
            row_num_clicked = event[2][0]
            window["-ROWSELECT-"].update(row_num_clicked + 1)


window.close()

Screenshot, Sketch, or Drawing
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.