Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Mã này có thể sẽ có một chút phức tạp hơn trong thực tế, tôi có thể thấy một vài vấn đề tiềm năng như tôi đang viết bài này (tôi có thể viết "Tôi để lại này như tập thể dục để bạn có thể xác định vấn đề với mã này"). * Sau khi cây đã được xây dựng, chúng tôi thiết lập lại cờ inhibitDraw và hiển thị cây. | We scan the disk finding all files with recognizable extensions and add the nodes to the tree files os.listdir imgs for file in files r ext os.path.splitext file cont icon imageDir.get ext None None if cont cont.addChild self.browser icon icon name file action self.showMe This code would probably be a little more complex in reality I can see a couple of potential problems as I m writing this I could write I leave this as an exercise for you to identify problems with this code . Once the tree has been built we reset the inhibitDraw flag and display the tree self.browser.inhibitDraw 0 self.browser.display That probably seems like a lot of code but the resulting browser provides a highly-acceptable interface. In addition users will understand the interface s navigation and it is readily adaptable to a wide range of data models. Running Example_8_10.py with a Python built with PIL will display a screen similar to the one in figure 8.11. Figure 8.11 Image browser BROWSERS .