也许这很明显,我错过了它,或者也许有人已经写了一个很好的指南,而我的(看似详尽的)谷歌搜索未能将其打开,但我一生都无法弄清楚如何获得该死的 python 控制台节奏盒做任何事!
我已经从插件菜单启用它,然后使用工具-> Python 控制台打开它。
它打印
You can access the main window through the 'shell' variable :
<rb.Shell object at 0xa6cdd24 (RBShell at 0xa14e000)>
>>>
Run Code Online (Sandbox Code Playgroud)
但是,在提示符下什么我做型什么!我试过了help
,我试过了exit()
,我试过了print "hello world"
,什么都没做!
当然,所有这些都可以在普通的 Python 控制台中运行。我不知道这里的区别是什么鬼!我应该做点什么而不是按回车键吗?
该Rhythmbox的插件写作指导有,你可以在Python控制台用来控制播放和修改的Rhythmbox命令的几个例子:
播放/暂停
shell.props.shell_player.playpause()
Run Code Online (Sandbox Code Playgroud)停止
shell.props.shell_player.stop()
Run Code Online (Sandbox Code Playgroud)下一首曲目
shell.props.shell_player.do_next()
Run Code Online (Sandbox Code Playgroud)将歌曲添加到播放队列
shell.add_to_queue("file://awsome_song.ogg")
Run Code Online (Sandbox Code Playgroud)显示可视化
import gst
goom = gst.element_factory_make ("goom")
sink = gst.element_factory_make ("ximagesink")
colour = gst.element_factory_make ("ffmpegcolorspace")
b = gst.Bin()
b.add (goom, colour, sink)
b.add_pad(gst.GhostPad("sink", goom.get_pad("sink")))
goom.link(colour)
colour.link(sink)
shell.get_player().props.player.add_tee(b)
Run Code Online (Sandbox Code Playgroud)小智 7
与任何 Python 对象一样,您可以通过对它使用 dir() 方法来了解它的很多信息。这将为您提供一个很好的起点。
You can access the main window through the 'shell' variable :
<rb.Shell object at 0x9e9675c (RBShell at 0x987b018)>
>>> dir(rb.Shell)
['__class__', '__cmp__', '__copy__', '__deepcopy__', '__delattr__', '__dict__',
'__doc__', '__format__', '__gdoc__', '__getattribute__', '__gobject_init__',
'__grefcount__', '__gtype__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
'__subclasshook__', 'add_to_queue', 'add_uri', 'add_widget', 'append_source',
'chain', 'connect', 'connect_after', 'connect_object', 'connect_object_after',
'disconnect', 'disconnect_by_func', 'do_notify', 'emit', 'emit_stop_by_name',
'freeze_notify', 'get_data', 'get_party_mode', 'get_player',
'get_playlist_manager', 'get_properties', 'get_property',
'get_source_by_entry_type', 'get_ui_manager', 'guess_source_for_uri',
'handler_block', 'handler_block_by_func', 'handler_disconnect',
'handler_is_connected','handler_unblock', 'handler_unblock_by_func', 'load_uri',
'notebook_set_page', 'notify', 'notify_custom', 'present', 'props',
'register_entry_type_for_source', 'remove_from_queue', 'remove_widget',
'set_data', 'set_properties', 'set_property', 'stop_emission', 'thaw_notify',
'toggle_visibility', 'weak_ref']
Run Code Online (Sandbox Code Playgroud)
然后,您可以 dir() 任何看起来很有趣的属性,例如“get_player”。
另一个值得关注的地方是您是否在对象上看到了 __doc__ 属性。
>>> print rb.Shell.__doc__
Object RBShell
Signals from RBShell:
visibility-changed (gboolean)
visibility-changing (gboolean, gboolean) -> gboolean
create-song-info (RBSongInfo, gboolean)
removable-media-scan-finished ()
notify-playing-entry (gboolean)
notify-custom (guint, gchararray, gchararray, GdkPixbuf, gboolean)
Properties from RBShell:
no-registration -> gboolean: no-registration
Whether or not to register
no-update -> gboolean: no-update
Whether or not to update the library
dry-run -> gboolean: dry-run
Whether or not this is a dry run
rhythmdb-file -> gchararray: rhythmdb-file
The RhythmDB file to use
playlists-file -> gchararray: playlists-file
The playlists file to use
selected-source -> RBSource: selected-source
Source which is currently selected
db -> RhythmDB: RhythmDB
RhythmDB object
ui-manager -> GtkUIManager: GtkUIManager
GtkUIManager object
clipboard -> RBShellClipboard: RBShellClipboard
RBShellClipboard object
playlist-manager -> RBPlaylistManager: RBPlaylistManager
RBPlaylistManager object
removable-media-manager -> RBRemovableMediaManager: RBRemovableMediaManager
RBRemovableMediaManager object
shell-player -> RBShellPlayer: RBShellPlayer
RBShellPlayer object
window -> GtkWindow: GtkWindow
GtkWindow object
prefs -> RBShellPreferences: RBShellPreferences
RBShellPreferences object
queue-source -> RBPlayQueueSource: queue-source
Queue source
library-source -> RBLibrarySource: library-source
Library source
sourcelist-model -> RBSourceListModel: sourcelist-model
RBSourcelistModel
sourcelist -> RBSourceList: sourcelist
RBSourcelist
source-header -> RBSourceHeader: source header widget
RBSourceHeader
visibility -> gboolean: visibility
Current window visibility
Signals from GObject:
notify (GParam)
Run Code Online (Sandbox Code Playgroud)
天哪,我刚刚发现问题是什么(2.5 年后)——出于某种原因,我的“输入”键映射到两个不同的按键事件,具体取决于数字锁定是否打开或关闭。当 numlock 打开时,它返回KP_ENTER
,当 numlock 关闭时,返回Return
。我总是打开数字锁定键,因为我更喜欢用键盘输入数字。
不幸的是,Rhythmbox 中的 python 控制台只能识别Return
运行命令——KP_ENTER
事件只是进入换行符......
但修复很简单,只需在使用控制台时关闭数字锁定即可。我在其他一些应用程序(通常是游戏)中遇到了这个问题,所以我将寻找一个更好的长期解决方案(也许迫使两者以Return
某种方式映射)......
归档时间: |
|
查看次数: |
7258 次 |
最近记录: |