Commits

Atsushi Odagiri committed 4b948f1 Draft

bucho is graphical.

Comments (0)

Files changed (4)

 # these methods are exposed to Internet by wsgi.py
 __all__ = ['show', 'latest_status', 'all_status', 'torumemo']
 
-def show():
-    """Say show :-)
-    """
-    _text="""
+_text="""
                                   #############                     ######## 
                                   #############                  ############## 
                                   #############                ################## 
                                                                                     #### 
                                                                                     #### 
     """
+
+def show():
+    """Say show :-)
+    """
     return _text
 
+def show_gui():
+    from bucho.compat import enable_gui
+    if enable_gui:
+        from bucho.gui import BuchoFrame
+        frame = BuchoFrame(_text)
+        frame.run()
+    else:
+        print_("Sorry, bucho is busy.")
+
 
 def latest_status():
     """Print latest bucho's tweet.
                 help='command plugin',
                 dest='plugin',
                 action='store')
-
         self.options, self.args = parser.parse_args()
 
 
         return 0
     return f
 
-for name in ['show', 'latest_status', 'all_status', 'torumemo']:
+for name in ['show', 'latest_status', 'all_status', 'torumemo', 'show_gui']:
     setattr(BuchoCmd, "do_" + name, makecmd(name))
 
 
+enable_gui = True
+Tkinter = None
+try:
+    import Tkinter
+except ImportError:
+    try:
+        import tkinter as Tkinter
+    except:
+        enable_gui = False
+
+from compat import Tkinter as tk
+
+class BuchoFrame(tk.Frame):
+    def __init__(self, text):
+        tk.Frame.__init__(self)
+        self.text = text
+        self.init_view()
+
+    def init_view(self):
+        self.text_view = tk.Text(self)
+        self.text_view.insert(tk.END, self.text)
+        self.text_view.configure(state=tk.DISABLED)
+        self.text_view.pack(fill=tk.BOTH, expand=True)
+
+        
+    def run(self):
+        self.pack(fill=tk.BOTH, expand=True)
+        self.mainloop()