I'm just needing something that can tell if the content in a 1 line text widget is too long, thus needing a horizontal scrollbar.
I have searched questions others have posted and found a solution for a vertical scrollbar, but it sadly doesn't work as accurately with the horizontal.
My solution for vertical:
if self.verse_box.cget('height') < int(self.verse_box.index('end-1c').split('.')[0]):
print "Too many lines"
But if I switch it like so it doesn't work as some characters are smaller and thus can have more fit in the line:
if self.verse_box.cget('width') < int(self.tags_box.index('end-1c').split('.')[1]):
print "This one line is too long"
Any and all advice would be greatly appreciated, thanks! ^-^
On any widget that supports scrolling, you can call the .xview()
or .yview()
method without parameters to get the current start/end fractions of the visible area along that axis. If the entire contents are already visible, this will be the tuple (0.0, 1.0)
. If the returned value is anything else, a scrollbar is needed to see the entire contents.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.