Skip to main content

Thread: [Python] Curses / Threading / Radio Tray


hi all, sorry vague title couldn't think of better one.

i'm attempting: take radio tray source , strip of references graphical parts (systray.py , gtk references). build curses interface , connect parts responsible audio playback , state change events. have succeeded in reducing code when try make start curses part there problem. curses seems halt execution of audio player.

source of radio tray can found here: https://bitbucket.org/carlmig/radio-tray/src use these files largely unmodified, modifications have made radiotray.py

original code initializes state mediator, audioplayer , invokes systray.run() contains following gtk-code:
code:
        gtk.gdk.threads_init()         gtk.main()
i replaced call own function
code:
    self.startcurses()
right have outcommented curses part there problem that:
code:
    def startcurses(self):         #self.screen = curses.initscr()         #self.screen.erase()         s = ""         while s != "quit":             s = raw_input("> ")             #s = self.screen.getstr(2,1)             if s == "play":                self.mediator.playurl("http://somafm.com/poptron.pls")         #curses.endwin()                         def updatesong(self, data):         #self.screen.addstr(1,1,"title: %s" % data['title'])         print "title: %s" % data['title']              def updatestate(self, data):         #self.screen.addstr(1,1,"state: %s" % data['state'])         print "state: %s" % data['state']
in form code works. when typing 'play' station fixed url played. updatestate() , updatesong() methods neatly called when there new information. surprises me bit raw_input() blocking call curses' getstr() method. when type play through curses getstr method first "connecting" event displayed execution of audio part seems halt. confirmed log file no new lines appears when gstreamer part starts firing events on state changes of radio stream.

going on here? makes curses different python code without curses?

can understand post way vague , can supply more code if necessary.

update bump: i'm little closer now, curses working stream playing on background thread. moved curses stuff subclass of thread called cursesthread. noticed have call gtk main loop after invoking cursesthread.

code:
        t = cursesthread(self.mediator,self.provider)         eventsubscriber.bind(eventmanager.song_changed, t.updatesong)         eventsubscriber.bind(eventmanager.state_changed, t.updatestate)         t.start()                  gtk.gdk.threads_init()         gtk.main()
if uncomment gtk lines stream doesn't start playing when invoke playurl method within cursesthread.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [Python] Curses / Threading / Radio Tray


Ubuntu

Comments

Popular posts from this blog

Could not place because the source rectangle is empty

Thread: Using smartcard reader with vpnc

Adobe Font Folio 7.0 or just 7?