Python gobject 模块,GObject() 实例源码
我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用gobject.GObject()。
def __init__(self, parent_win, xid=0):
gobject.GObject.__init__(self)
self.parent_win = parent_win
self.xid = xid
self.playing = None
self.paused = False
self.volume = 0
self.mute = False
self.pos = 0.0
self.length = None
self.info = {}
self.fullscreen = False
self.state = PlayerEngine.STATE_NONE
self.menu_items = None
self.setup_menu_items()
# __init__()
def __init__(self, radio, parent=None):
threading.Thread.__init__(self)
gobject.GObject.__init__(self)
self.__queue = {}
if parent:
self.__runlock = parent._get_run_lock()
self.status = lambda msg: parent.status(msg)
else:
self.__runlock = threading.Lock()
self.status = self._status
self.__counter = threading.Semaphore(0)
self.__lock = threading.Lock()
self.__enabled = True
self.radio = radio
def emit(self, *args):
gobject.idle_add(gobject.GObject.emit,self,*args)
def __init__(self, rthread):
gobject.GObject.__init__(self)
self.read_only = False
self._focused = False
self.rthread = rthread
def __init__(self, preview=False):
gobject.GObject.__init__(self)
self.is_preview = preview
# Module init
self.prefs = Preferences
self.keyboard = Keyboard
# create buffer
self.buf = gtksourceview.Buffer()
self.gtksourceview = gtksourceview.View(self.buf)
# setup style and lang managers
self.lm = gtksourceview.LanguageManager()
self.sm = gtksourceview.StyleSchemeManager()
self.lm.set_search_path([LANGDIR])
self.sm.set_search_path([STYLEDIR])
self.buf.set_style_scheme(self.sm.get_scheme('gcode'))
self.buf.set_language(self.lm.get_language('gcode'))
self.buf.set_max_undo_levels(20)
self.gtksourceview.set_show_line_numbers(True)
self.gtksourceview.set_show_line_marks(False)
self.gtksourceview.set_highlight_current_line(False)
# Only allow edit if gcode preview
self.gtksourceview.set_editable(self.is_preview)
self.holder_text = "\t\t\t****No file to preview****"
# Only highlight motion line if not preview
if not self.is_preview:
self.gtksourceview.set_can_focus(False)
self.holder_text = ""
self.gtksourceview.connect('button-press-event', self.on_button_press)
self.gtksourceview.connect('key-press-event', self.on_key_press)
# Set line highlight styles
self.gtksourceview.set_mark_category_background('none', gtk.gdk.Color('#ffffff'))
self.gtksourceview.set_mark_category_background('motion', gtk.gdk.Color('#c5c5c5'))
self.gtksourceview.set_mark_category_background('selected', gtk.gdk.Color('#96fef6'))
self.gtksourceview.set_mark_category_background('error', gtk.gdk.Color('#ff7373'))
self.mark = None
self.current_file = None
self.error_line =None
self.gtksourceview.show()