head first java programming phần 10

các sự kiện để chương trình giao diện của bạn, quá. Một số những sự kiện này thường được xử lý bằng công nghệ lập trình đồ họa bạn đang làm việc với. Đối với hầu hết các sự kiện của hệ điều hành, tkinter rất vui lòng xử lý chúng cho bạn. Khi bạn nhấp vào hộp đóng trên giao diện của bạn | custom widgets and classes Group widgets together If the interface were laid out with the checkbox for a track grouped alongside the volume slider for the same track it would look better. Each track could then have a row of widgets associated with it. As long as you know which widgets belong to which track you can load a lot more tracks at once without the checkboxes and sliders getting separated and without your users getting confused . The program currently uses a function to add the checkboxes and sliders to the interface one widget at a time. If you call the function several times the computer creates two more widgets with each call. But the widgets are not grouped. So how do you group widgets together in a GUI interface Create a new type of widget What if you don t just hand the computer a set of instructions What if you give it a brand new widget instead If you create a new kind of widget that groups a checkbox with a slider you can add your new widget to the interface and then guarantee that the checkbox and slider stay together __ yoi r new widget together the other widyts so they always stay ý fed- Your new widget becomes a new building block for your GUI interface. So how are new widgets created And how do they work you are here 4 363 frame widgets A frame widget contains other widgets Most GUI libraries including tkinter let you create custom widgets from a set of other components and tkinter includes a special kind of widget called a frame. A frame works just like a picture frame in that it surrounds other things. It s rectangular and it can contain other widgets Ạ frame is Vtke a frame- In tkinter a frame is created using Frame . If you can work out a way to create a new type of frame called say SoundPanel that contains the checkbox and the slider then you could use code something like this in your program This code uses an entirely new type of object a whole new kind of widget that has never existed before. How do you tell the computer to create .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.