Python Forum
Keeps showing prevuios inputs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keeps showing prevuios inputs
#1
python Type Wall
Hello!
I'm making a Python module to get customised pop-ups.
But when I save the output to a variable (var = func(a, b)), and then print it out, it prints out the input I entered previously! Why?
Codes:
msg_return(return value) function code:
def msg_return(returnvalue):
    global msg_outputvalue
    msg_outputvalue = returnvalue
    msg_outputvalue = returnvalue
entry1 code:
    elif msgbox_widgets == 'input':
        msgbox_entry1 = Entry(msgbox_window, width=32, font=('Futura', 16))
        msgbox_entry1.place(x=145, y=82)
        msgbox_button1 = Button(msgbox_window, text='Cancel', fg='gray70', font=('Futura', 20), command= lambda: [msg_return('"Cancel"_button-clicked'), msgbox_window.destroy()])
        msgbox_button1.place(x=438, y=82)
        msgbox_button2 = Button(msgbox_window, text='Okay', fg='gray70', font=('Futura', 20), command= lambda: [msg_return(msgbox_entry1.get()), msgbox_window.destroy()])
        msgbox_button2.place(x=390, y=82)
widget checker whole code:
        
    if msgbox_widgets == 'ok_cancel':
        msgbox_button1 = Button(msgbox_window, text='Cancel', fg='gray70', font=('Futura', 20), command= lambda: [msg_return('"Cancel"_button-clicked'), msgbox_window.destroy()])
        msgbox_button1.place(x=438, y=82)
        msgbox_button2 = Button(msgbox_window, text='Okay', fg='gray70', font=('Futura', 20), command= lambda: [msg_return('"Okay"_button-clicked'), msgbox_window.destroy()])
        msgbox_button2.place(x=390, y=82)
    elif msgbox_widgets == 'input':
        msgbox_entry1 = Entry(msgbox_window, width=32, font=('Futura', 16))
        msgbox_entry1.place(x=145, y=82)
        msgbox_button1 = Button(msgbox_window, text='Cancel', fg='gray70', font=('Futura', 20), command= lambda: [msg_return('"Cancel"_button-clicked'), msgbox_window.destroy()])
        msgbox_button1.place(x=438, y=82)
        msgbox_button2 = Button(msgbox_window, text='Okay', fg='gray70', font=('Futura', 20), command= lambda: [msg_return(msgbox_entry1.get()), msgbox_window.destroy()])
        msgbox_button2.place(x=390, y=82)
    else:
        print('CONSOLE ERROR: No such supported pop-up type: ' + msgbox_type)
    return msg_outputvalue

#Usage: msg_showmsgbox('warning_message', 'title', 'content Hello! Welcome to a brand new oper\nating system corwinus! ', 'ok_cancel')


Basically, I want the user to input something in the entry box and then I want to print it out!
But the output is wrong! It shows the previous value of the entry1.get()!

The first value which was set to the msg_output:
Output:
None
The first output:
Output:
None
but it should be Input No.1
The second output
Output:
Input No.1
but it should be Input No.2
Videos: PLEASE WATCH THE VIDEO CAREFULLY! PAY ATTENTION TO THE IDLE SHELL AND THE TKINTER WINDOWS!

Thanks!
Reply
#2
Start by adding print('msg_return({})'.format(repr(returnvalue))) in function msg_return to see if it gets correctly called.
Reply
#3
What are you using ? Tkinter, PyQt, PySide2 or something else
Reply
#4
(Jan-07-2020, 04:01 PM)Denni Wrote: What are you using ? Tkinter, PyQt, PySide2 or something else

I use Tkinter.
Reply
#5
(Jan-06-2020, 09:34 AM)Gribouillis Wrote: Start by adding print('msg_return({})'.format(repr(returnvalue))) in function msg_return to see if it gets correctly called.
It does @Gribouillis
Reply
#6
I'm afraid you'll have to post the whole code. It is difficult to diagnose an error with incomplete information.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020