# -*- coding: UTF-8 -*- import tkinter root = tkinter.Tk() root.geometry('100x100') label = tkinter.Label(root, text='', bg='red') label.grid(row=0, column=0, sticky='we') root.columnconfigure(0, weight=1) root.mainloop()
# -*- coding: UTF-8 -*- import tkinter root = tkinter.Tk() root.geometry('100x100') label = tkinter.Label(root, text='', bg='red') label.grid(row=0, column=0, sticky='we') root.columnconfigure(0, weight=1) root.mainloop()
# -*- coding: UTF-8 -*- import tkinter class Window(object): def __init__(self): self.root = tkinter.Tk() def clickwin(self, event): self._offsetx = event.x self._offsety = event.y def dragwin(self, event): x = self.root.winfo_pointerx() - self._offsetx y = self.root.winfo_pointery() - self._offsety self.root.geometry('+{x}+{y}'.format(x=x,y=y)) def run(self): self.root.geometry('100x100') self.root.overrideredirect(True) self.label = tkinter.Label(self.root, text='', bg='red') self.label.grid(row=0, column=0, sticky='we') self.label.bind('<Button-1>', self.clickwin) self.label.bind('<B1-Motion>', self.dragwin) self.root.columnconfigure(0, weight=1) self.root.mainloop() Window().run()