python - tkinter overrideredirect stops entry working -
i create "borderless" window in python , code works without overrideredirect, when use input disallowed. can not click entry box
*this code needs figured out, in function , there 500 lines of code go :d *
newwindow = tkinter.tk() w = 300 h = 400 ws = 1024 hs = 768 x = (ws/2) - (w/2) y = (hs/2) - (h/2) newwindow.configure(background="#2e393d") newwindow.overrideredirect(true) frame = tkinter.frame(newwindow) name = tkinter.label(newwindow, background="#1c1c1c", width=2, height=4) name.pack() global outputl global inputl inputl = tkinter.stringvar() outputl = tkinter.stringvar() def nomic(empty): reply = inputl.get() inputl.set("") mainprocess(reply) if way == "a": import speech_recognition sr r = sr.recognizer() sr.microphone() source: audio = r.listen(source) try: reply = r.recognize_google(audio) mainprocess(reply) except sr.unknownvalueerror: backcreatefile("i did not understand !") else: inputbox = tkinter.entry(frame, textvariable=inputl, width=40,foreground="#2e393d", background="white", font=("ubuntu", 13)) inputbox.bind("<return>", nomic) inputbox.pack(fill="x") outputlabel = tkinter.label(newwindow, textvariable=outputl) outputlabel.config( background="#2e393d", foreground="white", wraplength=280, pady=10, font=("ubuntu", 13)) outputlabel.pack(fill="x") weatherv = tkinter.stringvar() weatherv.set("current weather - " + status) weatherlabel = tkinter.label(newwindow, justify="left", textvariable=weatherv, background="#2e393d", foreground="white", font=("ubuntu", 13), pady=7).pack(fill="x") tempv = tkinter.stringvar() tempv.set("current temperature - " + str(ctemp)) templabel = tkinter.label(newwindow, justify="left", textvariable=tempv, background="#2e393d", foreground="white", font=("ubuntu", 13), pady=7).pack(fill="x") frame.pack()
here minimal code works on windows python 3.6 , tk 8.6. popup in default position, upper left corner screen.
import tkinter tk root = tk.tk() tag = tk.label(root, text='popup entry contents: ') var = tk.stringvar(root, 'var') label = tk.label(root, textvariable=var) tag.pack(side='left') label.pack(side='left') pop = tk.toplevel(root) pop.overrideredirect(true) entry = tk.entry(pop, textvariable=var) entry.pack() #pop.lift() # needed? tk 8.5.18+, not 8.6
test on system, , if works, figure out did differently in code.
Comments
Post a Comment