fork download
  1. # -*- coding:utf-8 -*-
  2.  
  3. import tkinter as tk
  4.  
  5. class Application(tk.Frame):
  6. def __init__(self, master=None):
  7. super().__init__(master)
  8. self.create_widgets()
  9. self.pack()
  10.  
  11. def do_feed(self):
  12. print("Hello, tkinter")
  13.  
  14. def create_widgets(self):
  15. self.label = tk.Label(self)
  16. self.label["text"] = "(画像をここに)"
  17. self.label["width"] = 20
  18. self.label["height"] = 10
  19. self.label.pack()
  20.  
  21. self.button1 = tk.Button(self, command=self.do_feed)
  22. self.button1["text"] = "エサをあげる"
  23. self.button1.pack()
  24.  
  25. root = tk.Tk()
  26. root.title("ちゃんと育ててね")
  27. root.minsize(200, 200)
  28. root.maxsize(200, 200)
  29. app = Application(root)
  30. app.mainloop()
  31.  
Runtime error #stdin #stdout #stderr 0.06s 15340KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 25, in <module>
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable