complete software group screen

This commit is contained in:
lizhi-rocky
2010-08-02 16:19:59 +08:00
parent 62e5b2b075
commit 5688e9974b
7 changed files with 109 additions and 214 deletions

View File

@@ -184,24 +184,40 @@ def destroy_top_window(w):
w.tk_widget.destroy()
class SoftwarePackageWindow():
''' Toplevel window for a group of software packages '''
''' Toplevel window for a group of software packages
class member
---------------------------
dict - class static member
---------------------------
instance member
---------------------------
group - data layer group instance
win - Tk widget
selection - StringVar variable for 'select_all'
opt_vars - a list to hold variables containing status for optional packages
opt_chks - a list to hold Checkbuttons for optional packages
'''
dict = {}
def __init__(self, g):
self.group = g
self.optional = []
self.opt_vars = []
self.opt_chks = []
SoftwarePackageWindow.dict[g.name] = self
def select_all(self):
''' callback function for check button select_all '''
self.group.selection = self.selection.get()
print self.group.selection
if self.selection.get() == 'all':
for ck in self.opt_chks:
ck.configure(state='disable')
def ok(self):
''' callback function for button OK '''
self.group.selection = self.selection.get()
for i in range(len(self.group.optional)):
# install field, yes or no
self.group.optional[i][1] = self.optional[i].get()
self.group.optional[i][1] = self.opt_vars[i].get()
self.win.destroy()
def cancel(self):
@@ -241,7 +257,7 @@ class SoftwarePackageWindow():
Tkinter.Label(fr1, text=self.group.mandatory[i]).grid(column=i%5, row=i/5, sticky='NWES')
Tkinter.Label(win, text='Optional').grid(column=0, row=3)
self.selection = Tkinter.StringVar(value="")
self.selection = Tkinter.StringVar(value=self.group.selection)
chk_sa = Tkinter.Checkbutton(win, text='Select all', command=self.select_all, variable=self.selection, onvalue='all', offvalue='manual')
chk_sa.grid(column=1, row=3)
if self.group.selection == 'all':
@@ -270,16 +286,20 @@ class SoftwarePackageWindow():
for i in range(len(self.group.optional)):
name, y_n = self.group.optional[i]
v = Tkinter.StringVar(value='no')
self.optional.append(v)
chk = Tkinter.Checkbutton(fr2, text=name, onvalue='yes', offvalue='no', variable=self.optional[i])
chk.grid(column=i%5, row=i/5, sticky='NWES')
self.opt_vars.append(v)
chk = Tkinter.Checkbutton(fr2, text=name, onvalue='yes', offvalue='no', variable=self.opt_vars[i])
self.opt_chks.append(chk)
chk.grid(column=i%5, row=i/5, sticky='NWS')
if y_n == 'yes':
chk.select()
else:
chk.deselect()
if self.group.selection == 'all':
chk.configure(state='disable')
Tkinter.Button(win, text='OK', command=self.ok).grid(column=0, row=6)
Tkinter.Button(win, text='Cancel', command=self.cancel).grid(column=1, row=6)
Tkinter.Button(win, text='OK', command=self.ok).grid(column=0, row=6, pady=2)
Tkinter.Button(win, text='Cancel', command=self.cancel).grid(column=1, row=6, pady=2)
win.after_idle(lambda : cnv1.configure(scrollregion=(0,0, fr1.winfo_width(), fr1.winfo_height())))
win.after_idle(lambda : cnv2.configure(scrollregion=(0,0, fr2.winfo_width(), fr2.winfo_height())))
@@ -293,5 +313,5 @@ class SoftwarePackageWindow():
pass
else:
break
win.wait_window()