Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After long research I haven't found such feature so I guess there's any. Tk is very simple interface, which allows programmer to build 'high-level' features from the basics. So my desired behaviour this way.</p> <pre><code>def onDoubleClick(self, event): ''' Executed, when a row is double-clicked. Opens read-only EntryPopup above the item's column, so it is possible to select text ''' # close previous popups self.destroyPopups() # what row and column was clicked on rowid = self._tree.identify_row(event.y) column = self._tree.identify_column(event.x) # clicked row parent id parent = self._tree.parent(rowid) # do nothing if item is top-level if parent == '': return # get column position info x,y,width,height = self._tree.bbox(rowid, column) # y-axis offset pady = height // 2 # place Entry popup properly url = self._tree.item(rowid, 'text') self.entryPopup = EntryPopup(self._tree, url) self.entryPopup.place( x=0, y=y+pady, anchor=W, relwidth=1) </code></pre> <p>This is method within a class which composes ttk.Treeview as self._tree</p> <p>And EntryPopup is then very simple sub-class of Entry:</p> <pre><code>class EntryPopup(Entry): def __init__(self, parent, text, **kw): ''' If relwidth is set, then width is ignored ''' super().__init__(parent, **kw) self.insert(0, text) self['state'] = 'readonly' self['readonlybackground'] = 'white' self['selectbackground'] = '#1BA1E2' self['exportselection'] = False self.focus_force() self.bind("&lt;Control-a&gt;", self.selectAll) self.bind("&lt;Escape&gt;", lambda *ignore: self.destroy()) def selectAll(self, *ignore): ''' Set selection on the whole text ''' self.selection_range(0, 'end') # returns 'break' to interrupt default key-bindings return 'break' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload