当前位置: 首页>>代码示例>>Python>>正文


Python Engine.connect方法代码示例

本文整理汇总了Python中engine.Engine.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.connect方法的具体用法?Python Engine.connect怎么用?Python Engine.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在engine.Engine的用法示例。


在下文中一共展示了Engine.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Wolfgang

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import connect [as 别名]
class Wolfgang():

    def __init__(self):
        self.engine = Engine()
        self.lucien = Lucien()

        self.uri = None
        self.is_playing = False
        self._sliderGrabbed = False
        self.loop = False
        self.library = {}

        self.builder = Gtk.Builder()
        self.builder.add_from_file(path.join(path.curdir, "wolfgang.ui"))
        self.builder.connect_signals(self)

        # Sup dawg, I heard you like black,
        # so I put a dark UI in your car so you can drive through the night.
        gtksettings = Gtk.Settings.get_default()
        gtksettings.set_property("gtk-application-prefer-dark-theme", True)
        self.main_toolbar = self.builder.get_object("main_toolbar")
        self.main_toolbar.get_style_context().add_class("primary-toolbar")
        self.main_toolbar.set_sensitive(False)

        self.previous_button = self.builder.get_object("previous_button")
        self.play_button = self.builder.get_object("play_button")
        self.next_button = self.builder.get_object("next_button")
        self.time_slider = self.builder.get_object("time_slider")
        self.next_button.set_sensitive(False)
        self.previous_button.set_sensitive(False)

        self._prepare_treeviews()

        self.window = self.builder.get_object("window1")
        self.window.set_icon_name("rhythmbox")
        self.window.maximize()
        self.window.connect("delete-event", self.quit)
        self.window.show_all()

        self.engine.connect("about_to_finish", self._onAboutToFinish)
        self.engine.connect("error", self._onError)
        self.lucien.connect("discovered", self._new_media)

        # Slight hack to get the user's "Music" XDG directory:
        with open(path.expanduser("~/.config/user-dirs.dirs"), "r") as foo:
            lines = foo.readlines()
            for line in lines:
                if "XDG_MUSIC_DIR" in line:
                    home = path.expanduser("~")
                    music_folder = line.split('"')[1].replace("$HOME", home)
                    break
            foo.close()

        self.lucien.collect(music_folder)

        GObject.timeout_add(500, self._updateSliderPosition)

    """
    UI initialization crack
    """
    def _prepare_treeviews(self):
        self.library_treeview = self.builder.get_object("library_treeview")
        self.playlist_treeview = self.builder.get_object("playlist_treeview")
        self.queue_treeview = self.builder.get_object("queue_treeview")
        # If we enable this, we'll get in trouble in the removeFromQueue method:
        # self.queue_treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)

        self.library_store = Gtk.TreeStore(str) # Only 1 "column" to contain all
        self.playlist_store = Gtk.ListStore(str, str, int)  # title, URI, track number
        self.queue_store = Gtk.ListStore(str, str, str)  # cursor, title, URI
        self.queue_current_iter = None  # To keep track of where the cursor was

        self.library_treeview.set_model(self.library_store)
        self.playlist_treeview.set_model(self.playlist_store)
        self.queue_treeview.set_model(self.queue_store)

        # Library: only one column, with two visible levels (artist, album)
        column = Gtk.TreeViewColumn()
        column_contents = Gtk.CellRendererText()
        column.pack_start(column_contents, True)
        column.add_attribute(column_contents, "text", 0)
        self.library_treeview.append_column(column)

        # Playlist: two columns in the store (title, URI), but only one shown
        column = Gtk.TreeViewColumn("Title")
        title = Gtk.CellRendererText()
        column.pack_start(title, True)
        column.add_attribute(title, "text", 0)
        self.playlist_treeview.append_column(column)

        # Queue: 3 columns in store, 1 shown for cursor, 1 for the track title
        column = Gtk.TreeViewColumn("Cursor")
        cursor = Gtk.CellRendererText()
        column.pack_start(cursor, True)
        column.add_attribute(cursor, "text", 0)
        self.queue_treeview.append_column(column)
        column = Gtk.TreeViewColumn("Title")
        title = Gtk.CellRendererText()
        column.pack_start(title, True)
        column.add_attribute(title, "text", 1)
#.........这里部分代码省略.........
开发者ID:luisbg,项目名称:wolfgang,代码行数:103,代码来源:wolfgang.py

示例2: sleep

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import connect [as 别名]
	print
	while True:
		sleep(1);
		
		if(is_idle()): continue
		
		try:
			window_class = get_window_class()
			window_title = get_window_title()
			
			if window_class != last_window_class or window_title != last_window_title:
				if time > 1:
					print str(time).ljust(6), last_window_class.ljust(30), last_window_title
					
					db.time_add(USER, last_window_class, last_window_title, time)
				
				time = 0
			
			time += 1
			
			last_window_class = window_class
			last_window_title = window_title
		except MySQLdb.OperationalError, e:
			print e
			db.connect()
		except Exception, e:
			print e

print
print
开发者ID:karamfil,项目名称:TimeTraktor,代码行数:32,代码来源:traktor.py


注:本文中的engine.Engine.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。