Aug-01-2024, 03:16 PM
(This post was last modified: Aug-01-2024, 03:22 PM by deanhystad.)
Hello, im fairly new to Tkinter and I want to know how can i center the following askstring for a password to the window.
heres my code so far:
here is my whole code incase I need to change it for the password:
heres my code so far:
from tkinter import *
from tkinter.messagebox import showinfo
from tkinter.simpledialog import askstring
from tkinter import simpledialog
top = Tk()
top.title("Lockscreen")
top.geometry("1175x1000")
top.config(bg="dark khaki")
def Password():
global win # Declare win as global
win = Tk()
win.geometry("1175x1000")
win.config(bg="dark khaki")
password = askstring('Password', 'Please enter your password:', show="*")i want the "password = askstring('Password', 'Please entet your password:', show="*") to show up in the center of the screen.here is my whole code incase I need to change it for the password:
from tkinter import *
from tkinter.messagebox import showinfo
from tkinter.simpledialog import askstring
from tkinter import simpledialog
top = Tk()
top.title("Lockscreen")
top.geometry("1175x1000")
top.config(bg="dark khaki")
def Password():
global win # Declare win as global
win = Tk()
win.geometry("1175x1000")
win.config(bg="dark khaki")
password = askstring('Password', 'Please enter your password:', show="*")
if password == ("Password"):
win.title("Desktop") # Assign title to the existing win instance
win.geometry("1175x1000")
win.config(bg="dark khaki")
def searchBar():
search = askstring('Search Bar', 'Search the web')
showinfo('Error', 'URL not found!')
command=searchBrowser()
def searchBrowser():
new_win = Tk() # Create a new window instance for the browser
new_win.title("Web Browser")
new_win.geometry("1175x1000")
new_win.config(bg="dark khaki")
B = Button(new_win, text="Search Bar", command=searchBar)
B.place(x=450, y=25)
new_win.mainloop() # Start the event loop for the browser window
B = Button(win, text="Web Browser", command=searchBrowser)
B.place(x=25, y=25)
def Images():
new_win = Tk() # Create a new window instance for Images
new_win.title("Images")
new_win.geometry("536x262")
new_win.mainloop() # Start the event loop for the Images window
def Minesweeper():
import subprocess
subprocess.run(["python", "Minesweeper.py"])
def downloads():
new_win = Tk() # Create a new window instance for Downloads
new_win.title("Downloads")
new_win.geometry("1175x1000")
new_win.config(bg="dark khaki")
B = Button(new_win, text="Minesweeper.exe", command=Minesweeper)
B.place(x=25, y=25)
new_win.mainloop() # Start the event loop for the Downloads window
def fileExplorer():
new_win = Tk() # Create a new window instance for File Explorer
new_win.title("File Explorer")
new_win.geometry("1175x1000")
new_win.config(bg="dark khaki")
B = Button(new_win, text="Downloads", command=downloads)
B.place(x=25, y=25)
B = Button(new_win, text="Images", command=Images)
B.place(x=25, y=55)
new_win.mainloop() # Start the event loop for the File Explorer window
B = Button(win, text="File Explorer", command=fileExplorer)
B.place(x=25, y=55)
win.mainloop() # Start the event loop for the Desktop window
if password != ("Password"):
showinfo(title="Error", message="Password Incorrect")
B = Button(top, text ="Login", command = Password)
B.place(x=480,y=250)
top.mainloop()
deanhystad write Aug-01-2024, 03:22 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
