Online video hd

Смотреть жесткое видео

Официальный сайт itartass-sib 24/7/365

Смотреть видео бесплатно

nvbn 12.06.2010 19:14

Python[Решено]pygtk и многопоточность

Решил написать штуку для deadbeef в indicator applet, всё работает, но автоматически не меняется пункт с названием песни.На конференции уже подсказали, нужно было добавить:
1
2
3
4
gtk.gdk.threads_init()
gtk.gdk.threads_enter()
#code
gtk.gdk.threads_leave()


Исправленный код:
 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/python
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

import gtk
import appindicator
import os
import time
import threading
import commands

class interface(threading.Thread):

def __init__(self):
threading.Thread.__init__(self)

def create(self, buf, func = None):
"""Create menu object"""
item = gtk.MenuItem(buf)
if func != None:
item.connect("activate", func, buf)
self.menu.append(item)
item.show()
return(item)

def show(self, widget, string):
"""Show deadbeef"""
os.system('deadbeef')

def play(self, widget, string):
"""Play or pause"""
os.system('deadbeef --pause')

def after(self, widget, string):
"""Next song"""
os.system('deadbeef --next')

def previos(self, widget, string):
"""Previos song"""
os.system('deadbeef --prev')

def run(self):
ind = appindicator.Indicator ("deadbeef", "deadbeef",
appindicator.CATEGORY_APPLICATION_STATUS)
ind.set_status (appindicator.STATUS_ACTIVE)
self.menu = gtk.Menu()
self.now= self.create("Now playing")
self.show = self.create("Show/Hide", self.show)
self.play_menu = self.create("Play/Pause", self.play)
self.next_menu = self.create("Next", self.after)
self.previos_menu = self.create("Previos", self.previos)
ind.set_menu(self.menu)
gtk.main()

class nowplaying(threading.Thread):

def __init__(self):
threading.Thread.__init__(self)

def run(self):
while True:
needle = commands.getoutput('deadbeef --nowplaying "%a - %t"')
needle = needle.splitlines()
try:
int.now.set_label(needle<1>)
except:
int.now.set_label(needle<0>)
time.sleep(1)


if __name__ == "__main__":
gtk.gdk.threads_init()
gtk.gdk.threads_enter()
int = interface()
int.start()
gtk.gdk.threads_leave()
now = nowplaying()
now.start()



Тэги: deadbeef pygtk python
+ 1 -
Похожие Поделиться

CrankY 12.06.2010 19:59 #
+ 2 -
Сам спросил, сам ответил)
Ляпота!
nvbn 12.06.2010 20:31 #
+ 0 -
В конференции просто через 5 минут подсказали)

Смотреть онлайн бесплатно

Онлайн видео бесплатно


Смотреть русское с разговорами видео

Online video HD

Видео скачать на телефон

Русские фильмы бесплатно

Full HD video online

Смотреть видео онлайн

Смотреть HD видео бесплатно

School смотреть онлайн