/ lib / python / propertywindow.py
propertywindow.py
 1  #    This is a component of emc2
 2  #    Copyright 2007 Jeff Epler <jepler@unpythonic.net>
 3  #
 4  #    This program is free software; you can redistribute it and/or modify
 5  #    it under the terms of the GNU General Public License as published by
 6  #    the Free Software Foundation; either version 2 of the License, or
 7  #    (at your option) any later version.
 8  #
 9  #    This program is distributed in the hope that it will be useful,
10  #    but WITHOUT ANY WARRANTY; without even the implied warranty of
11  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  #    GNU General Public License for more details.
13  #
14  #    You should have received a copy of the GNU General Public License
15  #    along with this program; if not, write to the Free Software
16  #    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  
18  import Tkinter
19  
20  def properties(app, title, names, props):
21      t = Tkinter.Toplevel(app)
22      t.wm_transient(app)
23      t.wm_title(title)
24      t.wm_iconname(title)
25      t.wm_resizable(0,0)
26       
27      for i, (k, n) in enumerate(names):
28  	if k not in props: continue
29          l = Tkinter.Label(t, text = n)
30          l.grid(row=i, column=0, sticky="nw")
31          l = Tkinter.Label(t, text = props[k], wraplength=200, justify="l")
32          l.grid(row=i, column=1, sticky="nw")
33      
34      b = Tkinter.Button(t, text=_("OK"), command=t.destroy, default="active",
35  		padx=0, pady=0, width=10)
36      b.grid(row=i+1, column=0, columnspan=2) 
37      t.after_idle(b.focus)
38      t.bind("<Escape>", lambda e: t.destroy()) 
39      t.bind("<Return>", lambda e: t.destroy()) 
40      return t
41  
42