-
-
Notifications
You must be signed in to change notification settings - Fork 106
Image Property
Some tk widgets have an image property. In pygubu, this property accepts an image file name that will be used when the widget is created.
To define an image, use the image selector located to the right of the property editor. The image name will be used as the 'key' for the selected image and saved into the *.ui file.
By default, the builder will search for images in the same directory of the specified ui file. Alternatively, you can specify different resource folders using the method add_resource_path(path). Those additional paths will be used to search for an image.
You must call add_resource_path before creating any widget that requires your custom image.
In code you can retrieve a reference of the tkinter image using the method get_image(name)
The image types you can use will depend on the tk version installed.
Full example code here.
...
def __init__(self, master=None):
# 1: Create a builder
self.builder = builder = pygubu.Builder()
# 2: Load an ui file
builder.add_from_file(PROJECT_UI)
# 3: Set images path before creating any widget
builder.add_resource_path(PROJECT_PATH)
# 4: Create the widget using self.master as parent
self.mainwindow = builder.get_object("mainwindow", master)
...
- Requirements
- Installation
- Launch
- Screens:
- Step-by-Step Examples:
- Completed Examples
- Tips
- Additional widget sets
- Known Issues
- FAQ
- Troubleshooting:
- Communicating: