I am working on making something called a PopMsg widget which is
actually identical to a Balloon widget from Pmw. Here is the code:
---code---
from Tkinter import *
import time
class PopMsg:
def showmsg(self, event):
for a in range(10000000) : pass
self.t.deiconif y()
self.t.geometry (str(self.msg.w info_reqwidth() )+'x'+str(self. msg.winfo_reqhe ight())+'+'+str (event.x_root)+ '+'+str(event.y _root))
self.widget.bin d('<Leave>', self.hide)
time.sleep(0.00 1)
def hide(self, event):
self.t.withdraw ()
def __init__(self, parent, widget, text=None):
self.parent=par ent
self.widget=wid get
self.text=text
self.t = Toplevel()
self.t.withdraw ()
self.t.override redirect(1)
self.msg = Message(self.t
, text=self.text
, bg='white'
, border=1
, relief=SOLID
, aspect=250)
self.msg.pack(i padx=10, ipady=5)
self.parent.unb ind('<Enter>')
self.parent.foc us()
self.widget.bin d('<Enter>', self.showmsg)
def printhello():
print 'Hello'
root = Tk()
button = Button(root, text='Hello !', command=printhe llo)
button.pack(pad x=10, pady=10)
p = PopMsg(root, button, text='Some messaging text can go here.')
root.mainloop()
---End Code---
My problem you'll notice is that I tried to put something of a 'delay'
that will allow the popup to show a few seconds after the cursor has
entered the targeted widget's space (in this case the button). That
works ok but I've found that while waiting I can't activate (or
'click') on the button until the PopMsg has shown up. Is there anything
I can do to solve this problem?
thanks,
Harlin Seritt
actually identical to a Balloon widget from Pmw. Here is the code:
---code---
from Tkinter import *
import time
class PopMsg:
def showmsg(self, event):
for a in range(10000000) : pass
self.t.deiconif y()
self.t.geometry (str(self.msg.w info_reqwidth() )+'x'+str(self. msg.winfo_reqhe ight())+'+'+str (event.x_root)+ '+'+str(event.y _root))
self.widget.bin d('<Leave>', self.hide)
time.sleep(0.00 1)
def hide(self, event):
self.t.withdraw ()
def __init__(self, parent, widget, text=None):
self.parent=par ent
self.widget=wid get
self.text=text
self.t = Toplevel()
self.t.withdraw ()
self.t.override redirect(1)
self.msg = Message(self.t
, text=self.text
, bg='white'
, border=1
, relief=SOLID
, aspect=250)
self.msg.pack(i padx=10, ipady=5)
self.parent.unb ind('<Enter>')
self.parent.foc us()
self.widget.bin d('<Enter>', self.showmsg)
def printhello():
print 'Hello'
root = Tk()
button = Button(root, text='Hello !', command=printhe llo)
button.pack(pad x=10, pady=10)
p = PopMsg(root, button, text='Some messaging text can go here.')
root.mainloop()
---End Code---
My problem you'll notice is that I tried to put something of a 'delay'
that will allow the popup to show a few seconds after the cursor has
entered the targeted widget's space (in this case the button). That
works ok but I've found that while waiting I can't activate (or
'click') on the button until the PopMsg has shown up. Is there anything
I can do to solve this problem?
thanks,
Harlin Seritt
Comment