tailieunhanh - head first java programming phần 9

Không phải tất cả các sự kiện được tạo ra bằng cách nhấp chuột vào nút Chương trình giao diện của bạn xử lý rất nhiều các sự kiện, không chỉ là sự kiện được tạo bởi người dùng của bạn, ví dụ, các nút được nhấp vào. Hệ thống điều hành của bạn có thể gửi | graphical interface elements Not all events are generated by button clicks Your GUI program processes lots of events not just the events generated by your user when for instance buttons are clicked. Your operating system can send events to your GUI program too. Some of these events are commonly handled by the graphical programming technology you are working with. For most of the operating system s events tkinter very kindly handles them for you. When you click the close box on your GUI this generates a Window Manager event for your code to handle. If your code doesn t handle a Window Manager event tkinter handles it for you in a default way too. Your user If the default event handling isn t what you want you have to capture the event before it gets to tkinter and is handled in the default way. At the moment the click on the close box is being handled for you by tkinter and the default behavior is to close the window. Let s take control of this default behavior. you are here 4 319 the cost of interactive loveliness Frank What s up now Joe Well it looks like I have to worry about lots of other GUI events not just my own. Jim Yeah. It appears the operating system and this Window Manager thing can give the GUI application work to do. Frank Yes that s right. All that interactive loveliness comes at a cost. Joe Cost You mean we have to pay Frank No not that sort of cost. You sometimes need to write a little extra code to interact with the Window Manager when and where necessary. that s what I mean by cost. Joe Phew So. what s a Window Manager anyway Frank It s something built into every GUI application that handles the management of your application s windows. Python s GUI tkinter has a Window Manager as do all the other GUI toolkits. Joe So how do I work with the events generated by the Window Manager Frank You create a function with the code you want to run and then connect the function to the event. Joe OK I get that. But which event do I connect up to It s not like .

crossorigin="anonymous">
Đã 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.