Help a programming Noob out please - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Help a programming Noob out please (/thread-29404.html) |
Help a programming Noob out please - sebz2019uk - Sep-01-2020 Hey guys. What I'm trying to achieve is to output the text for the text string generator out to a text box on my GUI. Im at my wits end with this haha. I would like the 'Generate' button to generate another password. As it stands. When you run the app. It outputs the generated password to the shell. import random import string # get random string password with letters, digits, and symbols def get_random_password_string(length): password_characters = string.ascii_letters + string.digits + string.punctuation password = ''.join(random.choice(password_characters) for i in range(length)) print("Random Password:", password) get_random_password_string(8) from tkinter import * window=Tk() b1=Button(text="Generate") b1.grid(row=2,column=3) def redirector(inputStr): textbox.insert(INSERT, inputStr) title_text=StringVar() e3=Entry(window, textvariable="Author_text") e3.grid(row=2, column=0) l1=Label(window, text="Author: Sebz Technologies") l1.grid (row=1, column=0) l1=Label(window, text="Title: Password Generator") l1.grid (row=0, column=0) sys.stdout.write = redirector #whenever sys.stdout.write is called, redirector is called. window.mainloop() RE: Help a programming Noob out please - DPaul - Sep-04-2020 Your Button instance should have a 'command= ' parameter to call the get_random_password... function. Paul |