Tkinter - disable the function to change to another window

Post here if you need help with creating a Graphical User Interface in Python.

Tkinter - disable the function to change to another window

Postby dec.stanley » Fri May 03, 2013 6:18 pm

Hi I'm making a security programme for my computer. I've got it working but i would like to know how to make it so you cannot change to another window. An example of this is when you are opening a file sometimes and it won't let you go onto another open window. Please help!!
dec.stanley
 
Posts: 5
Joined: Thu Mar 21, 2013 8:16 pm

Re: Tkinter - disable the function to change to another wind

Postby Yoriz » Fri May 03, 2013 7:03 pm

It's a bit hard to understand what your are asking for.
You dont want a tkinter window to open ?
You don't want an operating system window to open?
Disable the function that changes to another window - so when you click a button or something unbind the command ?
Try to make a small sample code of what your are wanting to do and explain it a bit clearer what result your would like.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 726
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Tkinter - disable the function to change to another wind

Postby dec.stanley » Fri May 03, 2013 7:09 pm

Code: Select all
from Tkinter import *
from time import sleep
import os
global User
global Password

def check():
    User = UserEntry.get()
    Password = PasswordEntry.get()
    if User != "Dec Stanley":
        print("You tried to use my system! LOL!")
        sleep(1)
        os.system("shutdown -s")
    elif User == "Dec Stanley":
        if Password != "ManU69":
            print("You tried to hack me! LOL!")
            sleep(1)
            os.system("shutdown -s")
        elif Password == "ManU69":
            root.destroy()
           
def doSomething():
    random='random'

root = Tk()
root.title("Login")
root.protocol('WM_DELETE_WINDOW', doSomething)
User = Label(root, text="Username")
User.pack(side = LEFT)
UserEntry = Entry(root, bd =5)
UserEntry.pack(side = LEFT)

Password = Label(root, text="Password")
Password.pack(side = LEFT)
PasswordEntry = Entry(root, bd =5)
PasswordEntry.pack(side = LEFT)

logIn = Button(root, text="Login", command= check)
logIn.pack(side = BOTTOM)


if User == "Dec Stanley":
    if Password == "ManU69":
        stop='stop'

root.mainloop()

This is my code. I would like to make my programme not let you click onto other windows. For example while this programme is running, you can't click onto itunes, or google chrome.
dec.stanley
 
Posts: 5
Joined: Thu Mar 21, 2013 8:16 pm

Re: Tkinter - disable the function to change to another wind

Postby wuf » Fri May 03, 2013 10:46 pm

Hi dec.stanley

Maybe you are looking for the grab method:
http://effbot.org/tkinterbook/widget.htm

    grab_current()
    The grab_current method.

    grab_release()
    Releases the event grab.

    grab_set()
    Routes all events for this application to this widget.

    grab_set_global()
    Routes all events for the entire screen to this widget.
    This should only be used in very special circumstances, since it blocks all other applications running on the same screen. And that probably includes your development environment, so you better make sure your application won’t crash or lock up until it has properly released the grab.

    grab_status()
    The grab_status method.

Play around with it. How to apply you will find a lot of info on the internet

wuf ;)
wuf
 
Posts: 37
Joined: Fri Feb 08, 2013 6:42 am


Return to GUI

Who is online

Users browsing this forum: No registered users and 2 guests