Commit cb686033 authored by André Anjos's avatar André Anjos 💬

[widgets] Use scrolledtext to display a better looking help dialog

parent de7487cf
Pipeline #26568 passed with stages
in 12 minutes and 59 seconds
......@@ -5,6 +5,7 @@
import tkinter
import tkinter.ttk
import tkinter.scrolledtext
import warnings
import platform
......@@ -543,21 +544,21 @@ class Tooltip(object):
self.wraplength = wraplength # in pixels, originally 180
self.widget = widget
self.text = text
self.widget.bind("<Enter>", self.onEnter)
self.widget.bind("<Leave>", self.onLeave)
self.widget.bind("<ButtonPress>", self.onLeave)
self.widget.bind("<Enter>", self.on_enter)
self.widget.bind("<Leave>", self.on_leave)
self.widget.bind("<ButtonPress>", self.on_leave)
self.bg = bg
self.pad = pad
self.id = None
self.tw = None
def onEnter(self, event=None):
def on_enter(self, event=None):
self.schedule()
def onLeave(self, event=None):
def on_leave(self, event=None):
self.unschedule()
self.hide()
......@@ -648,7 +649,6 @@ class Tooltip(object):
win.grid()
x, y = tip_pos_calculator(widget, label)
self.tw.wm_geometry("+%d+%d" % (x, y))
......@@ -898,19 +898,14 @@ class HelpDialog(Dialog):
self.title('Help')
# placeholder for the help text
tbox = tkinter.Text(self, width=50, height=70)
tbox.insert(tkinter.INSERT, text) #fill in contents
tbox = tkinter.scrolledtext.ScrolledText(self)
tbox.insert(tkinter.END, text)
tbox.config(state=tkinter.DISABLED)
tbox.focus_set()
tbox.grid(row=0, column=0, sticky=tkinter.NSEW)
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
# scrollbar for the help text
scrollbar = tkinter.ttk.Scrollbar(tbox)
scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
tbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=tbox.yview)
tbox.config(state=tkinter.DISABLED)
# a single dismiss button
btn = tkinter.ttk.Button(self, text ="Dismiss", command=lambda:
self.on_close())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment