1

I would like to create some screen that is displayed every time user login to machine. He would need to inserts his credentials and reason of his login, only then window could be closed. I was thinking about using tkinker, but I can find information how to lock it from closing or minimizing.

EDIT: Note that I'm not asking how to hide buttons, I figured it out. I want to prevent minimizing for e.g.: clicking on different window.

zimek-atomek
  • 413
  • 4
  • 14

1 Answers1

1

You definitely can do it with tkinter:

import tkinter as tk

LOGIN = 'admin'
PWD = '12345'


def prevent_exit():
    pass


def login():
    if login_entry.get() == LOGIN and pwd_entry.get() == PWD and reason_entry.get():
        window.quit()


window = tk.Tk()
window.attributes('-fullscreen', True)
window.attributes('-topmost', True)
window.protocol('WM_DELETE_WINDOW', prevent_exit)

login_label = tk.Label(window, text='Login')
login_label.grid(column=0, row=0)

login_entry = tk.Entry(window)
login_entry.grid(column=1, row=0)

pwd_label = tk.Label(window, text='Password')
pwd_label.grid(column=0, row=1)

pwd_entry = tk.Entry(window, show='*')
pwd_entry.grid(column=1, row=1)

reason_label = tk.Label(window, text='Reason')
reason_label.grid(column=0, row=2)

reason_entry = tk.Entry(window)
reason_entry.grid(column=1, row=2)

send_emails_button = tk.Button(window, text='Login', command=login)
send_emails_button.grid(column=0, row=3, columnspan=2)

tk.mainloop()

This full screen window can not be closed or minimized and it is always on top:

enter image description here

Alderven
  • 7,569
  • 5
  • 26
  • 38
  • Still, task manager doesn't care about `-topmost`, so you're able to tab to task manager and close this window. – CommonSense Jul 31 '19 at 12:01
  • @CommonSense actually you can't. Tkinter window will be always on top. – Alderven Aug 01 '19 at 05:32
  • Yes I can, even on win7. Last updates to win system cover that, keywords are: task manager always on top. For example: check [this](https://stackoverflow.com/questions/39246590/is-task-manager-a-special-kind-of-always-on-top-window-for-windows-10). But I don’t think it matters a lot. – CommonSense Aug 01 '19 at 09:14
  • It is only works if "always on top" option checked in Task Manager – Alderven Aug 01 '19 at 09:25