本文整理汇总了Python中dtk.ui.button.Button.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Button.connect方法的具体用法?Python Button.connect怎么用?Python Button.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.button.Button
的用法示例。
在下文中一共展示了Button.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BluetoothReplyDialog
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
class BluetoothReplyDialog(DialogBox):
DIALOG_MASK_SINGLE_PAGE = 0
def __init__(self, message, default_width=300, default_height=140, is_succeed=True):
DialogBox.__init__(self, "", default_width, default_height, self.DIALOG_MASK_SINGLE_PAGE)
self.hbox = gtk.HBox()
self.image_align = gtk.Alignment()
self.image_align.set(0, 0, 0, 0)
self.image_align.set_padding(0, 0, 20, 0)
self.image_box = ImageBox(app_theme.get_pixbuf("bluetooth/succeed.png"))
if not is_succeed:
self.image_box = ImageBox(app_theme.get_pixbuf("bluetooth/failed.png"))
self.image_align.add(self.image_box)
self.message_align = gtk.Alignment()
self.message_align.set(0, 0, 0, 0)
self.message_align.set_padding(20, 0, 10, 0)
if not is_succeed:
self.message_align.set_padding(0, 0, 10, 0)
self.message_label = Label(message, wrap_width = 200)
self.message_align.add(self.message_label)
self.hbox.pack_start(self.image_align)
self.hbox.pack_start(self.message_align)
self.confirm_align = gtk.Alignment()
self.confirm_align.set(0, 0, 0, 0)
self.confirm_align.set_padding(20, 0, 200, 0)
self.confirm_button = Button(_("Ok"))
self.confirm_button.set_size_request(70, WIDGET_HEIGHT)
self.confirm_button.connect("clicked", lambda widget : self.destroy())
self.confirm_align.add(self.confirm_button)
self.body_box.pack_start(self.hbox, False, False)
self.body_box.pack_start(self.confirm_align, False, False)
示例2: __init__
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def __init__(self):
DialogBox.__init__(self, _("Search"), 460, 300, DIALOG_MASK_SINGLE_PAGE,
modal=False, window_hint=None, close_callback=self.hide_all)
title_label = Label(_("Title:"))
self.title_entry = TextEntry("")
self.title_entry.set_size(300, 25)
self.search_button = Button(_("Search"))
self.search_button.connect("clicked", self.search_song)
control_box = gtk.HBox(spacing=5)
control_box.pack_start(title_label, False, False)
control_box.pack_start(self.title_entry, False, False)
control_box.pack_start(self.search_button, False, False)
scrolled_window = ScrolledWindow(0, 0)
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.result_view = ListView()
self.result_view.connect("double-click-item", self.double_click_cb)
self.result_view.draw_mask = self.get_mask_func(self.result_view)
self.result_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Type"), _("Size")])
scrolled_window.add_child(self.result_view)
self.prompt_label = Label("")
download_button = Button(_("Download"))
download_button.connect("clicked", self.download_song)
cancel_button = Button(_("Close"))
cancel_button.connect("clicked", lambda w: self.hide_all())
self.body_box.set_spacing(5)
self.body_box.pack_start(control_box, False, False)
self.body_box.pack_start(scrolled_window, True, True)
self.left_button_box.set_buttons([self.prompt_label])
self.right_button_box.set_buttons([download_button, cancel_button])
示例3: __init__
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def __init__(self):
DialogBox.__init__(self, _("Task Manager"), 350, 450, DIALOG_MASK_SINGLE_PAGE,
modal=False, close_callback=self.hide_all)
self.is_changed = False
scrolled_window = ScrolledWindow(0, 0)
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scrolled_align = gtk.Alignment()
scrolled_align.set(1, 1, 1, 1)
scrolled_align.set_padding(10, 0, 0, 0)
scrolled_align.add(scrolled_window)
self.jobs_view = JobsView()
self.jobs_view.draw_mask = self.get_mask_func(self.jobs_view)
scrolled_window.add_child(self.jobs_view)
pause_button = Button(_("Pause"))
pause_button.connect("clicked", self.pause_job)
stop_button = Button(_("Close"))
stop_button.connect("clicked", lambda w: self.hide_all())
self.body_box.add(scrolled_align)
self.right_button_box.set_buttons([pause_button, stop_button])
Dispatcher.connect("transfor-job", self.add_new_job)
示例4: __init__
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def __init__(self, network_interface):
gtk.VBox.__init__(self)
self.theme = None
self.set_spacing(10)
self.cache_view = CacheView(network_interface, download_dir=get_download_wallpaper_dir())
self.cache_view_sw = self.cache_view.get_scrolled_window()
self.nolink_image = ImageBox(app_theme.get_pixbuf("individuation/notlink.png"))
self.back_button = Button(_("Back"))
self.back_button.connect("clicked", self.__on_back)
download_button = Button(_("Download All"))
download_button.connect("clicked", self.on_download_button_clicked)
control_box = gtk.HBox(spacing=10)
control_box.pack_start(self.back_button, False, False)
self.control_align = gtk.Alignment()
self.control_align.set(1.0, 0.5, 0, 0)
self.control_align.set_padding(0, 5, 0, 10)
self.control_align.add(control_box)
self.pack_start(self.cache_view_sw, True, True)
self.pack_start(self.control_align, False, True)
event_manager.add_callback("fetch-failed", self.__fetch_failed)
示例5: BluetoothInputDialog
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
class BluetoothInputDialog(BluetoothDialog):
def __init__(self, title, ok_cb=None, cancel_cb=None):
BluetoothDialog.__init__(self, title)
self.ok_cb = ok_cb
self.cancel_cb = cancel_cb
self.input_entry_align = gtk.Alignment()
self.input_entry_align.set_padding(20, 20, 5, 5)
self.input_entry = InputEntry("")
self.input_entry.set_size(500, 25)
self.ok_button = Button(_("OK"))
self.ok_button.connect("clicked", self.__ok_callback)
self.cancel_button = Button(_("Cancel"))
self.cancel_button.connect("clicked", self.__cancel_callback)
self.input_entry_align.add(self.input_entry)
self.vbox.pack_end(self.input_entry_align)
self.add_dtk_button(self.ok_button, gtk.RESPONSE_OK)
self.add_dtk_button(self.cancel_button, gtk.RESPONSE_CANCEL)
self.input_entry.entry.connect("press-return", ok_cb, self.input_entry.get_text())
def __ok_callback(self, widget):
if self.ok_cb:
apply(self.ok_cb, [self.input_entry.get_text()])
def __cancel_callback(self, widget):
if self.cancel_cb:
self.cancel_cb()
示例6: __init__
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def __init__(self, song=None):
super(InfoSetting, self).__init__()
self.song = song
main_align = gtk.Alignment()
main_align.set_padding(40, 0, 100, 0)
main_align.set(0, 0, 0.5, 0.5)
self.main_table = gtk.Table(6, 3)
self.main_table.set_col_spacings(10)
self.main_table.set_row_spacings(10)
self.title_entry = self.create_combo_entry(0, 1, _("Title:"))
self.artist_entry = self.create_combo_entry(1, 2, _("Artist:"))
self.album_entry = self.create_combo_entry(2, 3, _("Album:"))
self.genre_entry = self.create_combo_entry(3, 4, _("Genre:"))
self.date_entry = self.create_combo_entry(4, 5, _("Date:"))
main_align.add(self.main_table)
# Update song
if song:
self.update_song(song)
save_button = Button(_("Save"))
save_button.connect("clicked", self.save_taginfo)
block_box = gtk.EventBox()
block_box.set_visible_window(False)
block_box.set_size_request(90, -1)
button_box = gtk.HBox()
button_box.pack_start(create_right_align(), True, True)
button_box.pack_start(save_button, False, False)
button_box.pack_start(block_box, False, False)
self.pack_start(main_align, False, True)
self.pack_start(button_box, False, False)
示例7: create_lyrics_dir_table
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def create_lyrics_dir_table(self):
main_table = gtk.Table(3, 2)
main_table.set_row_spacings(CONTENT_ROW_SPACING)
dir_title_label = Label(_("Lyrics directory"))
dir_title_label.set_size_request(200, 12)
label_align = gtk.Alignment()
label_align.set_padding(0, 0, 0, 0)
label_align.add(dir_title_label)
self.dir_entry = InputEntry()
self.dir_entry.set_text(os.path.expanduser(config.get("lyrics", "save_lrc_path", "~/.lyrics")))
self.dir_entry.set_editable(False)
self.dir_entry.set_size(250, 25)
modify_button = Button(_("Change"))
modify_button.connect("clicked", self.change_lyrics_save_dir)
hbox = gtk.HBox(spacing=5)
hbox.pack_start(self.dir_entry, False, False)
hbox.pack_start(modify_button, False, False)
main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
main_table.attach(hbox, 0, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
return main_table
示例8: __init__
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def __init__(self, confirm_callback=None):
DialogBox.__init__(self,
title=_("Close"),
default_width=360,
default_height=145,
mask_type=DIALOG_MASK_SINGLE_PAGE,
)
self.confirm_callback = confirm_callback
radio_group = gtk.HBox(spacing=50)
self.minimize_radio = RadioButton(_("Minimize to tray"))
self.minimize_radio.set_active(True)
self.quit_radio = RadioButton(_("Quit"))
radio_group.pack_start(self.minimize_radio, False, True)
radio_group.pack_start(self.quit_radio, False, True)
self.remembar_button = CheckButton(_("Don't prompt again"))
self.remembar_button.set_active(True)
radio_group_align = gtk.Alignment()
radio_group_align.set_padding(30, 0, 10, 0)
radio_group_align.add(radio_group)
confirm_button = Button(_("OK"))
confirm_button.connect("clicked", self.on_confirm_button_clicked)
cancel_button = Button(_("Cancel"))
cancel_button.connect("clicked", self.on_cancel_button_clicked)
# Connect widgets.
self.body_box.pack_start(radio_group_align, False, True)
self.left_button_box.set_buttons([self.remembar_button,])
self.right_button_box.set_buttons([confirm_button, cancel_button])
示例9: __init__
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def __init__(self):
DialogBox.__init__(
self, _("Lyrics search"), 460, 300, DIALOG_MASK_MULTIPLE_PAGE, close_callback=self.hide_all,
modal=False, window_hint=None, skip_taskbar_hint=False, window_pos=gtk.WIN_POS_CENTER)
self.artist_entry = InputEntry()
self.artist_entry.set_size(130, 23)
self.title_entry = InputEntry()
self.title_entry.set_size(130, 23)
artist_label = Label(_("Artist:"))
title_label = Label(_("Title:"))
right_align = gtk.Alignment()
right_align.set(0, 0, 0, 1)
self.search_button = Button(_("Search"))
self.search_button.connect("clicked", self.search_lyric_cb)
self.process_id = 0
info_box = gtk.HBox(spacing=25)
control_box = gtk.HBox(spacing=5)
title_box = gtk.HBox(spacing=5)
title_box.pack_start(title_label, False, False)
title_box.pack_start(self.title_entry)
artist_box = gtk.HBox(spacing=5)
artist_box.pack_start(artist_label, False, False)
artist_box.pack_start(self.artist_entry)
control_box.pack_start(title_box, False, False)
control_box.pack_start(artist_box, False, False)
info_box.pack_start(control_box, False, False)
info_box.pack_start(self.search_button, False, False)
sort_items = [ lambda items, reverse : self.sort_by_key(items, reverse, "title"),
lambda items, reverse : self.sort_by_key(items, reverse, "artist")]
self.result_view = TreeView()
self.result_view.set_expand_column(0)
self.result_view.connect("double-click-item", self.double_click_cb)
self.result_view.set_column_titles([_("Title"), _("Artist")], sort_items)
self.result_view.draw_mask = self.draw_view_mask
self.prompt_label = Label("")
download_button = Button(_("Download"))
download_button.connect("clicked", self.download_lyric_cb)
cancel_button = Button(_("Close"))
cancel_button.connect("clicked", lambda w: self.hide_all())
info_box_align = gtk.Alignment()
info_box_align.set_padding(5, 0, 5, 0)
info_box_align.add(info_box)
self.body_box.set_spacing(5)
self.body_box.pack_start(info_box_align, False, False)
self.body_box.pack_start(self.result_view, True, True)
self.left_button_box.set_buttons([self.prompt_label])
self.right_button_box.set_buttons([download_button, cancel_button])
self.lrc_manager = LrcManager()
示例10: __init__
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def __init__(self):
super(PreferenceDialog, self).__init__(_("Preferences"), 575, 495,
mask_type=DIALOG_MASK_MULTIPLE_PAGE,
close_callback=self.hide_all)
self.set_position(gtk.WIN_POS_CENTER)
self.main_box = gtk.VBox()
close_button = Button(_("Close"))
close_button.connect("clicked", lambda w: self.hide_all())
# Init widget.
self.general_setting = GeneralSetting()
self.hotkey_setting = HotKeySetting()
self.desktop_lyrics_setting = DesktopLyricsSetting()
self.scroll_lyrics_setting = ScrollLyricsSetting()
self.plugins_manager = PluginsManager()
# Category bar
self.category_bar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
self.category_bar.set_expand_column(0)
self.category_bar.draw_mask = self.draw_treeview_mask
self.category_bar.set_size_request(132, 516)
self.category_bar.connect("single-click-item", self.on_categorybar_single_click)
# Init catagory bar.
self.__init_category_bar()
category_box = gtk.VBox()
background_box = BackgroundBox()
background_box.set_size_request(132, 11)
background_box.draw_mask = self.draw_treeview_mask
category_box.pack_start(background_box, False, False)
category_bar_align = gtk.Alignment()
category_bar_align.set(0, 0, 1, 1,)
category_bar_align.set_padding(0, 1, 0, 0)
category_bar_align.add(self.category_bar)
category_box.pack_start(category_bar_align, True, True)
# Pack widget.
left_box = gtk.VBox()
self.right_box = gtk.VBox()
left_box.add(category_box)
self.right_box.add(self.general_setting)
right_align = gtk.Alignment()
right_align.set_padding(0, 0, 10, 0)
right_align.add(self.right_box)
body_box = gtk.HBox()
body_box.pack_start(left_box, False, False)
body_box.pack_start(right_align, False, False)
self.main_box.add(body_box)
# DialogBox code.
self.body_box.pack_start(self.main_box, True, True)
self.right_button_box.set_buttons([close_button])
示例11: SongSearchUI
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
class SongSearchUI(DialogBox):
def __init__(self):
DialogBox.__init__(self, _("Search"), 460, 300, DIALOG_MASK_SINGLE_PAGE,
modal=False, window_hint=None, close_callback=self.hide_all)
title_label = Label(_("Title:"))
self.title_entry = TextEntry("")
self.title_entry.set_size(300, 25)
self.search_button = Button(_("Search"))
self.search_button.connect("clicked", self.search_song)
control_box = gtk.HBox(spacing=5)
control_box.pack_start(title_label, False, False)
control_box.pack_start(self.title_entry, False, False)
control_box.pack_start(self.search_button, False, False)
scrolled_window = ScrolledWindow(0, 0)
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.result_view = ListView()
self.result_view.connect("double-click-item", self.double_click_cb)
self.result_view.draw_mask = self.get_mask_func(self.result_view)
self.result_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Type"), _("Size")])
scrolled_window.add_child(self.result_view)
self.prompt_label = Label("")
download_button = Button(_("Download"))
download_button.connect("clicked", self.download_song)
cancel_button = Button(_("Close"))
cancel_button.connect("clicked", lambda w: self.hide_all())
self.body_box.set_spacing(5)
self.body_box.pack_start(control_box, False, False)
self.body_box.pack_start(scrolled_window, True, True)
self.left_button_box.set_buttons([self.prompt_label])
self.right_button_box.set_buttons([download_button, cancel_button])
def search_song(self, widget):
self.result_view.clear()
title = self.title_entry.entry.get_text()
if not title.strip():
return
self.prompt_label.set_text(_("Now searching"))
# widget.set_sensitive(False)
utils.ThreadRun(multi_ways_query_song, self.render_song_infos, [title]).start()
@post_gui
def render_song_infos(self, song_infos):
if song_infos:
try:
items = [QueryInfoItem(song_info) for song_info in song_infos]
except Exception, e:
print e
else:
self.result_view.add_items(items)
self.prompt_label.set_text(_("Finish!"))
示例12: create_output_box
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def create_output_box(self):
output_label = Label("%s:" % _("Output"))
self.output_entry = InputEntry(os.path.expanduser("~/"))
self.output_entry.set_size(210, 24)
change_button = Button(_("Change"))
change_button.connect("clicked", self.set_output_directory)
output_box = gtk.HBox(spacing=5)
output_box.pack_start(output_label, False, False)
output_box.pack_start(self.output_entry, False, False)
output_box.pack_start(change_button, False, False)
return output_box
示例13: add_button
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def add_button(self, add_button):
container_remove_all(self.buttons_align.get_children()[0])
self.__setup_reset_button()
button = Button(add_button)
button.set_size_request(self.button_width, WIDGET_HEIGHT)
button.connect("clicked", self.__add_button_clicked, add_button)
self.buttons_list = []
self.buttons_list.append(button)
self.buttons_list.append(self.reset_button)
self.buttons_align = self.__setup_buttons_align(self.buttons_list)
self.right_box.pack_start(self.buttons_align)
示例14: __init__
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def __init__(self, monitor_dir):
gtk.VBox.__init__(self)
self.set_spacing(10)
self.select_view = SelectView(monitor_dir, filter_dir=["deepin-wallpapers"], add_system=False)
self.select_view.connect("items-change", self.select_view_item_changed)
self.select_view.connect("double-click-item", self.select_view_double_clicked)
self.select_view_sw = self.select_view.get_scrolled_window()
label_box = gtk.VBox()
no_favorites_label = Label(_("Your Favorites folder is empty."))
align_up = get_align(align=(0.5, 0.5, 0, 0))
align_up.add(no_favorites_label)
go_to_local_action = ActionButton(_("Add from Local Pictures"), lambda: event_manager.emit("switch-to-local-pictures", self))
align_down = get_align(align=(0.5, 0.5, 0, 0))
align_down.add(go_to_local_action)
label_box.pack_start(align_up, False, False)
label_box.pack_start(align_down, False, False)
self.no_favorites_align = gtk.Alignment(0.5, 0.5, 0, 0)
self.no_favorites_align.add(label_box)
self.notice_label = Label("")
set_wallpapper_button = Button(_("Set as wallpaper"))
set_wallpapper_button.connect("clicked", self.__on_set_as_wallpapper)
delete_button = Button(_("Delete"))
delete_button.connect("clicked", self.__on_delete)
self.button_box = gtk.HBox(spacing=10)
self.button_box.pack_start(set_wallpapper_button, False, False)
self.button_box.pack_start(delete_button, False, False)
self.control_box = gtk.HBox()
self.control_box.set_size_request(-1, 20)
self.control_box.pack_start(self.notice_label, False, False)
self.control_align = gtk.Alignment()
self.control_align.set(0.5, 0.5, 1, 1)
self.control_align.set_padding(0, 5, 20, 10)
self.control_align.add(self.control_box)
if len(self.select_view.items) == 0:
self.pack_start(self.no_favorites_align, True, True)
else:
self.pack_start(self.select_view_sw, True, True)
self.pack_end(self.control_align, False, True)
event_manager.add_callback("select-select-wallpaper", self.__on_select_select_wallpaper)
self.timeout_notice_hide_id = None
示例15: process_unmodifier_key
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import connect [as 别名]
def process_unmodifier_key(tmp_accel_buf):
dialog = DialogBox(" ", 550, 150)
dialog.window_frame.connect("expose-event", draw_widget_background)
dialog.set_keep_above(True)
dialog.set_modal(True)
dialog.body_align.set_padding(15, 10, 10, 10)
label1 = Label(_("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.")% tmp_accel_buf.get_accel_label(), enable_select=False, enable_double_click=False)
label2 = Label(_("Please try with a key such as Control, Alt or Shift at the same time."), enable_select=False, enable_double_click=False)
dialog.body_box.pack_start(label1)
dialog.body_box.pack_start(label2)
button = Button(_("Cancel"))
button.connect("clicked", lambda b: dialog.destroy())
dialog.right_button_box.set_buttons([button])
dialog.show_all()