Code Monkey home page Code Monkey logo

customtkintertitlebar's Introduction

自定义标题栏 CustomTkinterTitlebar

📃 这是一个项目可以帮助你拥有一个自定义的标题栏!小组件可以被放到这个标题栏里面 This is a project can help you to have a custom titlebar! Widgets can add into titlebar!

快速开始 Quick Start

from customtitlebar import CTT
from tkinter import ttk
from sv_ttk import set_theme

example = CTT()
example.title("TitleBar")
example.geometry("1030x570")
set_theme("dark")
en = ttk.Entry(example.titlebar)
en.pack(fill = "y", expand = True, pady = 1)

example.mainloop()

安装 Install

pip install CustomTkinterTitlebar --user

预览 View:

image image

🎰 样例 Example:

https://github.com/littlewhitecloud/CustomTkinterTitlebar-Examples

感谢 @HuyHung1408花时间来在Windows11上测试它! Thanks @HuyHung1408 for testing it on windows 11!

customtkintertitlebar's People

Contributors

littlewhitecloud avatar sadjok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

customtkintertitlebar's Issues

Window not closing

In IDLE mode, the close button is not working.

self._titleexit.config(
bd=0,
activebackground=self.colors["%sexit_bg" % self.theme],
width=44,
image=self.close_hov_img,
relief=FLAT,
command=self.quit,

Fix

 self._titleexit.config(
            bd=0,
            activebackground=self.colors["%sexit_bg" % self.theme],
            width=44,
            image=self.close_hov_img,
            relief=FLAT,
            command=self.destroy, # quit sometimes doesn't work
        )

Make window resizeable

Summary:
Make the window can be resizeable like normal window.
Problem:
I have no idea how to solve it...
I will try my best...

try to replace the three buttons by tcl vsapi

Here I found something intreseting:
image
It seems that windows put the max, min, restore, close or even help button's glyph in the DWMWindow class.
And there is something from the tcl/tk ttk_vsapi manual page (https://www.tcl.tk/man/tcl9.0/TkCmd/ttk_vsapi.html):

Change the appearance of a ttk::checkbutton(n) to use the Explorer pin part EBP_HEADERPIN.

ttk::style element create pin vsapi EXPLORERBAR 3 {
    {pressed !selected} 3
    {active !selected} 2
    {pressed selected} 6
    {active selected} 5
    {selected} 4
    {} 1
}
ttk::style layout Explorer.Pin {Explorer.Pin.pin -sticky news}
pack [ttk::checkbutton .pin -style Explorer.Pin]

And this program created a checkbutton with a element from the vsapi in the EXPLOREBAR.
image
image
So I am thinking we can get the elements from the vsapi in the DWMWindow and let dwm to draw the three buttons.

Sadly, it doesn't work when I wrote down something like this:

ttk::style element create max vsapi DWMWINDOW 29 \
    {disabled 4 pressed 3 active 2 {} 1}
ttk::style layout MaxButton {MaxButton.max -sticky news}
pack [ttk::button .close -style MaxButton]

TODO: make it works

Windows 11 下最大化按钮没有绑定一个特殊的事件

Windows 11 操作系统下,对于一般窗口而言,鼠标移至最大化按钮上悬停一会儿时(按下组合键 Win+Z 也可触发),会弹出一个分屏的小窗,但这个功能在这个自定义标题栏中是没有的。

image

不知作者是否能在未来加入此功能?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.