def __init__(self,parent,elements,existing,addCallback,deleteCallback): Frame.__init__(self,parent,relief='groove') self.nameLabel = Label(self,text="Notes: ") self.nameLabel.pack(fill=X,expand=1,side=TOP) self.existingLabel = Label(self,text=existing,relief='sunken',anchor="center") self.existingLabel.pack(fill=X,expand=1,side=TOP) lowerFrame = Frame(self) lowerFrame.pack(fill=BOTH,expand=1,side=BOTTOM) self.dropDown = SuperComboBox(lowerFrame,values=elements,state='readonly') self.dropDown.pack(fill=X,expand=1,side=LEFT) self.addButton = Button(lowerFrame,text="Add",command=addCallback) self.removeButton = Button(lowerFrame,text="Remove",command=deleteCallback) self.addButton.pack(fill=X,expand=1,side=LEFT) self.removeButton.pack(fill=X,expand=1,side=LEFT)
def initUI(self): s = Style() s.configure("ToolTip.TLabel", background="yellow") #frames fMain = Frame(self, borderwidth="2px", relief="groove") fMain.pack(fill=X, expand=1) fHigher = Frame(fMain) fLower = Frame(fMain) fHigher.pack(fill=X, expand=1, side=TOP) fLower.pack(fill=BOTH, expand=1, side=BOTTOM) fHigh_High = Frame(fHigher) self.fHigh_Low = Frame(fHigher) fHigh_High.pack(fill=X, expand=1) fRight = Frame(fHigh_High) fLeft = Frame(fHigh_High) fRight.pack(fill=NONE, side=RIGHT, expand=0) fLeft.pack(side=LEFT, fill=X, expand=1) #elements label = Label(fLeft, text=self.label) label.pack(side=LEFT, fill=BOTH, expand=1) self._calButton = calButton = Button(fLower, text="...", command=self.createCalendar, width=2) calButton.pack(side=RIGHT, fill=X, expand=0) years = range(1979, 2100) self._yearField = SuperComboBox(fLower, values=years, justify=CENTER, state='readonly') self._yearField.pack(side=LEFT, fill=X, expand=1) # months=("January","February","March","April","May","June","July","August", # "September","October","November","December") #months = range(1,13) self.months = months = ("", "January", "February", "March", "April", "May", "June", "July", "August", "Semptember", "October", "November", "December") self._monthField = SuperComboBox(fLower, values=months, justify=CENTER, state='readonly') self._monthField.pack(side=LEFT, fill=X, expand=1) days = range(1, 32) self._dayField = SuperComboBox(fLower, values=days, justify=CENTER, state='readonly') self._dayField.pack(side=LEFT, fill=X, expand=1) self._yearField.set(datetime.datetime.now().year) self._monthField.set(months[datetime.datetime.now().month]) self._dayField.set(datetime.datetime.now().day) #toolTip if self.toolTip: button = Button(fRight, text="?", width=2) button.pack(fill=NONE, expand=0) button.bind("<Enter>", self.hoverHelp) button.bind("<Leave>", self.leaveHelp) self.tooltipLabel = Label(self.fHigh_Low, text=self.toolTip, style="ToolTip.TLabel") self.tooltipLabel.pack(fill=X, expand=1)