{"id":10312,"library":"ttkbootstrap","title":"ttkbootstrap","description":"ttkbootstrap is a supercharged theme extension for tkinter that provides modern flat-style themes inspired by Bootstrap. It offers a wide range of pre-built widgets and styles, making it easy to create visually appealing and responsive GUI applications with Tkinter. The library is actively maintained with frequent minor and patch releases, typically every few weeks.","status":"active","version":"1.20.2","language":"en","source_language":"en","source_url":"https://github.com/israel-dryer/ttkbootstrap","tags":["tkinter","gui","theme","bootstrap","desktop","ui"],"install":[{"cmd":"pip install ttkbootstrap","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for image handling and certain widgets (e.g., icons). Specific versions are often pinned in `ttkbootstrap`.","package":"Pillow","optional":false}],"imports":[{"note":"The primary entry point for a themed Tkinter application.","symbol":"Window","correct":"import ttkbootstrap as tb\napp = tb.Window(themename=\"flatly\")"},{"note":"Required for displaying images. Often used with `Label` or `Button` widgets.","symbol":"PhotoImage","correct":"from ttkbootstrap import PhotoImage"},{"note":"Prior to v1.19.1, some dialogs (like `Dialog` itself) might have been referenced from `ttkbootstrap.dialog` but the correct path for pre-built dialogs is now `ttkbootstrap.dialogs`.","wrong":"from ttkbootstrap.dialog import Messagebox","symbol":"Messagebox","correct":"from ttkbootstrap.dialogs import Messagebox"}],"quickstart":{"code":"import ttkbootstrap as tb\n\ndef main():\n    app = tb.Window(themename=\"cosmo\") # Try 'darkly', 'superhero', 'flatly', etc.\n    app.title(\"My ttkbootstrap App\")\n    app.geometry(\"400x200\")\n\n    label = tb.Label(app, text=\"Hello from ttkbootstrap!\", font=('Helvetica', 16))\n    label.pack(pady=30)\n\n    button = tb.Button(app, text=\"Click Me\", command=lambda: label.config(text=\"Button Clicked!\"), bootstyle=\"primary\")\n    button.pack(pady=10)\n\n    app.mainloop()\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart creates a simple ttkbootstrap application with a themed window, a label, and a button. The `Window` class automatically sets up a themed Tkinter root window. Experiment with different `themename` values like 'darkly', 'superhero', or 'flatly' for varying aesthetics."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer. The current recommended minimum is Python 3.10.","message":"ttkbootstrap dropped support for Python 3.9 in version 1.19.0. Applications using Python 3.9 or older will fail to install or run with newer versions.","severity":"breaking","affected_versions":">=1.19.0"},{"fix":"Update import statements from `from ttkbootstrap.dialog import Dialog` to `from ttkbootstrap.dialogs.dialog import Dialog` for custom dialogs, or `from ttkbootstrap.dialogs import Messagebox` for pre-built ones.","message":"The import path for certain dialog classes, such as `Dialog` (for creating custom dialogs), changed from `ttkbootstrap.dialog` to `ttkbootstrap.dialogs` in version 1.19.1. While `ttkbootstrap.dialogs` now holds pre-built dialogs like `Messagebox`, the base `Dialog` class also moved there.","severity":"deprecated","affected_versions":">=1.19.1"},{"fix":"Assign the `PhotoImage` object to an instance variable of a class or a global variable to prevent it from being garbage collected. Example: `self.icon = PhotoImage(file='icon.png'); button.config(image=self.icon)`.","message":"When using `PhotoImage` objects (e.g., for icons on buttons or labels), ensure you maintain a reference to the image object. If the `PhotoImage` object is garbage collected, the image will disappear from the widget.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Store the `PhotoImage` object as an attribute of the widget's parent (e.g., `self.my_image = PhotoImage(...)`) or as a global variable. This ensures it remains in memory as long as the widget needs it.","cause":"A `PhotoImage` object used by a widget (e.g., a button or label) has been garbage collected because no strong reference to it was maintained.","error":"TclError: image \"pyimageX\" doesn't exist"},{"fix":"Update your import statement. For general dialogs, use `from ttkbootstrap.dialogs import Messagebox` or `Querybox`. For the base custom `Dialog` class, use `from ttkbootstrap.dialogs.dialog import Dialog`.","cause":"Attempting to import dialogs (like `Dialog` or `Messagebox`) from an old path that was removed or changed in `ttkbootstrap` v1.19.1 and later.","error":"ModuleNotFoundError: No module named 'ttkbootstrap.dialog'"},{"fix":"Ensure `app.mainloop()` (where `app` is your `tb.Window` instance) is called at the very end of your application's setup code to start the GUI event loop.","cause":"Often happens if `tb.Window()` is called but the `mainloop()` method is not invoked at the end of the script to start the Tkinter event loop.","error":"AttributeError: 'Window' object has no attribute 'mainloop'"}]}