Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

CTkMessagebox

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

CTkMessagebox

A modern messagebox for customtkinter

  • 2.7
  • PyPI
  • Socket score

Maintainers
1

CTkMessagebox

A modern and fully customizable messagebox for CustomTkinter, A must-have extension pack!

License Download PyPI Downloads Platform

3d


Features

  • Customize all elements inside the messagebox
  • Add custom icons or images
  • Add multiple options according to your wish
  • No ugly looking header or borders
  • Comes with 5 default icons
  • Spawns at center of the screen/app
  • Draggable window
  • Fade-in/Fade-out window effect

Installation

pip install CTkMessagebox

GitHub repo size


How it looks?

Screenshot


Example

from CTkMessagebox import CTkMessagebox
import customtkinter

def show_info():
    # Default messagebox for showing some information
    CTkMessagebox(title="Info", message="This is a CTkMessagebox!")

def show_checkmark():
    # Show some positive message with the checkmark icon
    CTkMessagebox(message="CTkMessagebox is successfully installed.",
                  icon="check", option_1="Thanks")
    
def show_error():
    # Show some error message
    CTkMessagebox(title="Error", message="Something went wrong!!!", icon="cancel")
    
def show_warning():
    # Show some retry/cancel warnings
    msg = CTkMessagebox(title="Warning Message!", message="Unable to connect!",
                  icon="warning", option_1="Cancel", option_2="Retry")
    
    if msg.get()=="Retry":
        show_warning()
        
def ask_question():
    # get yes/no answers
    msg = CTkMessagebox(title="Exit?", message="Do you want to close the program?",
                        icon="question", option_1="Cancel", option_2="No", option_3="Yes")
    response = msg.get()
    
    if response=="Yes":
        app.destroy()       
    else:
        print("Click 'Yes' to exit!")
              
app = customtkinter.CTk()
app.rowconfigure((0,1,2,3,4,5), weight=1)
app.columnconfigure(0, weight=1)
app.minsize(200,250)

customtkinter.CTkLabel(app, text="CTk Messagebox Examples").grid(padx=20)
customtkinter.CTkButton(app, text="Check CTkMessagebox", command=show_checkmark).grid(padx=20, pady=10, sticky="news")
customtkinter.CTkButton(app, text="Show Info", command=show_info).grid(padx=20, pady=10, sticky="news")
customtkinter.CTkButton(app, text="Show Error", command=show_error).grid(padx=20, pady=10, sticky="news")
customtkinter.CTkButton(app, text="Show Warning", command=show_warning).grid(padx=20, pady=10, sticky="news")
customtkinter.CTkButton(app, text="Ask Question", command=ask_question).grid(padx=20, pady=(10,20), sticky="news")

app.mainloop()


OPTIONS

ParametersDescription
masterset parent window (optional), the box will spawn at center of the parent window
widthwidth of the window in px (optional)
heightheight of the window in px (optional)
fg_colorforground color of the messagebox [middle portion]
bg_colorbackground color of the messagebox
titletitle of the messagebox
messagemain message of the messagebox which will be shown at the center
option_1the text on the first button [Default is 'OK']
option_2the text on the second button
option_3the text on the last button
optionsdirectly pass a list containing the options in order
button_colorcolor of the buttons
text_colorcolor of the message-text
title_colorcolor of the title-text
button_text_colorcolor of the button-text
button_hover_colorhover color of the buttons
button_widthwidth of the buttons in px
button_heightheight of the buttons in px
border_widthwidth of the border around the main frame [Default is 1]
border_colorcolor of the frame border
cancel_buttondefine the cancel button type: circle, cross or None
cancel_button_colorcolor of the close button, set it to 'transparent' if you want to hide it
iconicon that will be shown in the messagebox [Default is the 'info' icon]
icon_sizedefine the size of the icon image manually (tuple)
corner_radiuscorner roundness of the messagebox window [not applicable in linux]
fontfont of the messagebox text (tuple)
headeradd the original header back if you don't like overrideredirect (bool)
topmostdisable the topmost window outside the app (bool)
soundenable the system bell sound when the window popups (bool)
justifyposition the buttons to center/right/left
focus_optionselect an option by default when Enter key is pressed
fade_in_durationenable a fade-in and fade-out animation (int, default is 0)

Icons

Default icons:

icons

(These icons are created using Paint.NET, free to use!)

For custom images, just use icon="image_path.png"

That's all, hope it will help in UI development!

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc