Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Window-management/Python/window-management.py
Normal file
32
Task/Window-management/Python/window-management.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from tkinter import *
|
||||
import tkinter.messagebox
|
||||
|
||||
def maximise():
|
||||
"""get screenwidth and screenheight, and resize window to that size.
|
||||
Also move to 0,0"""
|
||||
root.geometry("{}x{}+{}+{}".format(root.winfo_screenwidth(), root.winfo_screenheight(), 0, 0))
|
||||
|
||||
def minimise():
|
||||
"""Iconify window to the taskbar. When reopened, the window is
|
||||
unfortunately restored to its original state, NOT its most recent state."""
|
||||
root.iconify()
|
||||
|
||||
def delete():
|
||||
"""create a modal dialog. If answer is "OK", quit the program"""
|
||||
if tkinter.messagebox.askokcancel("OK/Cancel","Are you sure?"):
|
||||
root.quit()
|
||||
|
||||
root = Tk()
|
||||
|
||||
mx=Button(root,text="maximise",command=maximise)
|
||||
mx.grid()
|
||||
mx.bind(maximise)
|
||||
|
||||
mn=Button(root,text="minimise",command=minimise)
|
||||
mn.grid()
|
||||
mn.bind(minimise)
|
||||
|
||||
#catch exit events, including "X" on title bar.
|
||||
root.protocol("WM_DELETE_WINDOW",delete)
|
||||
|
||||
mainloop()
|
||||
Loading…
Add table
Add a link
Reference in a new issue