dialog

Jerry 2jerry at writeme.com
Tue Feb 22 18:46:58 EST 2000


Try to make your own dialog box.

import Tkinter
tk=Tkinter
class YourDialog(tk.Toplevel):
  """ Boite d'erreur
  """
  def __init__(s, parent=tk._default_root, titre="erreur",
text="ERRRREUR/OR"):
    tk.Toplevel.__init__(s, parent)
    s.transient(s)
    s.title(titre)
    tk.Message(s,  text=text).pack(side=tk.TOP,fill=tk.X)

    s.bt_retry=tk.Button(s,text='Retry',command=s.retry)
    s.bt_retry.pack(side=tk.LEFT,anchor=tk.S+tk.W)
    s.bt_quit=tk.Button(s,text='Quit',command=s.quit)
    s.bt_quit.pack(side=tk.RIGHT,anchor=tk.S+tk.E)
    # shorter : tk.Button(s, ...).pack()

  def quit(s):
    s.destroy()
    s.parent.destroy() #too ??
  def Retry(s):
    s.destroy()
    s.parent.methode_need_to_br_retry()

# if you don't want to know the name of the methode to retry ... add a
function argument
   pass the callback (retry) trought the constructor then just call
s.callback()
#Better way : return an action id which is properly used by the parent
widget.
  like : return 'Retry'

Jerry the foolish dracomorpheus, jerome VACHER - france -


Stephen Quinney a écrit dans le message
<87900c97bc.fsf at jupiter.pigeon-st>...
>Can anyone either point me in the direction of the full documentation
>on Dialog or solve this trivial problem which is bugging me please?
>
>I have an error dialog box which pops up when something goes wrong, i
>nicked the code from one of Guido's Tkinter demos. I want to bind a
>function to each of the two available buttons, i.e. when the retry
>button is pressed it calls a function retry() and when quit is pressed
>the program quits.
>
>def errordialog(self):
>    Dialog.Dialog(self.root,
>        text = 'This shouldn't happen',
>        title = "Something horrible happened",
>        bitmap = 'error',
>        default = 0,
>        strings = ('Retry','Quit'))
>
>Thanks for any suggestions,
>
>Stephen





More information about the Python-list mailing list