小编Fox*_*SGR的帖子

使 tkinter 窗口出现在任务栏中

我正在制作音乐播放器 GUI,但无法让它出现在任务栏或 Alt-Tab 中。我已将 overrideredirect() 设置为 true 以删除边框和标题。我还做到了当用户执行“鼠标单击并拖动”操作时,窗口会移动。这是代码:

import tkinter
import sys
import os


class Win(tkinter.Tk):
    global imgfile
    imgfile = r"play.png"

    def __init__(self, master=None):
        def close():
            self.destroy()
            sys.exit()

        def dirchosen():
            global songlist
            songlist = []
            try:
                os.chdir(dirinput.get())
            except:
                print("Invalid Directory")
                raise
            for file in os.listdir(dirinput.get()):
                songlist.append(file)

        tkinter.Tk.__init__(self, master)
        self.overrideredirect(True)
        self._offsetx = 0
        self._offsety = 0

        self.bind('<Button-1>', self.clickwin)
        self.bind('<B1-Motion>', self.dragwin)

        self.geometry("350x200")
        self.config(bg="#FF4766")

        titlelabel = tkinter.Label(self, text="FoxSGR Media Player", bg="#FF4766", font=("Segoe UI", 12))
        titlelabel.pack(ipady=4)

        chdirbutton = tkinter.Button(self, relief="groo", activebackground="#FF8080", command=dirchosen)
        chdirbutton.config(text="Choose Directory", …
Run Code Online (Sandbox Code Playgroud)

python user-interface tkinter python-3.x

7
推荐指数
1
解决办法
2488
查看次数

标签 统计

python ×1

python-3.x ×1

tkinter ×1

user-interface ×1