16 odpowiedzi
+ 20
its possible with the kivy or tikner libraries. but they are not available on sololearn.
+ 10
If you use a User interface Library in Python you can!
Example using Kivy:
https://kivy.org/doc/stable/api-kivy.uix.popup.html
popup = Popup(title='Test popup', content=Label(text='Hello world'), auto_dismiss=False)
popup.open()
+ 10
With tkinter:
import tkinter.messagebox
tkinter.messagebox.showinfo(title, text)
there are a lot more useful messageboxes in tkinter.messagebox
+ 8
Implementing a GUI is not the *only* way to display the alert-box. If I remember correctly, you can also accomplish this via use of either the os module or sys module. I'll have to look into this later as this has made me curious. Lol.
+ 6
Arthur I ran it on pydroid.
It gave a gray screen
+ 6
How about my code? Isn't it the answer?
https://code.sololearn.com/cey1rm5X9PYC/?ref=app
https://code.sololearn.com/cNsKyh6qJxv0/?ref=app
+ 5
Tim
Ulisses Cruz
LONGTIE👔
And I would have to download these and use IDLE or another Python editor?
+ 5
it help me too.
+ 5
Kivy, PyQt5... thats what i know
+ 4
Ok, thanks
+ 4
DrChicken24
In tkinter
from tkinter import *
window = Tk()
alert = Tk()
def exit():
exit()
def alert():
x = Label(alert,text = "Hello world")
x.pack()
Okay = Button(alert,text = "exit",witdth = 20,bg = "red",command = exit)
Okay.pack()
alert.mainloop()
Button = Button(window,text = "Alert",bg = "green",width = 20, command = alert)
window.geometry("500x400+200+200")
Button.pack()
window.mainloop()
I did it on my way, i dont think there is a method for doing that
+ 3
tkinter is in the standart library. So it works on every machine with python except SoloLearn.
+ 3
from kivy.app import App
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.factory import Factory
class Example(FloatLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.init_popup()
def init_popup(self):
# create content popup (ObjectReference)
content = Button(
text='Close',
size_hint=(.2, .1)
)
# create a popup window
popup = Popup(
title='Test Popup',
content=content,
size_hint=(None, None),
size=(400, 400),
auto_dismiss=False
)
# close popup
content.bind(on_press=lambda instance:popup.dismiss())
button = Button(
text='Show Popup',
size_hint=(None, None),
size=(200, 50),
pos_hint={'center_x': 0.5, 'center_y': 0.5}
)
button.bind(on_release=lambda instance:popup.open())
self.add_widget(button)
class ExampleApp(App):
title = 'Popup Example'
def build(self):
return Example()
ExampleApp().run()
+ 2
LONGTIE👔 Pydroid cant create two windowns, only one
The gray screen is the button who when pressed creat another window(the alert) with a red button to close the window
+ 1
Tim Can you do this in a actual code for me?
0
In django or flask we will written HTML, CSS, JS Anyone programming language in python