Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
tkinter.simpledialog.SimpleDialog Class Reference

List of all members.

Public Member Functions

def __init__
def go
def return_event
def wm_delete_window
def done

Public Attributes

 root
 message
 frame
 num
 cancel
 default

Private Member Functions

def _set_transient

Detailed Description

Definition at line 31 of file simpledialog.py.


Constructor & Destructor Documentation

def tkinter.simpledialog.SimpleDialog.__init__ (   self,
  master,
  text = '',
  buttons = [],
  default = None,
  cancel = None,
  title = None,
  class_ = None 
)

Definition at line 35 of file simpledialog.py.

00035 
00036                  title=None, class_=None):
00037         if class_:
00038             self.root = Toplevel(master, class_=class_)
00039         else:
00040             self.root = Toplevel(master)
00041         if title:
00042             self.root.title(title)
00043             self.root.iconname(title)
00044         self.message = Message(self.root, text=text, aspect=400)
00045         self.message.pack(expand=1, fill=BOTH)
00046         self.frame = Frame(self.root)
00047         self.frame.pack()
00048         self.num = default
00049         self.cancel = cancel
00050         self.default = default
00051         self.root.bind('<Return>', self.return_event)
00052         for num in range(len(buttons)):
00053             s = buttons[num]
00054             b = Button(self.frame, text=s,
00055                        command=(lambda self=self, num=num: self.done(num)))
00056             if num == default:
00057                 b.config(relief=RIDGE, borderwidth=8)
00058             b.pack(side=LEFT, fill=BOTH, expand=1)
00059         self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window)
00060         self._set_transient(master)

Here is the caller graph for this function:


Member Function Documentation

def tkinter.simpledialog.SimpleDialog._set_transient (   self,
  master,
  relx = 0.5,
  rely = 0.3 
) [private]

Definition at line 61 of file simpledialog.py.

00061 
00062     def _set_transient(self, master, relx=0.5, rely=0.3):
00063         widget = self.root
00064         widget.withdraw() # Remain invisible while we figure out the geometry
00065         widget.transient(master)
00066         widget.update_idletasks() # Actualize geometry information
00067         if master.winfo_ismapped():
00068             m_width = master.winfo_width()
00069             m_height = master.winfo_height()
00070             m_x = master.winfo_rootx()
00071             m_y = master.winfo_rooty()
00072         else:
00073             m_width = master.winfo_screenwidth()
00074             m_height = master.winfo_screenheight()
00075             m_x = m_y = 0
00076         w_width = widget.winfo_reqwidth()
00077         w_height = widget.winfo_reqheight()
00078         x = m_x + (m_width - w_width) * relx
00079         y = m_y + (m_height - w_height) * rely
00080         if x+w_width > master.winfo_screenwidth():
00081             x = master.winfo_screenwidth() - w_width
00082         elif x < 0:
00083             x = 0
00084         if y+w_height > master.winfo_screenheight():
00085             y = master.winfo_screenheight() - w_height
00086         elif y < 0:
00087             y = 0
00088         widget.geometry("+%d+%d" % (x, y))
00089         widget.deiconify() # Become visible at the desired location

def tkinter.simpledialog.SimpleDialog.done (   self,
  num 
)

Definition at line 109 of file simpledialog.py.

00109 
00110     def done(self, num):
00111         self.num = num
00112         self.root.quit()
00113 

Here is the caller graph for this function:

Definition at line 90 of file simpledialog.py.

00090 
00091     def go(self):
00092         self.root.wait_visibility()
00093         self.root.grab_set()
00094         self.root.mainloop()
00095         self.root.destroy()
00096         return self.num

Definition at line 97 of file simpledialog.py.

00097 
00098     def return_event(self, event):
00099         if self.default is None:
00100             self.root.bell()
00101         else:
00102             self.done(self.default)

Here is the call graph for this function:

Definition at line 103 of file simpledialog.py.

00103 
00104     def wm_delete_window(self):
00105         if self.cancel is None:
00106             self.root.bell()
00107         else:
00108             self.done(self.cancel)

Here is the call graph for this function:


Member Data Documentation

Definition at line 48 of file simpledialog.py.

Definition at line 49 of file simpledialog.py.

Definition at line 45 of file simpledialog.py.

Definition at line 43 of file simpledialog.py.

Definition at line 47 of file simpledialog.py.

Definition at line 37 of file simpledialog.py.


The documentation for this class was generated from the following file: