小编Jak*_*ria的帖子

滚动 tkinter 树视图时如何移动弹出窗口?

我有一个带有垂直滚动条的 tkinter 树视图。为了使其(看起来)可编辑,当用户双击树视图的单元格时,我创建一个弹出条目。但是,当树视图滚动时,我无法使弹出窗口移动。

import tkinter  as tk
from tkinter import ttk

class EntryPopup(ttk.Entry):
    def __init__(self, parent, itemId, col, **kw):
        super().__init__(parent, **kw)
        self.tv = parent
        self.iId = itemId
        self.column = col
        self['exportselection'] = False

        self.focus_force()
        self.bind("<Return>", self.onReturn)

    def saveEdit(self):
        self.tv.set(self.iId, column=self.column, value=self.get())
        print("EntryPopup::saveEdit---{}".format(self.iId))

    def onReturn(self, event):
        self.tv.focus_set()        
        self.saveEdit()
        self.destroy()


class EditableDataTable(tk.Frame):
    def __init__(self, parent):
        tk.Frame.__init__(self, parent)

        self.parent = parent
        self.tree = None
        self.entryPopup = None
        columns = ("Col1", "Col2")
        # Create a treeview with vertical scrollbar.
        self.tree = ttk.Treeview(self, columns=columns, show="headings") …
Run Code Online (Sandbox Code Playgroud)

python treeview scroll tkinter popupwindow

5
推荐指数
1
解决办法
779
查看次数

标签 统计

popupwindow ×1

python ×1

scroll ×1

tkinter ×1

treeview ×1