本文整理匯總了Python中quodlibet.qltk.Button類的典型用法代碼示例。如果您正苦於以下問題:Python Button類的具體用法?Python Button怎麽用?Python Button使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Button類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
def __init__(self, browser):
if self.is_not_unique():
return
super(Preferences, self).__init__()
self.set_border_width(12)
self.set_title(_("Playlist Browser Preferences"))
self.set_default_size(420, 240)
self.set_transient_for(qltk.get_top_parent(browser))
box = Gtk.VBox(spacing=6)
edit_frame = self.edit_display_pane(browser, _("Playlist display"))
box.pack_start(edit_frame, False, True, 12)
main_box = Gtk.VBox(spacing=12)
close = Button(_("_Close"), Icons.WINDOW_CLOSE)
close.connect('clicked', lambda *x: self.destroy())
b = Gtk.HButtonBox()
b.set_layout(Gtk.ButtonBoxStyle.END)
b.pack_start(close, True, True, 0)
main_box.pack_start(box, True, True, 0)
self.use_header_bar()
if not self.has_close_button():
main_box.pack_start(b, False, True, 0)
self.add(main_box)
close.grab_focus()
self.show_all()
示例2: PluginPreferences
def PluginPreferences(self, win):
box = Gtk.VBox(spacing=12)
# api key section
def key_changed(entry, *args):
config.set("plugins", "fingerprint_acoustid_api_key",
entry.get_text())
button = Button(_("Request API key"), Icons.NETWORK_WORKGROUP)
button.connect("clicked",
lambda s: util.website("https://acoustid.org/api-key"))
key_box = Gtk.HBox(spacing=6)
entry = UndoEntry()
entry.set_text(get_api_key())
entry.connect("changed", key_changed)
label = Gtk.Label(label=_("API _key:"))
label.set_use_underline(True)
label.set_mnemonic_widget(entry)
key_box.pack_start(label, False, True, 0)
key_box.pack_start(entry, True, True, 0)
key_box.pack_start(button, False, True, 0)
box.pack_start(Frame(_("AcoustID Web Service"),
child=key_box), True, True, 0)
return box
示例3: __init__
def __init__(self, parent, default="", **kwargs):
if self.is_not_unique():
return
super(TextEdit, self).__init__()
self.set_title(_("Edit Display"))
self.set_transient_for(qltk.get_top_parent(parent))
self.set_border_width(12)
self.set_default_size(420, 190)
vbox = Gtk.VBox(spacing=12)
close = Button(_("_Close"), Icons.WINDOW_CLOSE)
close.connect('clicked', lambda *x: self.destroy())
b = Gtk.HButtonBox()
b.set_layout(Gtk.ButtonBoxStyle.END)
b.pack_start(close, True, True, 0)
self.box = box = self.Box(default, **kwargs)
vbox.pack_start(box, True, True, 0)
self.use_header_bar()
if not self.has_close_button():
vbox.pack_start(b, False, True, 0)
self.add(vbox)
self.apply = box.apply
self.revert = box.revert
close.grab_focus()
self.get_child().show_all()
示例4: enabled
def enabled(self):
self.scrolled_window = Gtk.ScrolledWindow()
self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.adjustment = self.scrolled_window.get_vadjustment()
self.textview = Gtk.TextView()
self.textbuffer = self.textview.get_buffer()
self._italics = self.textbuffer.create_tag("italic", style="italic",
foreground="grey")
self.textview.set_editable(False)
self.textview.set_cursor_visible(False)
self.textview.set_wrap_mode(Gtk.WrapMode.WORD)
self.textview.set_justification(Gtk.Justification.CENTER)
self.textview.connect('key-press-event', self.key_press_event_cb)
add_css(self.textview, "* { padding: 6px; }")
vbox = Gtk.VBox()
vbox.pack_start(self.textview, True, True, 0)
self._edit_button = Button("Edit Lyrics", Icons.EDIT)
hbox = Gtk.HBox()
hbox.pack_end(self._edit_button, False, False, 3)
vbox.pack_start(hbox, False, False, 3)
self.scrolled_window.add(vbox)
self.textview.show()
self.scrolled_window.show()
self._sig = None
cur = app.player.info
if cur is not None:
cur = SongWrapper(cur)
self.plugin_on_song_started(cur)
示例5: __init__
def __init__(self, count=0, text="", initial={}, limit=3):
"""count: the total amount of items expected, 0 for unknown/indefinite
text: text to display in the label; may contain % formats
initial: initial values for % formats (text % initial)
limit: count must be greater than limit (or 0) for pause/stop to appear
The current iteration of the counter can be gotten as
self.current. count can be gotten as self.count.
"""
super(WaitLoadBase, self).__init__()
self._label = Gtk.Label()
self._label.set_use_markup(True)
self._progress = Gtk.ProgressBar()
self._progress.set_pulse_step(0.08)
self.pulse = self._progress.pulse
self.set_fraction = self._progress.set_fraction
self.set_text = self._label.set_markup
self.setup(count, text, initial)
if self.count > limit or self.count == 0:
# Add stop/pause buttons. count = 0 means an indefinite
# number of steps.
self._cancel_button = Button(_("_Stop"), Icons.PROCESS_STOP)
self._pause_button = ToggleButton(_("P_ause"),
Icons.MEDIA_PLAYBACK_PAUSE)
self._cancel_button.connect('clicked', self.__cancel_clicked)
self._pause_button.connect('clicked', self.__pause_clicked)
else:
self._cancel_button = None
self._pause_button = None
示例6: __init__
def __init__(self, filters, browser, parent=None):
super(SelectionWindow, self).__init__()
self.set_border_width(10)
self.set_title(FilterAll.PLUGIN_NAME)
self.set_default_size(200, 250)
self.set_transient_for(parent)
model = Gtk.ListStore(bool, str, str)
for key, value in sorted(filters.items()):
model.append(row=[False, key, value])
toggle = Gtk.CellRendererToggle()
toggle.connect("toggled", self.__toggeled, model, browser)
text = Gtk.CellRendererText()
toggle_column = Gtk.TreeViewColumn("", toggle, active=0)
column = Gtk.TreeViewColumn(_("Tag"), text, text=1)
view = Gtk.TreeView(model)
view.append_column(toggle_column)
view.append_column(column)
sw = Gtk.ScrolledWindow()
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.set_shadow_type(Gtk.ShadowType.IN)
sw.add(view)
buttons = Gtk.HButtonBox()
buttons.set_spacing(6)
buttons.set_layout(Gtk.ButtonBoxStyle.END)
close = Button(_("_Close"), Icons.WINDOW_CLOSE)
close.connect('clicked', lambda *x: self.destroy())
buttons.pack_start(close, True, True, 0)
box = Gtk.VBox(spacing=12)
box.pack_start(sw, True, True, 0)
box.pack_start(buttons, False, True, 0)
self.add(box)
self.show_all()
示例7: PluginPreferences
def PluginPreferences(self, *args):
vbox = Gtk.VBox(spacing=12)
label = Gtk.Label(label=_("Visualiser executable:"))
def edited(widget):
self.executable = widget.get_text()
entry = UndoEntry()
entry.connect('changed', edited)
entry.set_text(self.executable)
hbox = Gtk.HBox(spacing=6)
hbox.pack_start(label, False, False, 0)
hbox.pack_start(entry, True, True, 0)
vbox.pack_start(hbox, True, True, 0)
def refresh_clicked(widget):
self.disabled()
self.enabled()
refresh_button = Button(_("Reload"), Icons.VIEW_REFRESH)
refresh_button.connect('clicked', refresh_clicked)
vbox.pack_start(refresh_button, False, False, 0)
return vbox
示例8: __init__
def __init__(self, browser):
if self.is_not_unique():
return
super(Preferences, self).__init__()
self._browser = browser
self.set_transient_for(qltk.get_top_parent(browser))
self.set_default_size(350, 225)
self.set_border_width(12)
self.set_title(_("Album Collection Preferences"))
vbox = Gtk.VBox(spacing=12)
editor = PatternEditor()
editor.headers = get_headers()
apply = Button(_("_Apply"))
connect_obj(apply, "clicked", self.__apply, editor, False)
cancel = Button(_("_Cancel"))
cancel.connect("clicked", lambda x: self.destroy())
box = Gtk.HButtonBox()
box.set_spacing(6)
box.set_layout(Gtk.ButtonBoxStyle.END)
box.pack_start(apply, True, True, 0)
self.use_header_bar()
if not self.has_close_button():
box.pack_start(cancel, True, True, 0)
vbox.pack_start(editor, True, True, 0)
vbox.pack_start(box, False, True, 0)
self.add(vbox)
apply.grab_focus()
self.show_all()
示例9: __init__
def __init__(self, parent, library):
super(RenameFiles, self).__init__(spacing=6)
self.__skip_interactive = False
self.set_border_width(12)
hbox = Gtk.HBox(spacing=6)
cbes_defaults = NBP_EXAMPLES.split("\n")
self.combo = ComboBoxEntrySave(NBP, cbes_defaults,
title=_("Path Patterns"),
edit_title=_(u"Edit saved patterns…"))
self.combo.show_all()
hbox.pack_start(self.combo, True, True, 0)
self.preview = qltk.Button(_("_Preview"), Icons.VIEW_REFRESH)
self.preview.show()
hbox.pack_start(self.preview, False, True, 0)
self.pack_start(hbox, False, True, 0)
self.combo.get_child().connect('changed', self._changed)
model = ObjectStore()
self.view = Gtk.TreeView(model=model)
self.view.show()
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(self.view)
self.pack_start(sw, True, True, 0)
self.pack_start(Gtk.VBox(), False, True, 0)
# rename options
rename_options = Gtk.HBox()
# file name options
filter_box = FilterPluginBox(self.handler, self.FILTERS)
filter_box.connect("preview", self.__filter_preview)
filter_box.connect("changed", self.__filter_changed)
self.filter_box = filter_box
frame_filename_options = Frame(_("File names"), filter_box)
frame_filename_options.show_all()
rename_options.pack_start(frame_filename_options, False, True, 0)
# album art options
albumart_box = Gtk.VBox()
# move art
moveart_box = Gtk.VBox()
self.moveart = ConfigCheckButton(
_('_Move album art'),
"rename", "move_art", populate=True)
self.moveart.set_tooltip_text(
_("See '[albumart] filenames' config entry " +
"for image search strings"))
self.moveart.show()
moveart_box.pack_start(self.moveart, False, True, 0)
self.moveart_overwrite = ConfigCheckButton(
_('_Overwrite album art at target'),
"rename", "move_art_overwrite", populate=True)
self.moveart_overwrite.show()
moveart_box.pack_start(self.moveart_overwrite, False, True, 0)
albumart_box.pack_start(moveart_box, False, True, 0)
# remove empty
removeemptydirs_box = Gtk.VBox()
self.removeemptydirs = ConfigCheckButton(
_('_Remove empty directories'),
"rename", "remove_empty_dirs", populate=True)
self.removeemptydirs.show()
removeemptydirs_box.pack_start(self.removeemptydirs, False, True, 0)
albumart_box.pack_start(removeemptydirs_box, False, True, 0)
frame_albumart_options = Frame(_("Album art"), albumart_box)
frame_albumart_options.show_all()
rename_options.pack_start(frame_albumart_options, False, True, 0)
self.pack_start(rename_options, False, True, 0)
# Save button
self.save = Button(_("_Save"), Icons.DOCUMENT_SAVE)
self.save.show()
bbox = Gtk.HButtonBox()
bbox.set_layout(Gtk.ButtonBoxStyle.END)
bbox.pack_start(self.save, True, True, 0)
self.pack_start(bbox, False, True, 0)
render = Gtk.CellRendererText()
column = TreeViewColumn(title=_('File'))
column.pack_start(render, True)
def cell_data_file(column, cell, model, iter_, data):
entry = model.get_value(iter_)
cell.set_property("text", entry.name)
column.set_cell_data_func(render, cell_data_file)
column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.view.append_column(column)
render = Gtk.CellRendererText()
render.set_property('editable', True)
#.........這裏部分代碼省略.........
示例10: RenameFiles
class RenameFiles(Gtk.VBox):
title = _("Rename Files")
FILTERS = [SpacesToUnderscores, StripWindowsIncompat, StripDiacriticals,
StripNonASCII, Lowercase]
handler = RenameFilesPluginHandler()
IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'bmp']
@classmethod
def init_plugins(cls):
PluginManager.instance.register_handler(cls.handler)
def __init__(self, parent, library):
super(RenameFiles, self).__init__(spacing=6)
self.__skip_interactive = False
self.set_border_width(12)
hbox = Gtk.HBox(spacing=6)
cbes_defaults = NBP_EXAMPLES.split("\n")
self.combo = ComboBoxEntrySave(NBP, cbes_defaults,
title=_("Path Patterns"),
edit_title=_(u"Edit saved patterns…"))
self.combo.show_all()
hbox.pack_start(self.combo, True, True, 0)
self.preview = qltk.Button(_("_Preview"), Icons.VIEW_REFRESH)
self.preview.show()
hbox.pack_start(self.preview, False, True, 0)
self.pack_start(hbox, False, True, 0)
self.combo.get_child().connect('changed', self._changed)
model = ObjectStore()
self.view = Gtk.TreeView(model=model)
self.view.show()
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(self.view)
self.pack_start(sw, True, True, 0)
self.pack_start(Gtk.VBox(), False, True, 0)
# rename options
rename_options = Gtk.HBox()
# file name options
filter_box = FilterPluginBox(self.handler, self.FILTERS)
filter_box.connect("preview", self.__filter_preview)
filter_box.connect("changed", self.__filter_changed)
self.filter_box = filter_box
frame_filename_options = Frame(_("File names"), filter_box)
frame_filename_options.show_all()
rename_options.pack_start(frame_filename_options, False, True, 0)
# album art options
albumart_box = Gtk.VBox()
# move art
moveart_box = Gtk.VBox()
self.moveart = ConfigCheckButton(
_('_Move album art'),
"rename", "move_art", populate=True)
self.moveart.set_tooltip_text(
_("See '[albumart] filenames' config entry " +
"for image search strings"))
self.moveart.show()
moveart_box.pack_start(self.moveart, False, True, 0)
self.moveart_overwrite = ConfigCheckButton(
_('_Overwrite album art at target'),
"rename", "move_art_overwrite", populate=True)
self.moveart_overwrite.show()
moveart_box.pack_start(self.moveart_overwrite, False, True, 0)
albumart_box.pack_start(moveart_box, False, True, 0)
# remove empty
removeemptydirs_box = Gtk.VBox()
self.removeemptydirs = ConfigCheckButton(
_('_Remove empty directories'),
"rename", "remove_empty_dirs", populate=True)
self.removeemptydirs.show()
removeemptydirs_box.pack_start(self.removeemptydirs, False, True, 0)
albumart_box.pack_start(removeemptydirs_box, False, True, 0)
frame_albumart_options = Frame(_("Album art"), albumart_box)
frame_albumart_options.show_all()
rename_options.pack_start(frame_albumart_options, False, True, 0)
self.pack_start(rename_options, False, True, 0)
# Save button
self.save = Button(_("_Save"), Icons.DOCUMENT_SAVE)
self.save.show()
bbox = Gtk.HButtonBox()
bbox.set_layout(Gtk.ButtonBoxStyle.END)
bbox.pack_start(self.save, True, True, 0)
self.pack_start(bbox, False, True, 0)
render = Gtk.CellRendererText()
column = TreeViewColumn(title=_('File'))
column.pack_start(render, True)
#.........這裏部分代碼省略.........
示例11: ViewLyrics
class ViewLyrics(EventPlugin, UserInterfacePlugin):
"""The plugin for viewing lyrics in the main window."""
PLUGIN_ID = 'View Lyrics'
PLUGIN_NAME = _('View Lyrics')
PLUGIN_DESC = _('Automatically displays tag or file-based lyrics '
'in a sidebar.')
PLUGIN_ICON = Icons.FORMAT_JUSTIFY_FILL
def enabled(self):
self.scrolled_window = Gtk.ScrolledWindow()
self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.adjustment = self.scrolled_window.get_vadjustment()
self.textview = Gtk.TextView()
self.textbuffer = self.textview.get_buffer()
self._italics = self.textbuffer.create_tag("italic", style="italic",
foreground="grey")
self.textview.set_editable(False)
self.textview.set_cursor_visible(False)
self.textview.set_wrap_mode(Gtk.WrapMode.WORD)
self.textview.set_justification(Gtk.Justification.CENTER)
self.textview.connect('key-press-event', self.key_press_event_cb)
add_css(self.textview, "* { padding: 6px; }")
vbox = Gtk.VBox()
vbox.pack_start(self.textview, True, True, 0)
self._edit_button = Button("Edit Lyrics", Icons.EDIT)
hbox = Gtk.HBox()
hbox.pack_end(self._edit_button, False, False, 3)
vbox.pack_start(hbox, False, False, 3)
self.scrolled_window.add(vbox)
self.textview.show()
self.scrolled_window.show()
self._sig = None
cur = app.player.info
if cur is not None:
cur = SongWrapper(cur)
self.plugin_on_song_started(cur)
def create_sidebar(self):
vbox = Gtk.VBox(margin=0)
vbox.pack_start(self.scrolled_window, True, True, 0)
vbox.show_all()
return vbox
def disabled(self):
self.textview.destroy()
self.scrolled_window.destroy()
def plugin_on_song_started(self, song):
"""Called when a song is started. Loads the lyrics.
If there are lyrics associated with `song`, load them into the
lyrics viewer. Otherwise, hides the lyrics viewer.
"""
lyrics = None
if song is not None:
print_d("Looking for lyrics for %s" % song("~filename"))
lyrics = song("~lyrics")
if lyrics:
self.textbuffer.set_text(lyrics)
self.adjustment.set_value(0) # Scroll to the top.
self.textview.show()
else:
title = _("No lyrics found for\n %s") % song("~basename")
self._set_italicised(title)
def edit(widget):
print_d("Launching lyrics editor for %s" % song("~filename"))
assert isinstance(song, SongWrapper)
information = Information(app.librarian, [song._song])
information.get_child()._switch_to_lyrics()
information.show()
if self._sig:
self._edit_button.disconnect(self._sig)
self._sig = self._edit_button.connect('clicked', edit)
def _set_italicised(self, title):
self.textbuffer.set_text(title)
start = self.textbuffer.get_start_iter()
end = self.textbuffer.get_end_iter()
self.textbuffer.remove_all_tags(start, end)
self.textbuffer.apply_tag(self._italics, start, end)
def plugin_on_changed(self, songs):
cur = app.player.info
if cur:
fn = cur("~filename")
for s in songs:
if s("~filename") == fn:
print_d("Active song changed, reloading lyrics")
self.plugin_on_song_started(SongWrapper(cur))
else:
self._set_italicised(_("No active song"))
def key_press_event_cb(self, widget, event):
"""Handles up/down "key-press-event" in the lyrics view."""
#.........這裏部分代碼省略.........
示例12: __init__
def __init__(self, model):
songs_text = numeric_phrase("%d duplicate group",
"%d duplicate groups",
len(model))
super(DuplicateDialog, self).__init__()
self.set_destroy_with_parent(True)
self.set_title("Quod Libet - %s (%s)" % (Duplicates.PLUGIN_NAME,
songs_text))
self.finished = False
self.set_default_size(960, 480)
self.set_border_width(6)
swin = Gtk.ScrolledWindow()
swin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
swin.set_shadow_type(Gtk.ShadowType.IN)
# Set up the browser view
view = DuplicateSongsView(model)
def cell_text(column, cell, model, iter_, index):
text = model[iter_][index]
cell.markup = text
cell.set_property("markup", text)
# Set up the columns
for i, (tag, f) in enumerate(DuplicatesTreeModel.TAG_MAP):
e = (Pango.EllipsizeMode.START if tag == '~filename'
else Pango.EllipsizeMode.END)
render = Gtk.CellRendererText()
render.set_property("ellipsize", e)
col = Gtk.TreeViewColumn(util.tag(tag), render)
# Numeric columns are better smaller here.
if tag.startswith("~#"):
col.set_fixed_width(80)
col.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
else:
col.set_expand(True)
col.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
col.set_resizable(True)
col.set_cell_data_func(render, cell_text, i + 1)
view.append_column(col)
view.connect('popup-menu', self.__songs_popup_menu)
swin.add(view)
# A basic information area
hbox = Gtk.HBox(spacing=6)
def expand_all(*args):
model = view.get_model()
for row in model:
if view.row_expanded(row.path):
view.collapse_row(row.path)
else:
for row in model:
view.expand_row(row.path, False)
expand = Gtk.Button(_("Collapse / Expand all"))
connect_obj(expand, "clicked", expand_all, view)
hbox.pack_start(expand, False, True, 0)
label = Gtk.Label(label=_("Duplicate key expression is '%s'") %
Duplicates.get_key_expression())
hbox.pack_start(label, True, True, 0)
close = Button(_("_Close"), Icons.WINDOW_CLOSE)
close.connect('clicked', self.__quit)
hbox.pack_start(close, False, True, 0)
vbox = Gtk.VBox(spacing=6)
vbox.pack_start(swin, True, True, 0)
vbox.pack_start(hbox, False, True, 0)
self.add(vbox)
self.show_all()
示例13: __init__
def __init__(self, browser):
if self.is_not_unique():
return
super(Preferences, self).__init__()
self.set_border_width(12)
self.set_title(_("Cover Grid Preferences"))
self.set_default_size(420, 380)
self.set_transient_for(qltk.get_top_parent(browser))
# Do this config-driven setup at instance-time
self._PREVIEW_ITEM["~rating"] = format_rating(0.75)
self.mag_lock = False
box = Gtk.VBox(spacing=6)
vbox = Gtk.VBox(spacing=6)
cb = ConfigCheckButton(
_("Show album _text"), "browsers", "album_text")
cb.set_active(config.getboolean("browsers", "album_text"))
cb.connect('toggled',
lambda s: browser.toggle_text())
vbox.pack_start(cb, False, True, 0)
cb2 = ConfigCheckButton(
_("Show \"All Albums\" Item"), "browsers", "covergrid_all")
cb2.set_active(config.getboolean("browsers", "covergrid_all", False))
cb2.connect('toggled',
lambda s: browser.view.get_model().refilter())
vbox.pack_start(cb2, False, True, 0)
cb3 = ConfigCheckButton(
_("Wide Mode"), "browsers", "covergrid_wide")
cb3.set_active(config.getboolean("browsers",
"covergrid_wide", False))
cb3.connect('toggled',
lambda s: browser.toggle_wide())
vbox.pack_start(cb3, False, True, 0)
# Redraws the covers only when the user releases the slider
def mag_button_press(*_):
self.mag_lock = True
def mag_button_release(mag, _):
self.mag_lock = False
mag_changed(mag)
def mag_changed(mag):
if self.mag_lock:
return
newmag = mag.get_value()
oldmag = config.getfloat("browsers", "covergrid_magnification", 3.)
if newmag == oldmag:
print_d("Covergrid magnification haven't changed: {0}"
.format(newmag))
return
print_d('Covergrid magnification update from {0} to {1}'
.format(oldmag, newmag))
config.set("browsers", "covergrid_magnification", mag.get_value())
browser.update_mag()
mag_scale = Gtk.HScale(
adjustment=Gtk.Adjustment.new(config.getfloat("browsers",
"covergrid_magnification", 3), 0., 10., .5, .5, 0))
mag_scale.set_tooltip_text(_("Cover Magnification"))
l = Gtk.Label(label=_("Cover Magnification"))
mag_scale.set_value_pos(Gtk.PositionType.RIGHT)
mag_scale.connect('button-press-event', mag_button_press)
mag_scale.connect('button-release-event', mag_button_release)
mag_scale.connect('value-changed', mag_changed)
vbox.pack_start(l, False, True, 0)
vbox.pack_start(mag_scale, False, True, 0)
f = qltk.Frame(_("Options"), child=vbox)
box.pack_start(f, False, True, 12)
display_frame = self.edit_display_pane(browser, _("Album Display"))
box.pack_start(display_frame, True, True, 0)
main_box = Gtk.VBox(spacing=12)
close = Button(_("_Close"), Icons.WINDOW_CLOSE)
close.connect('clicked', lambda *x: self.destroy())
b = Gtk.HButtonBox()
b.set_layout(Gtk.ButtonBoxStyle.END)
b.pack_start(close, True, True, 0)
main_box.pack_start(box, True, True, 0)
self.use_header_bar()
if not self.has_close_button():
main_box.pack_start(b, False, True, 0)
self.add(main_box)
close.grab_focus()
self.show_all()
示例14: RenameFiles
class RenameFiles(Gtk.VBox):
title = _("Rename Files")
FILTERS = [SpacesToUnderscores, StripWindowsIncompat, StripDiacriticals,
StripNonASCII, Lowercase]
handler = RenameFilesPluginHandler()
@classmethod
def init_plugins(cls):
PluginManager.instance.register_handler(cls.handler)
def __init__(self, parent, library):
super(RenameFiles, self).__init__(spacing=6)
self.set_border_width(12)
hbox = Gtk.HBox(spacing=6)
cbes_defaults = NBP_EXAMPLES.split("\n")
self.combo = ComboBoxEntrySave(NBP, cbes_defaults,
title=_("Path Patterns"),
edit_title=_(u"Edit saved patterns…"))
self.combo.show_all()
hbox.pack_start(self.combo, True, True, 0)
self.preview = qltk.Button(_("_Preview"), Icons.VIEW_REFRESH)
self.preview.show()
hbox.pack_start(self.preview, False, True, 0)
self.pack_start(hbox, False, True, 0)
self.combo.get_child().connect('changed', self._changed)
model = ObjectStore()
self.view = Gtk.TreeView(model=model)
self.view.show()
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(self.view)
self.pack_start(sw, True, True, 0)
self.pack_start(Gtk.VBox(), False, True, 0)
filter_box = FilterPluginBox(self.handler, self.FILTERS)
filter_box.connect("preview", self.__filter_preview)
filter_box.connect("changed", self.__filter_changed)
self.filter_box = filter_box
self.pack_start(filter_box, False, True, 0)
# Save button
self.save = Button(_("_Save"), Icons.DOCUMENT_SAVE)
self.save.show()
bbox = Gtk.HButtonBox()
bbox.set_layout(Gtk.ButtonBoxStyle.END)
bbox.pack_start(self.save, True, True, 0)
self.pack_start(bbox, False, True, 0)
render = Gtk.CellRendererText()
column = TreeViewColumn(_('File'), render)
def cell_data_file(column, cell, model, iter_, data):
entry = model.get_value(iter_)
cell.set_property("text", entry.name)
column.set_cell_data_func(render, cell_data_file)
column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.view.append_column(column)
render = Gtk.CellRendererText()
render.set_property('editable', True)
column = TreeViewColumn(_('New Name'), render)
def cell_data_new_name(column, cell, model, iter_, data):
entry = model.get_value(iter_)
cell.set_property("text", entry.new_name or u"")
column.set_cell_data_func(render, cell_data_new_name)
column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.view.append_column(column)
connect_obj(self.preview, 'clicked', self.__preview, None)
connect_obj(parent, 'changed', self.__class__.__preview, self)
connect_obj(self.save, 'clicked', self.__rename, library)
render.connect('edited', self.__row_edited)
for child in self.get_children():
child.show()
def __filter_preview(self, *args):
Gtk.Button.clicked(self.preview)
def __filter_changed(self, *args):
self._changed(self.combo.get_child())
def _changed(self, entry):
self.save.set_sensitive(False)
self.preview.set_sensitive(bool(entry.get_text()))
def __row_edited(self, renderer, path, new):
path = Gtk.TreePath.new_from_string(path)
model = self.view.get_model()
#.........這裏部分代碼省略.........
示例15: __init__
def __init__(self, parent, library):
super(RenameFiles, self).__init__(spacing=6)
self.set_border_width(12)
hbox = Gtk.HBox(spacing=6)
cbes_defaults = NBP_EXAMPLES.split("\n")
self.combo = ComboBoxEntrySave(NBP, cbes_defaults,
title=_("Path Patterns"),
edit_title=_(u"Edit saved patterns…"))
self.combo.show_all()
hbox.pack_start(self.combo, True, True, 0)
self.preview = qltk.Button(_("_Preview"), Icons.VIEW_REFRESH)
self.preview.show()
hbox.pack_start(self.preview, False, True, 0)
self.pack_start(hbox, False, True, 0)
self.combo.get_child().connect('changed', self._changed)
model = ObjectStore()
self.view = Gtk.TreeView(model=model)
self.view.show()
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(self.view)
self.pack_start(sw, True, True, 0)
self.pack_start(Gtk.VBox(), False, True, 0)
filter_box = FilterPluginBox(self.handler, self.FILTERS)
filter_box.connect("preview", self.__filter_preview)
filter_box.connect("changed", self.__filter_changed)
self.filter_box = filter_box
self.pack_start(filter_box, False, True, 0)
# Save button
self.save = Button(_("_Save"), Icons.DOCUMENT_SAVE)
self.save.show()
bbox = Gtk.HButtonBox()
bbox.set_layout(Gtk.ButtonBoxStyle.END)
bbox.pack_start(self.save, True, True, 0)
self.pack_start(bbox, False, True, 0)
render = Gtk.CellRendererText()
column = TreeViewColumn(_('File'), render)
def cell_data_file(column, cell, model, iter_, data):
entry = model.get_value(iter_)
cell.set_property("text", entry.name)
column.set_cell_data_func(render, cell_data_file)
column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.view.append_column(column)
render = Gtk.CellRendererText()
render.set_property('editable', True)
column = TreeViewColumn(_('New Name'), render)
def cell_data_new_name(column, cell, model, iter_, data):
entry = model.get_value(iter_)
cell.set_property("text", entry.new_name or u"")
column.set_cell_data_func(render, cell_data_new_name)
column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.view.append_column(column)
connect_obj(self.preview, 'clicked', self.__preview, None)
connect_obj(parent, 'changed', self.__class__.__preview, self)
connect_obj(self.save, 'clicked', self.__rename, library)
render.connect('edited', self.__row_edited)
for child in self.get_children():
child.show()