Skip to content

TheKliko/CTkFluentWidgets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CTkFluentWidgets

This is a CustomTkinter widget library based on Fluent UI. It has all the basic widgets and a few more advanced widgets.

Caution

This library is not made for professional use, it only covers the widgets I needed for my own projects. You will be better off learning React or C# instead.

Windows

FluentRootWindow

This is your main window. It is a CTk window with integrated TkinterDnD2 support and a built-in banner and notification system.

send_banner()
  • send_banner(...) -> str Sends an InfoBar banner. Returns the banner ID.
def send_banner(
    title: str,
    message: str,
    mode: Literal[
        'success',
        'caution',
        'critical',
        'solid_attention',
        'attention',
        'neutral',
        'solid_neutral'
    ] = "neutral",
    is_icon_visible: bool = True,
    is_closable: bool = True,
    auto_close_after_ms: int = 0
) -> str:
close_banner()
  • close_banner(...) -> None Manually close a banner with the given ID.
def close_banner(id: str) -> None:
send_notification()
  • send_notification(...) -> str Sends an in-app notification. Returns the notification ID.
def send_notification(
    title: str,
    message: str,
    is_closable: bool = True,
    auto_close_after_ms: int = 0,
    on_click: Optional[Callable] = None
) -> str:
close_notification()
  • close_notification(...) -> None Manually close a notification with the given ID.
def close_notification(id: str) -> None:
set_notification_app_title()
  • set_notification_app_title(...) -> None Sets the app title for all future notifications.
def set_notification_app_title(title: str) -> None:
set_notification_app_icon()
  • set_notification_app_icon(...) -> None Sets the app icon for all future notifications.
def set_notification_app_icon(icon: str | Path | Image.Image | CTkImage) -> None:

FluentToplevel

A CTkToplevel with custom styling

Widgets

FluentLabel

A CTkLabel with custom styling and optional autowrap support.

Variations

FluentImageLabel

The default FluentLabel doesn't have image support, use this one instead.

FluentHyperlinkLabel

A clickable FluentLabel that opens the given URL.


FluentFrame

A CTkFrame with custom styling and optionaly drag-and-drop support.

Variations

FluentButtonFrame

A FluentFrame that acts like a button. Make sure to call the bind_all_children() method after adding your widgets.


FluentButton

A button.

Variations

FluentTransparentButton

A transparent button.

FluentAccentButton

A button styled using the user's Windows accent color.

FluentDropdownButton

A dropdown button.

FluentNavigationButton

Used internally by the FluentSidebar widget.


FluentTextBox

A CTkEntry with custom styling.


FluentToggleSwitch

A toggle switch.


FluentCheckBox

A checkbox.


FluentProgressBar

A CTkProgressBar with custom styling.


FluentColorPicker

A custom color picker based on CTkColorPicker and DuckDuckGo's color picker.


FluentSidebar

A custom sidebar for your app.

Methods

get_header_frame()
  • get_header_frame(...) -> FluentFrame Returns a header frame, creates one if it doesn't exist yet
add_navigation_button()
  • add_navigation_button(...) -> str Creates navigation button based on the provided button data, returns the button ID.
{
    "text": str,
    "image": CTkImage,
    "command": Callable
}
add_footer_button()
  • add_footer_button(...) -> str Creates footer button based on the provided button data, returns the button ID.
{
    "text": str,
    "image": CTkImage,
    "command": Callable
}

View Models

ListView

Display frames in a list.

Methods

add_frame()
  • add_frame(...) -> ListViewFrame Add a new frame and return it. It's position is automatically managed by the ListView widget.
remove_item()
  • remove_item(...) -> None Remove an item from the ListView.
def remove_item(item_or_id: str | ListViewFrame) -> None:

GridView

Display frames in a grid.

Methods

add_frame()
  • add_frame(...) -> GridViewFrame Add a new frame and return it. It's position is automatically managed by the GridView widget.
add_frame()
  • add_button_frame(...) -> GridViewButtonFrame Add a new button frame and return it. It's position is automatically managed by the GridView widget.
def add_button_frame(command: Optional[Callable] = None) -> GridViewButtonFrame:
remove_item()
  • remove_item(...) -> None Remove an item from the GridView.
def remove_item(item_or_id: str | GridViewFrame | GridViewButtonFrame) -> None:

Other

messagebox

A replacement for tkinter.messagebox.

Methods

show_info()
  • show_info(...) -> None Shows an info level messagebox.
def show_info(title: str = "", message: str = "", window_title: str = "FluentMessageBox", window_icon: str | Path = Assets.FAVICON, ok_text: str = "OK", can_copy_message: bool = False, bell: bool = True, additional_buttons: Optional[list[dict] | tuple[dict, ...]] = None, centered: bool = True) -> None:
show_warning()
  • show_warning(...) -> None Shows a warning level messagebox.
def show_warning(title: str = "", message: str = "", window_title: str = "FluentMessageBox", window_icon: str | Path = Assets.FAVICON, ok_text: str = "OK", can_copy_message: bool = False, bell: bool = True, additional_buttons: Optional[list[dict] | tuple[dict, ...]] = None, centered: bool = True) -> None:
show_error()
  • show_error(...) -> None Shows an error level messagebox.
def show_error(title: str = "", message: str = "", window_title: str = "FluentMessageBox", window_icon: str | Path = Assets.FAVICON, ok_text: str = "OK", can_copy_message: bool = False, bell: bool = True, additional_buttons: Optional[list[dict] | tuple[dict, ...]] = None, centered: bool = True) -> None:
ask_ok_cancel()
  • ask_ok_cancel(...) -> bool Shows a question level messagebox. Returns True if OK is pressed, otherwise False.
def ask_ok_cancel(title: str = "", message: str = "", window_title: str = "FluentMessageBox", window_icon: str | Path = Assets.FAVICON, ok_text: str = "OK", cancel_text: str = "Cancel", can_copy_message: bool = False, bell: bool = True, additional_buttons: Optional[list[dict] | tuple[dict, ...]] = None, centered: bool = True) -> bool:
ask_yes_no()
  • ask_yes_no(...) -> None Shows a question level messagebox. Returns True if Yes is pressed, otherwise False.
def ask_yes_no(title: str = "", message: str = "", window_title: str = "FluentMessageBox", window_icon: str | Path = Assets.FAVICON, yes_text: str = "Yes", no_text: str = "No", can_copy_message: bool = False, bell: bool = True, additional_buttons: Optional[list[dict] | tuple[dict, ...]] = None, centered: bool = True) -> bool:

inputdialog

Show an input dialog.

Methods

get_color()
  • get_color(...) -> str | None Shows a color picker and returns the selected color or None if no color was selected.
def get_color(window_title: str = "FluentColorPicker", window_icon: str | Path = Assets.FAVICON, ok_text: str = "OK", cancel_text: str = "Cancel", mode: Literal["simple", "advanced"] = "simple", bell: bool = False, centered: bool = True) -> Optional[str]:
get_input()
  • get_input(...) -> str | None Asks the user for input and returns the response or None if no response was given.
def get_input(title: str = "", message: str = "", window_title: str = "FluentInputDialog", window_icon: str | Path = Assets.FAVICON, ok_text: str = "OK", cancel_text: str = "Cancel", placeholder_text: str = "Type here", bell: bool = False, centered: bool = True, validate: Literal['none', 'focus', 'focusin', 'focusout', 'key', 'all'] = "none", validatecommand = None) -> Optional[str]: