def band_options(self, *args): """ method to change displayed band price when a band is selected in combobox, also changes to band cost value """ bandPrice = CONST.BANDS.get(self.bandNameCombobox.get()) if bandPrice: self.bandChose.set(mc.pound_string(bandPrice)) self.bandCost = bandPrice else: self.bandCost = 0 self.bandChose.set(mc.pound_string(0))
def band_options(self, *args): """method to change the bandcost being display and the background band price being stored when the user selects an option in the band combobox""" bandPrice = CONST.BANDS.get(self.bandName.get()) print(bandPrice) if bandPrice: self.bandCost.set(mc.pound_string(bandPrice)) self.bandPrice = bandPrice else: self.bandCost.set(mc.pound_string(0)) self.bandPrice = 0 print('band price {}'.format(self.bandPrice))
def __init__(self, master, event): super().__init__(master, event) self.master = master self.event = event # vars self.roomNumbers = CONST.PARTY_ROOMS self.bandOptions = list(CONST.BANDS.keys()) self.bandChose = StringVar(self.master, mc.pound_string(event.bandPrice)) self.bandVariable = StringVar() self.bandCost = 0 # window configure self.master.title('Update Party') self.title.configure(text='Update Party') # overriding super room numbers self.roomNoCombo.configure(values=self.roomNumbers) # overriding super date of event entry widget bind events self.dateOfEventValue.trace('w', lambda name, index, mode: self.freeBands(list(CONST.BANDS.keys()), 'party')) self.dateOfEventValue.trace('w', lambda name, index, mode: self.freeRooms(CONST.PARTY_ROOMS, 'party')) # if type of event is party then select room booked on create from roomNumber list if type(event) == Party: self.roomNoCombo.current(self.roomNumbers.index(self.event.eventRoomNo)) # widgets for selecting a band self.bandNameLbl = Label(self.master, text="Select Band:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.bandNameCombobox = ttk.Combobox(self.master, values=self.bandOptions, state='readonly', postcommand=self.band_options, textvariable=self.bandVariable) self.bandNameCombobox.current(self.bandOptions.index(self.event.bandName)) self.bandNameCombobox.bind('<<ComboboxSelected>>', self.band_options) self.bandCostLbl = Label(self.master, text="Band Cost:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.bandCostDisplay = Label(self.master, font=style.textNormal, textvariable=self.bandChose, anchor=W, width=20, bg=style.widgetBG) # grid layout for widgets self.bandNameLbl.grid(row=10, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.bandNameCombobox.grid(row=10, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.bandCostLbl.grid(row=11, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.bandCostDisplay.grid(row=11, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) # if event is a type of party then check for free bands and rooms for party if type(self.event) == Party: self.freeBands(list(CONST.BANDS.keys()), 'party') self.freeRooms(CONST.PARTY_ROOMS, 'party') self.band_options()
def CostBreakDownUI(master, booking): """function creates the UI for the cost breakdown section on the invoice Section of the window""" # widgets for invoice form CostBreakHeading = Label(master, text='Cost Break Down', font=style.textHeading, bg=style.widgetBG) totalExVATLabel = Label(master, text='Total ex VAT:', font=style.textNormal, bg=style.widgetBG) totalExVATInfo = Label(master, text=mc.pound_string(booking.subTotal()), font=style.textNormal, bg=style.widgetBG) VATTotalLabel = Label(master, text='VAT:', font=style.textNormal, bg=style.widgetBG) VATTotalInfo = Label(master, text=mc.pound_string(booking.VAT()), font=style.textNormal, bg=style.widgetBG) TotalLabel = Label(master, text='Total:', font=style.textNormal, bg=style.widgetBG) TotalInfo = Label(master, text=mc.pound_string(booking.total()), font=style.textNormal, bg=style.widgetBG) # grid layout for widgets CostBreakHeading.grid(row=20, column=0, columnspan=2, sticky=NSEW, padx=style.paddingX, pady=style.paddingY) totalExVATLabel.grid(row=21, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) totalExVATInfo.grid(row=21, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) VATTotalLabel.grid(row=22, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) VATTotalInfo.grid(row=22, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) TotalLabel.grid(row=23, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) TotalInfo.grid(row=23, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY)
def __init__(self, master): super().__init__(master) # overriding super room number options self.roomNumbers = CONST.WEDDING_ROOMS self.roomNoCombo.configure(values=self.roomNumbers) self.costPerHeadDisplay.configure( text=mc.pound_string(CONST.EVENT_COST_PER_HEAD.get('Wedding'))) # removing trace callbacks inherited from parent class for ti in self.dateOfEventValue.trace_vinfo(): self.dateOfEventValue.trace_vdelete(*ti) # adding trace calls to date of event self.dateOfEventValue.trace( 'w', lambda name, index, mode: self.freeBands( list(CONST.BANDS.keys()), 'wedding')) self.dateOfEventValue.trace( 'w', lambda name, index, mode: self.freeRooms( CONST.WEDDING_ROOMS, 'wedding')) # widgets for number of rooms self.noOfRoomsLbl = Label(self.master, text="Number of Rooms:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.noOfRoomsEntry = Entry(self.master, font=style.textNormal, validate='key') self.noOfRoomsEntry.configure(validatecommand=( self.noOfRoomsEntry.register(validation.NumbersOnly), '%S', '%d')) # grid layout for widgets self.noOfRoomsLbl.grid(row=12, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.noOfRoomsEntry.grid(row=12, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY)
def __init__(self, master, event): super().__init__(master, event) # overriding default heading self.Heading.configure(text='View Details Party') self.buttonInvoice.configure(command=lambda: ig.party_invoice(self.event)) # labels for Band Selected self.bandSelectedTitle = Label(self.master, text='Band Selected:', font=style.textNormal, bg=style.widgetBG) self.bandSelectedInfo = Label(self.master, text=event.bandName, font=style.textNormal, bg=style.widgetBG) # labels for band cost self.bandCostTitle = Label(self.master, text='Band Cost:', font=style.textNormal, bg=style.widgetBG) self.bandCostInfo = Label(self.master, text=mc.pound_string(event.bandPrice), font=style.textNormal, bg=style.widgetBG) # layout for labels self.bandSelectedTitle.grid(row=8, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.bandSelectedInfo.grid(row=8, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.bandCostTitle.grid(row=9, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.bandCostInfo.grid(row=9, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY)
def search_Total(self): """function to get the total income of bookings made between two dates""" # checks entries are not empty and at least one check box is selected if validation.EntriesNotEmpty(self.master) and self.checkbox_checked(): db = DBAccess() selectedTables = [] # Gets data from the database from all 3 tables if self.conferenceCheck.get(): selectedTables.append('Conference') if self.partyCheck.get(): selectedTables.append('party') if self.weddingCheck.get(): selectedTables.append('Wedding') # passes search criteria to a data access function to get results results = db.bookings_between_dates(selectedTables, self.dateFromDatePick.get(), self.dateToDatePick.get()) total = 0 for result in results: total += result.total() # Adds the results together self.totalIncomeInfo['text'] = mc.pound_string(total) # converts to pound sterling else: dialogs.no_search_criteria(self.master) # Returns warning to user if no search criteria entered
def party_invoice(party): """This function merges the values that we want into the mail merge place holders on the invoice template""" PartyTemplatePath = "invoice_templates\\Party_template.docx" doc = MailMerge(PartyTemplatePath) doc.merge(name=party.nameofContact, address=party.address, contactNumber=party.contactNo, dateCreated='{:%Y-%m-%d}'.format(datetime.now().today()), dateOfBooking=party.dateOfBooking.strftime('%Y-%m-%d'), dateOfEvent=party.dateOfEvent.strftime('%Y-%m-%d'), bandName=party.bandName, bandPrice=mc.pound_string(party.bandPrice), roomNumber=party.eventRoomNo, costPerHead=mc.pound_string(party.costPerhead), numberOfGuests=str(party.noGuests), costPerHeadTotal=mc.pound_string(party.costPerHeadTotal()), subTotal=mc.pound_string(party.subTotal()), VAT=mc.pound_string(party.VAT()), total=mc.pound_string(party.total())) save_file(doc) # saves document
def Conference_Invoice(Conference): """This function merges the values that we want into the mail merge place holders on the invoice template""" ConferenceTemplatePath = "invoice_templates\\Conference_template.docx" doc = MailMerge(ConferenceTemplatePath) doc.merge( dateCreated='{:%Y-%m-%d}'.format(datetime.now().today()), companyName=str(Conference.companyName), name=str(Conference.nameofContact), address=str(Conference.address), contactNumber=str(Conference.contactNo), dateOfBooking=Conference.dateOfBooking.strftime('%Y-%m-%d'), dateOfEvent=Conference.dateOfEvent.strftime('%Y-%m-%d'), numberOfDays=str(Conference.noOfDays), projectorRequired='Yes' if Conference.projectorRequired else 'No', roomNumber=str(Conference.eventRoomNo), numberOfGuests=str(Conference.noGuests), costPerHead=mc.pound_string(Conference.costPerhead), priceForAllDays=mc.pound_string(Conference.subTotal()), subTotal=mc.pound_string(Conference.subTotal()), VAT=mc.pound_string(Conference.VAT()), total=mc.pound_string(Conference.total()), PricePerDay=mc.pound_string(Conference.PricePerDay())) save_file(doc) # saves document
def __init__(self, master, event): self.master = master self.master.resizable(0, 0) self.master.iconbitmap(str(style.logo)) self.event = event # window configure self.master.title('View Details') self.master.configure(bg=style.widgetBG) # setting text formatting vars and padding vars # labels for form # heading label is given text value by child classes self.Heading = Label(self.master, text='heading', font=style.textHeading, bg=style.widgetBG) # Number of Guests labels self.noGuestsTitle = Label(self.master, text='Number of Guests:', font=style.textNormal, bg=style.widgetBG) self.noGuestsInfo = Label(self.master, text=event.noGuests, font=style.textNormal, bg=style.widgetBG) # Name of Contact Labels self.nameContactTitle = Label(self.master, text='Name of Contact:', font=style.textNormal, bg=style.widgetBG) self.nameContactInfo = Label(self.master, text=event.nameofContact, font=style.textNormal, bg=style.widgetBG) # Address Labels self.addressTitle = Label(self.master, text='Full Address of Contact:', font=style.textNormal, bg=style.widgetBG) self.addressInfo = Label(self.master, text=event.address, font=style.textNormal, bg=style.widgetBG) # Contact Number Labels self.contactNumberTitle = Label(self.master, text='Contact Number:', font=style.textNormal, bg=style.widgetBG) self.contactNumberInfo = Label(self.master, text=event.contactNo, font=style.textNormal, bg=style.widgetBG) # Event Room Number Label self.roomNumberTitle = Label(self.master, text='Event Room Number:', font=style.textNormal, bg=style.widgetBG) self.roomNumberInfo = Label(self.master, text=event.eventRoomNo, font=style.textNormal, bg=style.widgetBG) # Date of Booking Labels self.dateOfBookingTitle = Label(self.master, text='Date of Booking:', font=style.textNormal, bg=style.widgetBG) self.dateOfBookingInfo = Label(self.master, text=event.dateOfBooking, font=style.textNormal, bg=style.widgetBG) # Date of Event Labels self.dateOfEventTitle = Label(self.master, text='Date of Event', font=style.textNormal, bg=style.widgetBG) self.dateOfEventInfo = Label(self.master, text=event.dateOfEvent, font=style.textNormal, bg=style.widgetBG) # cost per head labels self.costPerHeadTitle = Label(self.master, text='Cost Per Head:', font=style.textNormal, bg=style.widgetBG) self.costPerHeadInfo = Label(self.master, text=mc.pound_string(event.costPerhead), font=style.textNormal, bg=style.widgetBG) # frame for packing buttons at bottom of form self.buttonFrame = Frame(self.master, bg=style.widgetBG) # buttons # these buttons are user on each child class and should be placed at the bottom self.buttonBack = Button(self.buttonFrame, text='Back', font=style.textNormal, bg=style.buttonColour1, width=style.buttonWidth , height=style.buttonHeight, command=self.master.destroy) self.buttonInvoice = Button(self.buttonFrame, text='Save Invoice', font=style.textNormal, bg=style.buttonColour2, width=style.buttonWidth, height=style.buttonHeight) # placing widgets on grid layout # placing heading title self.Heading.grid(row=0, column=0, columnspan=2, sticky=NSEW, padx=style.paddingX, pady=style.paddingY) # placing Title and Info labels for each of the Event details self.noGuestsTitle.grid(row=1, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.noGuestsInfo.grid(row=1, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.nameContactTitle.grid(row=2, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.nameContactInfo.grid(row=2, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.addressTitle.grid(row=3, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.addressInfo.grid(row=3, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.contactNumberTitle.grid(row=4, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.contactNumberInfo.grid(row=4, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.roomNumberTitle.grid(row=5, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.roomNumberInfo.grid(row=5, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.dateOfBookingTitle.grid(row=6, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.dateOfBookingInfo.grid(row=6, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.dateOfEventTitle.grid(row=7, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.dateOfEventInfo.grid(row=7, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.costPerHeadTitle.grid(row=19, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.costPerHeadInfo.grid(row=19, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) CostBreakDownUI(self.master, self.event) self.buttonFrame.grid(row=24, column=0, columnspan=2) self.buttonBack.pack(side=LEFT, padx=style.paddingX, pady=style.paddingY) self.buttonInvoice.pack(side=LEFT, padx=style.paddingX, pady=style.paddingY)
def __init__(self, master, event): self.master = master self.master.resizable(0, 0) self.master.iconbitmap(str(style.logo)) self.event = event # rooms combobox string for default option self.roomComboText = StringVar() # bool to track if room number selected self.roomSelected = False # string to track value of date of event self.dateOfEventValue = StringVar(self.master, self.event.dateOfEvent) # configure master self.master.configure(background=style.windowBG) self.roomNumbers = ['select option'] # widgets # form title self.title = Label(self.master, text='Heading', font=style.textHeading, height=2, bg=style.widgetBG) # number of guests widgets self.noGuestsLbl = Label(self.master, text="Number of Guests:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.noGuestsEntry = Entry(self.master, validate='key') self.noGuestsEntry.configure(validatecommand=(self.noGuestsEntry.register(validation.NumbersOnly), '%S', '%d')) self.noGuestsEntry.insert(0, event.noGuests) # name of contact widgets self.nameOfContactLbl = Label(self.master, text="Name of Contact:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.nameOfContactEntry = Entry(self.master, validate='key') self.nameOfContactEntry.configure(validatecommand=(self.nameOfContactEntry.register( lambda S, P, d, parent=self.master: validation.lettersOnly(S, P, d, parent)), '%S', '%P', '%d')) self.nameOfContactEntry.insert(0, event.nameofContact) # address widgets self.addressLbl = Label(self.master, text="Full Address of Contact:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.addressEntry = Entry(self.master, validate='key') self.addressEntry.configure( validatecommand=(self.addressEntry.register( lambda S, P, d, parent=self.master: validation.check_address(S, P, d, parent)), '%S', '%P', '%d')) self.addressEntry.insert(0, event.address) # contact number widgets self.contactNumberLbl = Label(self.master, text="Contact Number:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.contactNumberEntry = Entry(self.master, validate='key') self.contactNumberEntry['validatecommand'] = (self.contactNumberEntry.register( lambda S, P, d, i, parent=self.master: validation.ValidatePhoneNumber(S, P, d, i, parent)), '%S', '%P', '%d', '%i') self.contactNumberEntry.insert(0, event.contactNo) # room number widgets self.roomNoLbl = Label(self.master, text="Event Room Number:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.roomNoCombo = ttk.Combobox(self.master, value=self.roomNumbers, state='readonly', textvariable=self.roomComboText) self.roomNoCombo.bind('<<ComboboxSelected>>', self.room_pick) # date of event widgets self.dateOfEventLbl = Label(self.master, text="Date of Event:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.dateOfEventEntry = Entry(self.master, textvariable=self.dateOfEventValue) self.dateOfEventEntry.configure(disabledbackground="white", disabledforeground="black") self.dateOfEventEntry.configure(state='readonly') # if date of event can only be changed if date not in the pasted if not self.event.dateOfEvent < datetime.datetime.now().date(): self.dateOfEventEntry.bind('<Button-1>', lambda e: tlf.calendar_popup(e, self.master, self.dateOfEventValue, self.dateOfEventValue.get())) # cost per head widgets self.costPerHeadLbl = Label(self.master, text="Cost Per Head:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.costPerHeadDisplay = Label(self.master, font=style.textNormal, anchor=W, width=20, text=mc.pound_string(self.event.costPerhead), bg=style.widgetBG) # frame for buttons self.frame = Frame(self.master, bg=style.widgetBG) # buttons for bottom of form self.buttonBack = Button(self.frame, text='Back', bg='snow', width=style.buttonWidth, height=style.buttonHeight, command=self.master.destroy) self.buttonDelete = Button(self.frame, text='Delete', bg=style.buttonColour1, width=style.buttonWidth, height=style.buttonHeight, command=self.delete_booking) self.buttonSave = Button(self.frame, text='Save', bg=style.buttonColour2, width=style.buttonWidth, height=style.buttonHeight, command=self.update_booking) # layout for widget self.title.grid(columnspan=5) self.noGuestsLbl.grid(row=1, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.noGuestsEntry.grid(row=1, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.nameOfContactLbl.grid(row=2, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.nameOfContactEntry.grid(row=2, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.addressLbl.grid(row=3, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.addressEntry.grid(row=3, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.contactNumberLbl.grid(row=4, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.contactNumberEntry.grid(row=4, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.roomNoLbl.grid(row=5, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.roomNoCombo.grid(row=5, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.dateOfEventLbl.grid(row=6, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.dateOfEventEntry.grid(row=6, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.costPerHeadLbl.grid(row=100, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.costPerHeadDisplay.grid(row=100, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.frame.grid(row=101, columnspan=2) self.buttonBack.pack(side=LEFT, padx=style.paddingX, pady=style.paddingY) self.buttonDelete.pack(side=LEFT, padx=style.paddingX, pady=style.paddingY) self.buttonSave.pack(side=LEFT, padx=style.paddingX, pady=style.paddingY)
def __init__(self, master): super().__init__(master) self.master = master # overriding parent values # overriding room number configuration from parent class and cost per head self.roomNumbers = CONST.PARTY_ROOMS self.roomNoCombo.configure(values=self.roomNumbers) self.costPerHeadDisplay.configure( text=mc.pound_string(CONST.EVENT_COST_PER_HEAD.get('Party'))) # overriding super date of event entry widget bind events self.dateOfEventValue.trace( 'w', lambda name, index, mode: self.freeBands( list(CONST.BANDS.keys()), 'party')) self.dateOfEventValue.trace( 'w', lambda name, index, mode: self.freeRooms( CONST.PARTY_ROOMS, 'party')) # party class variables # variable used as textVariable for band cost display label self.bandCost = StringVar(self.master, mc.pound_string(0)) self.bandOptions = list(CONST.BANDS.keys( )) # setting band options using a list of keys in band dictionary # variable used to show default option in band combobox self.bandSelected = StringVar(self.master, 'Please select a Band') self.bandPrice = 0 # widgets for party class # band selecting widgets self.bandNameLbl = Label(self.master, text="Select Band:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.bandName = ttk.Combobox(self.master, values=self.bandOptions, state='readonly', textvariable=self.bandSelected) self.bandName.bind('<<ComboboxSelected>>', self.band_options) self.bandCostLbl = Label(self.master, text="Band Cost:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.bandCostDisplay = Label(self.master, font=style.textNormal, textvariable=self.bandCost, anchor=W, width=20, bg=style.widgetBG) # grid layout for widgets self.bandNameLbl.grid(row=10, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.bandName.grid(row=10, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.bandCostLbl.grid(row=11, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.bandCostDisplay.grid(row=11, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY)
def __init__(self, master): self.master = master super().__init__(master) # overriding room number configuration from parent class self.roomNumbers = CONST.CONFERENCE_ROOMS self.roomNoCombo.configure(values=self.roomNumbers) # adding trace to date of event text variable self.dateOfEventValue.trace( 'w', lambda name, index, mode: self.conference_room_check(event=NONE)) # cost per head showing cost per head for conference self.costPerHeadDisplay.configure( text=mc.pound_string(CONST.EVENT_COST_PER_HEAD.get('Conference'))) self.projectorRequired = BooleanVar( ) # boolean to track state of projector required checkButton # widgets for conference class # company name widgets self.companyLbl = Label(self.master, text="Company Name:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.companyEntry = Entry(self.master, font=style.textNormal, validate='key') self.companyEntry.configure( validatecommand=(self.companyEntry.register(validation.char_limit), '%P', 100)) # number of days widgets self.noOfDaysLbl = Label(self.master, text="Number of Days:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.noOfDaysValue = StringVar( ) # variable to store string value in noOfDaysEntry used to add trace self.noOfDaysEntry = Entry(self.master, validate='key', textvariable=self.noOfDaysValue) self.noOfDaysEntry.configure(validatecommand=( self.noOfDaysEntry.register(validation.NumbersOnly), '%S', '%d', '%P', 50)) self.noOfDaysValue.trace( 'w', lambda name, index, mode: self.conference_room_check(event=None)) # projector required widgets self.projectorLbl = Label(self.master, text="Projector Required?:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.projectorCheck = Checkbutton(self.master, text="Tick for yes", variable=self.projectorRequired, bg=style.widgetBG, font=style.textNormal) # layout for from self.companyLbl.grid(row=10, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.companyEntry.grid(row=10, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.noOfDaysLbl.grid(row=11, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.noOfDaysEntry.grid(row=11, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.projectorLbl.grid(row=12, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.projectorCheck.grid(row=12, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY)
def __init__(self, master): self.master = master # variables self.roomNumbers = [ ] # list stores room numbers for room number combobox # text variable for room combobox used to show default value self.roomComboText = StringVar(self.master, 'Please select a Room') self.roomSelected = False # boolean tracks if a room has been selected in the room combobox # user as text variable to store date selected from calendar widget and run trace callbacks self.dateOfEventValue = StringVar(self.master) # widgets for window # number of guests widgets self.noGuestsLbl = Label(self.master, text="Number of Guests:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.noGuestsEntry = Entry(self.master, validate='key') self.noGuestsEntry.configure(validatecommand=( self.noGuestsEntry.register(validation.NumbersOnly), '%S', '%d')) # name of contact widgets self.nameOfContactLbl = Label(self.master, text="Name of Contact:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.nameOfContactEntry = Entry(self.master, validate='key') self.nameOfContactEntry.configure(validatecommand=( self.nameOfContactEntry.register(validation.lettersOnly), '%S', '%P', '%d')) # address widgets self.addressLbl = Label(self.master, text="Full Address of Contact:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.addressEntry = Entry(self.master, validate='key') self.addressEntry.configure(validatecommand=( self.addressEntry.register(validation.check_address), '%S', '%P', '%d')) # contact number widgets self.contactNumberLbl = Label(self.master, text="Contact Number:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.contactNumberEntry = Entry(self.master, validate='key') self.contactNumberEntry['validatecommand'] = ( self.contactNumberEntry.register(validation.ValidatePhoneNumber), '%S', '%P', '%d', '%i') # room number widgets self.roomNoLbl = Label(self.master, text="Event Room Number:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.roomNoCombo = ttk.Combobox(self.master, value=self.roomNumbers, state='readonly', textvariable=self.roomComboText) self.roomNoCombo.bind('<<ComboboxSelected>>', self.room_pick) # date of event widgets self.dateOfEventLbl = Label(self.master, text="Date of Event:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.dateOfEventEntry = Entry(self.master, textvariable=self.dateOfEventValue, font=style.textNormal, state='readonly') self.dateOfEventEntry.bind('<Button-1>', self.selectDate) # date of booking widgets self.dateOfBookingLal = Label(self.master, font=style.textNormal, bg=style.widgetBG, text='Date of Booking:') self.dateOfBookingInfo = Label(self.master, font=style.textNormal, bg=style.widgetBG, text=datetime.datetime.now().date()) # cost per head widgets self.costPerHeadLbl = Label(self.master, text="Cost Per Head:", font=style.textNormal, anchor='e', width=20, bg=style.widgetBG) self.costPerHeadDisplay = Label(self.master, font=style.textNormal, anchor=W, width=20, text=mc.pound_string(0), bg=style.widgetBG) # grid layout self.noGuestsLbl.grid(row=0, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.noGuestsEntry.grid(row=0, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.nameOfContactLbl.grid(row=1, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.nameOfContactEntry.grid(row=1, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.addressLbl.grid(row=2, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.addressEntry.grid(row=2, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.contactNumberLbl.grid(row=3, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.contactNumberEntry.grid(row=3, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.roomNoLbl.grid(row=4, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.roomNoCombo.grid(row=4, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.dateOfEventLbl.grid(row=5, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.dateOfEventEntry.grid(row=5, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.dateOfBookingLal.grid(row=6, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.dateOfBookingInfo.grid(row=6, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY) self.costPerHeadLbl.grid(row=100, column=0, sticky=E, padx=style.paddingX, pady=style.paddingY) self.costPerHeadDisplay.grid(row=100, column=1, sticky=W, padx=style.paddingX, pady=style.paddingY)