Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 import sys
00032 import os
00033 import time
00034
00035 from Tkinter import *
00036 from Tkconstants import *
00037 from tkFileDialog import *
00038 import tkFont
00039
00040 from hekateros_control.Utils import *
00041
00042
00043
00044
00045
00046 class WarnDlg(Toplevel):
00047
00048
00049
00050
00051
00052
00053 def __init__(self, master=None, cnf={}, **kw):
00054
00055 kw = self.initData(kw)
00056
00057 Toplevel.__init__(self, master=master, cnf=cnf, **kw)
00058 self.title(self.m_title)
00059
00060
00061 self.createWidgets()
00062
00063
00064 self.m_bttnCancel.bind('<KeyPress-Return>', func=self.close)
00065
00066
00067 if master is not None:
00068 self.update_idletasks()
00069 x0 = master.winfo_rootx()
00070 y0 = master.winfo_rooty()
00071 xp = x0 + (master.winfo_width() - self.winfo_width()) / 2 - 8
00072 yp = y0 + (master.winfo_height() - self.winfo_height()) / 2 - 20
00073 glist = [self.winfo_width(), self.winfo_height(), xp, yp]
00074
00075 self.geometry('{0}x{1}+{2}+{3}'.format(*glist))
00076
00077
00078
00079 self.protocol("WM_DELETE_WINDOW", self.close)
00080
00081
00082
00083
00084
00085 self.focus_set()
00086
00087
00088 self.grab_set()
00089
00090
00091 self.transient(master)
00092
00093
00094 self.wait_window(self)
00095
00096
00097
00098
00099
00100
00101
00102
00103 def initData(self, kw):
00104 self.m_icons = {}
00105 imageLoader = ImageLoader(py_pkg='hekateros_control.images')
00106 if kw.has_key('title'):
00107 self.m_title = kw['title']
00108 del kw['title']
00109 else:
00110 self.m_title = "Warning"
00111 if kw.has_key('image'):
00112 self.m_icons['image'] = imageLoader.load(kw['image'])
00113 del kw['image']
00114 else:
00115 self.m_icons['image'] = None
00116 if self.m_icons['image'] is None:
00117 self.m_icons['image'] = imageLoader.load('icons/icon_warning.png')
00118 if kw.has_key('msg'):
00119 self.m_msg = kw['msg']
00120 del kw['msg']
00121 else:
00122 self.m_msg = "Warn what???"
00123 self.m_result = False
00124 return kw
00125
00126
00127
00128
00129 def createWidgets(self):
00130 frame = Frame(self)
00131 frame.grid(row=0, column=0)
00132
00133
00134 w = Label(frame)
00135 if self.m_icons['image'] is not None:
00136 w = Label(frame)
00137 w['image'] = self.m_icons['image']
00138 w['anchor'] = CENTER
00139 w.grid(row=0, column=0, rowspan=2, sticky=W+N+S)
00140
00141
00142 w = Label(frame)
00143 helv = tkFont.Font(family="Helvetica",size=24,weight="bold")
00144 w['font'] = helv
00145 w['text'] = 'Warning'
00146 w['anchor'] = CENTER
00147 w.grid(row=0, column=1, sticky=E+W)
00148
00149 row = 1
00150
00151
00152 w = Label(frame)
00153 w['text'] = self.m_msg
00154 w['anchor'] = W
00155 w['justify'] = LEFT
00156 w.grid(row=row, column=1, padx=5, sticky=E+W)
00157
00158 row += 1
00159
00160 wframe = Frame(frame)
00161 wframe.grid(row=row, column=1)
00162
00163
00164 w = Button(wframe, width=10, text='Cancel', command=self.close)
00165 w.grid(row=0, column=0, padx=2, pady=5)
00166 w['anchor'] = CENTER
00167 self.m_bttnCancel = w
00168
00169
00170 w = Button(wframe, width=10, text='Continue', command=self.ok)
00171 w.grid(row=0, column=1, padx=2, pady=5)
00172 w['anchor'] = CENTER
00173 self.m_bttnContinue = w
00174
00175
00176
00177
00178 def ok(self):
00179 self.m_result = True
00180 self.close()
00181
00182
00183
00184
00185 def close(self):
00186 self.destroy()