コード例 #1
0
    def test_calendar_selection(self):
        widget = Calendar(self.window,
                          month=3,
                          year=2011,
                          day=10,
                          maxdate=date(2013, 1, 1),
                          mindate=date(2010, 1, 1))
        widget.pack()
        self.assertEqual(widget.selection_get(), date(2011, 3, 10))

        widget.selection_set(date(2012, 4, 11))
        self.assertEqual(widget.selection_get(), date(2012, 4, 11))
        self.assertEqual(widget._date, date(2012, 4, 1))
        widget.selection_set(datetime(2012, 5, 11))
        self.assertEqual(widget.selection_get(), date(2012, 5, 11))
        self.assertNotIsInstance(widget.selection_get(), datetime)
        self.assertIsInstance(widget.selection_get(), date)
        widget.selection_set(datetime(2012, 5, 21).strftime('%x'))
        self.assertEqual(widget.selection_get(), date(2012, 5, 21))
        self.assertNotIsInstance(widget.selection_get(), datetime)
        self.assertIsInstance(widget.selection_get(), date)

        widget.selection_set(date(2018, 4, 11))
        self.assertEqual(widget.selection_get(), date(2013, 1, 1))
        widget.selection_set(date(2001, 4, 11))
        self.assertEqual(widget.selection_get(), date(2010, 1, 1))
        widget.selection_clear()
        self.assertIsNone(widget.selection_get())
        # test Swedish locale
        widget.destroy()
        widget = Calendar(self.window, locale='sv_SE')
        widget.pack()
        widget.selection_set(format_date(date(2012, 4, 11), 'short', 'sv_SE'))
コード例 #2
0
def Search():
    clear(frame2)
    frame3 = Frame(frame2)
    frame4 = Frame(frame2)
    frame5 = Frame(frame2)
    Label(frame3, text="Guest First Name", font=("arial", 12),
          height=2).grid(row=0, column=0)
    FirstName = Entry(frame3, font=("arial", 12))
    FirstName.grid(row=0, column=1)
    Label(frame3, text="Guest Last Name", font=("arial", 12),
          height=2).grid(row=0, column=2)
    LastName = Entry(frame3, font=("arial", 12))
    LastName.grid(row=0, column=3)
    Label(frame3, text="Room Number", font=("arial", 12),
          height=2).grid(row=0, column=4)
    Room = Entry(frame3, font=("arial", 12))
    Room.grid(row=0, column=5)
    Label(frame3, text="Phone Number", font=("arial", 12),
          height=2).grid(row=0, column=6)
    Phone = Entry(frame3, font=("arial", 12))
    Phone.grid(row=0, column=7)
    Label(frame4, text="Street Address", font=("arial", 12),
          height=2).grid(row=1, column=0)
    Address = Entry(frame4, font=("arial", 12))
    Address.grid(row=1, column=1)
    Label(frame4, text="Check In Date", font=("arial", 12),
          height=2).grid(row=1, column=2)
    CheckIn = Calendar(frame4, selectmode='day', date_pattern='y-mm-dd')
    CheckIn.selection_clear()
    CheckIn.grid(row=1, column=3)
    Label(frame4, text="Check Out Date", font=("arial", 12),
          height=2).grid(row=1, column=4)
    CheckOut = Calendar(frame4, selectmode='day', date_pattern='y-mm-dd')
    CheckOut.selection_clear()
    CheckOut.grid(row=1, column=5)

    def check():
        search_result = search_data(FirstName.get(), LastName.get(),
                                    Room.get(), Phone.get(), Address.get(),
                                    CheckIn.get_date(), CheckOut.get_date())
        if search_result:
            clear(frame5)
            Label(frame5,
                  text="Guest Name",
                  font=("arial", 20),
                  height=2,
                  width=18).grid(row=0, column=0)
            Label(frame5,
                  text="Room Number",
                  font=("arial", 20),
                  height=2,
                  width=18).grid(row=0, column=1)
            Label(frame5,
                  text="Check In Date",
                  font=("arial", 20),
                  height=2,
                  width=18).grid(row=0, column=2)
            Label(frame5,
                  text="Check out Date",
                  font=("arial", 20),
                  height=2,
                  width=18).grid(row=0, column=3)
            for i in range(len(search_result)):
                B = Button(frame5,
                           text=search_result[i][0] + ' ' +
                           search_result[i][1],
                           command=partial(GuestProfile, search_result[i][5]),
                           font=("arial", 15),
                           height=2,
                           width=24,
                           borderwidth=1,
                           relief="groove")
                B.grid(row=i + 1, column=0)
                Label(frame5,
                      text=search_result[i][2],
                      font=("arial", 15),
                      height=2,
                      width=24,
                      borderwidth=1,
                      relief="groove").grid(row=i + 1, column=1)
                Label(frame5,
                      text=search_result[i][3],
                      font=("arial", 15),
                      height=2,
                      width=24,
                      borderwidth=1,
                      relief="groove").grid(row=i + 1, column=2)
                Label(frame5,
                      text=search_result[i][4],
                      font=("arial", 15),
                      height=2,
                      width=24,
                      borderwidth=1,
                      relief="groove").grid(row=i + 1, column=3)
        elif search_result == []:
            clear(frame5)
            Label(frame5, text="No Match Found", font=("arial", 25),
                  height=2).grid(row=0, column=0)
        else:
            clear(frame5)
            Label(frame5,
                  text="Please Enter Input(s)",
                  font=("arial", 25),
                  height=2).grid(row=0, column=0)
        CheckIn.selection_clear()
        CheckOut.selection_clear()

    Button1 = Button(frame4, text='Search', command=check,
                     font=("arial", 14)).grid(row=1, column=6)
    frame3.grid(row=0, column=0)
    frame4.grid(row=1, column=0)
    frame5.grid(row=2, column=0)
    frame2.grid(row=1, column=0)