USB mode
14. dubna 2010Lang: cs
#!/usr/bin/env python
#! coding:utf8
'''
Created on 11.3.2010
@author: Josef 'multi' Jebavý
mail: josef dot jebavy at gmail.com
web: http://multi.xeres.cz
'''
import elementary, dbus, evas
def getDbusObject (bus, busname , objectpath , interface):
dbusObject = bus.get_object(busname, objectpath)
return dbus.Interface(dbusObject, dbus_interface=interface)
class UsbBox(elementary.Box):
def __init__(self, window):
self.window = window
elementary.Box.__init__(self, self.window)
self.usbDBUS = getDbusObject (dbus.SystemBus(), "org.freesmartphone.ousaged", "/org/freesmartphone/Usage", "org.freesmartphone.Usage")
self.toggle = elementary.Toggle(self.window)
self.toggle.label_set("UsbHost:")
self.toggle.size_hint_align_set(-1.0, 0.0)
self.toggle.states_labels_set("Request", "Release")
# self.toggle.state_set(1)
self.toggle._callback_add('changed', self.mode_handle)
self.pack_start(self.toggle)
self.toggle.show()
def __del__(self):
if self.toggle.state_get():
self.usbDBUS.ReleaseResource("UsbHost")
def mode_handle(self, obj):
if obj.state_get():
self.usbDBUS.RequestResource("UsbHost")
else:
self.usbDBUS.ReleaseResource("UsbHost")
class USBmode:
def destroy(self, event, *args, **kargs):
"""metoda ktera zavre okno a ukonci program"""
self.usbDBUS.ReleaseResource("UsbHost")
elementary.exit()
def __init__(self):
self.window = elementary.Window("USBmode", elementary.ELM_WIN_BASIC)
self.window.title_set("USB mode")
self.window.callback_destroy_add(self.destroy)
bg = elementary.Background(self.window)
self.window.resize_object_add(bg)
bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
bg.show()
self.box = elementary.Box(self.window)
self.box.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
self.box.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
self.box.show()
self.window.resize_object_add(self.box)
usbBox = UsbBox(self.window)
self.box.pack_end(usbBox)
usbBox.show()
self.window.show()
elementary.run()
elementary.shutdown()
if __name__ == "__main__":
print "spoustim se "
USBmode()
Články na podobné téma
Odběr novinek
Pokud máte zájem dostávat příležitostně na email novinky.
Můžete se vyplněním emailu registrovat k
odběru novinek.
+