TAILIEUCHUNG - Apress Pro PHP-GTK phần 10

Tạo hai nút. button1 = mới GtkButton ('Hoạt động'); button2 = new GtkButton ('Không hoạt động'); / / Thiết lập phong cách cho cả hai nút. $ button1-set_style (phong cách); $ button2-set_style (phong cách); / / nút hai không hoạt động. $ button2-set_sensitive (false); / / Thêm một hộp nút để cửa sổ. $ buttonBox = mới GtkHButtonBox (); cửa sổ add ($ buttonBox); / / Thêm nút vào hộp. | CHAPTER 16 CHANGING THE LOOK AND FEEL 331 Listing 16-5. Setting the Background Pixmap for a GtkStyle php Create a window and set it up to shut down cleanly. window new GtkWindow window- connect_simple destroy array Gtk main_quit Create a new style object. style new GtkStyle Create a pixbuf. file Crisscott images pixbuf GdkPixbuf new_from_file file Get a pixmap from the pixbuf. list pixmap pixbuf- render_pixmap_and_mask Assign the pixmap to the normal bg_pixmap. style- bg_pixmap Gtk STATE_INSENSITIVE pixmap Create two buttons. button1 new GtkButton Active button2 new GtkButton Inactive Set the style for both buttons. button1- set_style style button2- set_style style Make button two inactive. button2- set_sensitive false Add a button box to the window. buttonBox new GtkHButtonBox window- add buttonBox Add the buttons to the box. buttonBox- pack_start button1 buttonBox- pack_start button2 Show the window and start the main loop. window- show_all Gtk main Figure 16-4 shows the result of this small script. One button appears normally while the other which has been made insensitive using set_sensitive has a checkered background. 332 CHAPTER 16 CHANGING THE LOOK AND FEEL Figure 16-4. Using GtkStyle to Change a Background Pixmap Summary Even the most unique application can end up with an appearance that is ordinary and routine. Modifying the look and feel of an application can not only give it life but also improve its usability. Changing a widget s appearance by using RC files or GtkStyle objects can make a widget stand out so that it is more noticeable or can give the user clues about the state of the widget. In an RC file definitions and rules are set up similar to a CSS file in an HTML page. The rules determine which styles will be applied to each widget. GtkStyle objects are similar but are used for real-time style modifications. Using a GtkStyle object allows a widget to change colors or fonts based on an event. Regardless of how styles are .

TỪ KHÓA LIÊN QUAN
Đã 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.