Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a borderless application in Python (windows)?

I would like to know how to create an application in Windows that does not have the default border; particularly the title bar with minimize, maximize, and close buttons. I'm thinking of writing a ticker program that takes up a narrow space at the top or bottom of the screen, but I won't attempt it unless it's possible to make a thin application in Python. Any help with terminology is appreciated; maybe I don't know how to ask the right question in searching. Does Tkinter have this option? Thanks

like image 900
user6811 Avatar asked Feb 21 '12 03:02

user6811


1 Answers

I found an example that answered my question here. overrideredirect(1) is the key function.

I like this method because I'm familiar with Tk and preferred a Tk solution, but see the other answers for alternate solutions.

import tkMessageBox
from Tkinter import *

class App():
    def __init__(self):
        self.root = Tk()
        self.root.overrideredirect(1)
        self.frame = Frame(self.root, width=320, height=200,
                           borderwidth=2, relief=RAISED)
        self.frame.pack_propagate(False)
        self.frame.pack()
        self.bQuit = Button(self.frame, text="Quit",
                            command=self.root.quit)
        self.bQuit.pack(pady=20)
        self.bHello = Button(self.frame, text="Hello",
                             command=self.hello)
        self.bHello.pack(pady=20)

    def hello(self):
        tkMessageBox.showinfo("Popup", "Hello!")

app = App()
app.root.mainloop()

Just need to add your own kill button or quit method.

like image 87
user6811 Avatar answered Oct 25 '22 02:10

user6811