File: status_window.py

package info (click to toggle)
fceux 2.3.0%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 8,904 kB
  • sloc: cpp: 108,328; ansic: 10,341; sh: 3,386; python: 424; pascal: 391; perl: 82; makefile: 70; lisp: 60
file content (40 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# A cool thing that i don't feel like explaining
import gtk
import gobject
import os
class shit:
  def __init__(self, command, title="Status Window"):
    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    self.window.set_default_size(400,300)
    self.window.set_title(title)

    self.scroll = gtk.ScrolledWindow()
    self.scroll.set_property("hscrollbar-policy", gtk.POLICY_NEVER)

    self.buffer = gtk.TextBuffer()
    
    self.text_view = gtk.TextView(self.buffer)
    self.text_view.set_editable(False)
    self.window.add(self.scroll)
    self.scroll.add(self.text_view)

    gobject.timeout_add(10, self.get_output)
    
    self.handle = os.popen(command, "r",1)
    self.add(self.handle.readlines())
  def get_output(self):
    self.add(self.handle.read())

  def show(self):
    self.window.show_all()

  def hide(self):
    self.window.hide_all()
  
  def add(self, string):
    self.buffer.insert_at_cursor(string)

myshit = shit("fceu-server", "THE StatUZ")
myshit.show()
gtk.main()