Hướng dẫn python windows error message
I have a program and if you enter the ip address wrong the shell window will produce a socket error. I want to create a pop up message box that runs anytime I see a certain error in the shell window. I cant really find a whole lot of info on something like this. Sunny Patel 7,5542 gold badges31 silver badges42 bronze badges asked Jun 10, 2019 at 17:33 2 You can use PySimple GUI. It's easy to implement. For that you need to install it. You can Install it through this command :- pip install PySimpleGUICode for Invalid Ip address of generating Pop Up is as follow:-
Hope this Helpful ! answered Jun 10, 2019 at 18:07 Urvi SoniUrvi Soni 3041 gold badge2 silver badges11 bronze badges 1 you could do something like this if you want a popup message box if you are using windows.
else you could use Tkinter using
check this tutorial for more answered Jun 10, 2019 at 17:42 painorpainor 9611 gold badge7 silver badges23 bronze badges 1 Does Tcl/Tk fit your use case?
answered Jun 10, 2019 at 17:52 4 The Tkinter library has many built-in functions and methods which can be used to implement the functional part of an application. We can use messagebox module in Tkinter to create various popup dialog boxes. The messagebox property has different types of built-in popup windows that the users can use in their applications. If you need to display the error messagebox in your application, you can use showerror("Title", "Error Message") method. This method can be invoked with the messagebox itself. Example# Import the required libraries from tkinter import * from tkinter import messagebox # Create an instance of tkinter frame or window win = Tk() # Set the size of the tkinter window win.geometry("700x350") # Define a function to show the error message def on_click(): messagebox.showerror('Python Error', 'Error: This is an Error Message!') # Create a label widget label = Label(win, text="Click the button to show the message ", font=('Calibri 15 bold')) label.pack(pady=20) # Create a button to delete the button b = Button(win, text="Click Me", command=on_click) b.pack(pady=20) win.mainloop() OutputWhen you run the above code, it will show a button widget and a label in the window. Click the button to show the error message. Updated on 06-Aug-2021 07:40:41
|