Beispiel #1
0
def test_update_command_with_parameter():
    a = App()

    callback_event = Event()
    def callback(value):
        assert l.value == "foo"
        callback_event.set()

    l = ListBox(a, ["foo", "bar"])
    l.value = "foo"

    l.update_command(callback)

    l._listbox._command_callback()
    assert callback_event.is_set()

    a.destroy()
Beispiel #2
0
def test_update_command():
    a = App()

    callback_event = Event()
    def callback():
        callback_event.set()

    l = ListBox(a, ["foo", "bar"])

    l._listbox._command_callback()
    assert not callback_event.is_set()

    l.update_command(callback)
    l._listbox._command_callback()
    assert callback_event.is_set()
    callback_event.clear()

    l.update_command(None)
    l._listbox._command_callback()
    assert not callback_event.is_set()

    a.destroy()
for course in course_list:
    course_btn = PushButton(cbox, text=course.get_cname(), width=10, height=3)
    course_btn.bg = (129, 217, 222)
    course_btn.text_color = (255, 255, 255)
    course_btn.update_command(food_details, [course.get_cname()])

admin_button = PushButton(cbox,
                          text="Admin",
                          command=admin_access,
                          width=10,
                          height=3)
admin_button.bg = (129, 217, 222)
admin_button.text_color = (255, 255, 255)

food_listbox = ListBox(fbox)
food_listbox.update_command(add_food)
order_listbox = ListBox(obox, width=200, height=200)
delete_button = PushButton(obox, text="Undo", command=undo)
clear_button = PushButton(obox, text="Clear", command=clear_order)
finish_button = PushButton(obox, text="Finish", command=finish_order)
cost_lbl = Text(obox, text="Total Cost:")

success_lbl = Text(afbox)

for course in course_list:
    course_btn = PushButton(aabox, text=course.get_cname(), width=10, height=3)
    course_btn.bg = (129, 217, 222)
    course_btn.text_color = (255, 255, 255)
    course_btn.update_command(admin_food_details, [course.get_cname()])

admin_listbox_available = ListBox(abbox)
# This is section where you add any GUI widgets

# Loop through the teacher_list and create a button for each one
row = 0
column = 0
for teacher in teacher_list:
    # We only want 3 columns of buttons
    if column == 3:
        column = 0
        row += 1
    else:
        # Each button displays the name of the teacher
        teacher_btn = PushButton(app,
                                 text=teacher.get_tname(),
                                 width=10,
                                 height=3,
                                 grid=[column, row])
        # We use update_command() instead of command because we want to send a parameter to the teacher_details() function
        teacher_btn.update_command(teacher_details, [teacher.get_tname()])
        column += 1

teacher_label = Text(app, grid=[0, row + 1])
class_label = Text(app, grid=[0, row + 2])
class_listbox = ListBox(app, grid=[0, row + 3])
class_listbox.update_command(student_details)
class_count_label = Text(app, grid=[0, row + 4])

# Start the program
app.display()