1. Trang chủ
  2. » Ngoại Ngữ

Graphical user interfaces for Python programs Phần 4 pot

1 169 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1
Dung lượng 167,65 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

BROW SERS 183We scan the disk, finding all files with recognizable extensions and add the nodes to the tree: files = os.listdirimgs for file in files: r, ext = os.path.splitextfile cont,

Trang 1

BROW SERS 183

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 poten-tial 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

Ngày đăng: 05/08/2014, 14:20

TỪ KHÓA LIÊN QUAN