-3

I am very noob and I need help please.

Here's my code:

from tkinter import *

root = Tk()
root.geometry('500x500')

def callback() :
    print ("click!")

b = Button(root, text="OK", command=callback)
b.pack()

mainloop()
martineau
  • 119,623
  • 25
  • 170
  • 301
uri
  • 1
  • 1
  • what's your `mainloop()`? I don't see its definition. Pleas provide a [complete, minimal, verifiable example](https://stackoverflow.com/help/mcve) – Aemyl Apr 04 '19 at 12:07
  • I said I was a noob so I don't know What are you saying – uri Apr 04 '19 at 12:21
  • I only copy this from one blog and I redimesione this – uri Apr 04 '19 at 12:22
  • 1
    Your code works fine. Where are you getting stuck? – FrainBr33z3 Apr 04 '19 at 12:23
  • @Aemyl: `mainloop()` is a function in the `tkinter` module and was brought into scope via the `from tkinter import *` statement. – martineau Apr 04 '19 at 12:26
  • It's possible that the problem is from repl.it (is were I programe)? – uri Apr 04 '19 at 12:28
  • Okey thank you so much – uri Apr 04 '19 at 12:29
  • @martineau shouldn't it be `root.mainloop()`? Or is that equivalent? – Aemyl Apr 04 '19 at 12:42
  • I think it is . – uri Apr 04 '19 at 12:43
  • @Aemyl: `root.mainloop()` would have also worked (since it's also a universal widget method). With or without a widget, it just runs the Tk main loop. – martineau Apr 04 '19 at 12:48
  • 2
    I'm sure that your problem comes from this online python evviroment site. Just run your code on your computer and you will see it works. Don't do Gui programming on online sites. –  Apr 04 '19 at 14:17
  • 3
    tkinter was create to work with local GUI (Windows/XWindow) and local monitor/display. So when you run it online on server then it tries to use GUI on server and monitor connected to server. But servers don't need GUIs or monitors. And they don't have GUIs and monitors. Besides you could't see monitor connected to server. – furas Apr 05 '19 at 02:54
  • okey I will try this – uri Apr 05 '19 at 10:24

2 Answers2

1

Try This:

from Tkinter import *
import tkMessageBox

root = Tk()
root.geometry('200x60')
root.title('Test Application')

def notify():
    tkMessageBox.showwarning('Notification', 'Display is not capable of DPMS!')

b1 = Button(root, text="Run!", command=notify)
b1.pack()

root.mainloop()
Dylan Logan
  • 395
  • 7
  • 18
  • @uri What do you mean it doesn't work? It works perfectly fine on my machine, can you please be more specific, my guess is that you might not have tkMessageBox. – Dylan Logan Apr 05 '19 at 10:30
0

Uri, you should probably run it on your computer instead of on the web. If you are using a chromebook go into settings and enable Linux.

——-Windows-——

Windows Install:

Click here

——-Mac-——

Mac Install:

click here

——-Linux-——

Linux Problems:

click here

Linux Install:

click here