https://github.com/akascape/ctkmenubar
Modern menu/tool bar widget library for customtkinter. (extension/add-on)
https://github.com/akascape/ctkmenubar
customtkinter customtkinter-menu menubar titlebar-toolbar tkinter tkinter-gui tkinter-menubar tkinter-python toolbar
Last synced: 8 months ago
JSON representation
Modern menu/tool bar widget library for customtkinter. (extension/add-on)
- Host: GitHub
- URL: https://github.com/akascape/ctkmenubar
- Owner: Akascape
- License: cc0-1.0
- Created: 2023-05-29T06:32:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-07T11:10:56.000Z (about 1 year ago)
- Last Synced: 2025-04-13T04:59:26.683Z (8 months ago)
- Topics: customtkinter, customtkinter-menu, menubar, titlebar-toolbar, tkinter, tkinter-gui, tkinter-menubar, tkinter-python, toolbar
- Language: Python
- Homepage:
- Size: 77.1 KB
- Stars: 129
- Watchers: 3
- Forks: 12
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CTkMenuBar
Modern menu bar widget library for customtkinter.
## Features
- Custom dropdown menus
- Add menu in top of title bar
- Classic and modern menubar with full customisability
- Add commands and submenus
## Installation
```
pip install CTkMenuBar
```
### [
](https://github.com/Akascape/CTkMenuBar/archive/refs/heads/main.zip)
## Menu Types
- ## CTkMenuBar

### Usage
```python
from CTkMenuBar import *
...
menu = CTkMenuBar(master=root)
menu.add_cascade("Menu")
...
```
### Methods
- **.add_cascade(text, ctk_button_args...)**: add new menu button in the menu bar
- **.configure(*args)**: update parameters
### Arguments
| Parameter | Description |
|-----------| ------------|
| **master** | define the master widget, can be root or frame |
| bg_color | set the bg color of the menu bar |
| height | set height of the menu bar |
| width | set width of the menu bar buttons |
| padx | set internal padding between menu bar buttons |
| pady | set internal padding in top and bottom of menu bar |
| postcommand | add a command before spawing the dropdown |
| _*other frame parameters_ | other ctk frame parameters can also be passed |
- ## CTkTitleMenu
_This title menu is only supported in windows OS!_

### Usage
```python
from CTkMenuBar import *
...
menu = CTkTitleMenu(master=root)
menu.add_cascade("Menu")
...
```
### Methods
- **.add_cascade(text, ctk_button_kwargs...)**: add new menu button in the menu bar
### Arguments
| Parameter | Description |
|-----------| ------------|
| **master** | define the master window, can be **root or toplevel** only |
| bg_color | set the bg color of the menu bar |
| title_bar_color | set color to the header (**only works with windows 11**), `RGB order: 0x00rrggbb` |
| width | set width of the menu bar buttons |
| padx | set internal padding between menu bar buttons |
| x_offset | set the x distance from the header |
| y_offset | set the y distance from the header |
| postcommand | add a command before spawing the dropdown |
| _*other frame parameters_ | other ctk frame parameters can also be passed |
## CustomDropdownMenu
This is the common dropdown menu class which is used by both ctkmenubar and ctktitlemenu.
### Usage
```python
from CTkMenuBar import *
...
dropdown = CustomDropdownMenu(widget=button)
dropdown.add_option(option="value")
dropdown.add_separator()
submenu = dropdown.add_submenu("submenu")
submenu.add_option(option="value")
...
```
### Methods
- **.add_option(option, command)**: add option to the dropdown and attach the command
- **.add_separator()**: add a separator line between the options
- **.add_submenu(submenu_name)**: add a submenu as option
- **.configure(*args)**: change dropdown menu options
### Arguments
| Parameter | Description |
|-----------| ------------|
| **widget** | attach the dropdown to the cascade widget |
| master | *optional*, change the spawn window if required |
| bg_color | set the bg color of the dropdown |
| fg_color | set the option button fg color |
| text_color | set the text color |
| hover_color | set hover color of the option button |
| separator_color | change the separator line color |
| font | change the font of the text |
| width | set width of the dropdown |
| height | set height of the dropdown |
| padx | set padding in x for the dropdown frame |
| pady | set padding in y for the dropdown frame |
| _*other frame parameters_ | other ctk frame parameters can also be passed |
_Credits goes to [LucianoSaldivia](https://github.com/LucianoSaldivia) for providing this dropdown menu class._