本文整理汇总了Python中dtk.ui.button.Button类的典型用法代码示例。如果您正苦于以下问题:Python Button类的具体用法?Python Button怎么用?Python Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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)
示例2: __init__
def __init__(self):
'''
init docs
'''
gtk.VBox.__init__(self)
self.draw_title_background = self.draw_tab_title_background
self.theme = None
self.delete_view = DeleteView(padding_x=30, padding_y=ITEM_PADDING_Y)
self.delete_view_sw = self.delete_view.get_scrolled_window()
self.action_align = gtk.Alignment()
self.action_align.set_padding(5, 5, 510, 5)
self.action_box = gtk.HBox(spacing = 10)
self.back_button = Button(_("Back"))
self.back_button.set_size_request(80, WIDGET_HEIGHT)
self.back_button.connect("clicked", self.__on_back)
self.select_all_button = Button(_("Select all"))
self.select_all_button.set_size_request(80, WIDGET_HEIGHT)
self.select_all_button.connect("clicked", self.__on_select_all)
self.delete_button = Button(_("Delete"))
self.delete_button.set_size_request(80, WIDGET_HEIGHT)
self.delete_button.connect("clicked", self.__on_delete)
self.action_box.pack_start(self.select_all_button, False, False)
self.action_box.pack_start(self.delete_button, False, False)
self.action_box.pack_start(self.back_button, False, False)
self.action_align.add(self.action_box)
self.pack_start(self.delete_view_sw, True, True)
self.pack_start(self.action_align, False, False)
event_manager.add_callback("select-delete-wallpaper", self.__on_select_delete_wallpaper)
示例3: BluetoothInputDialog
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()
示例4: __init__
def __init__(self,
title,
message,
default_width=400,
default_height=220,
confirm_callback=None,
cancel_callback=None,
confirm_button_text="Yes",
cancel_button_text="No"):
DialogBox.__init__(self, "", default_width, default_height, DIALOG_MASK_SINGLE_PAGE)
self.confirm_callback = confirm_callback
self.cancel_callback = cancel_callback
self.title_align = gtk.Alignment()
self.title_align.set(0, 0, 0, 0)
self.title_align.set_padding(0, 0, FRAME_LEFT_PADDING, 8)
self.title_label = Label(title, wrap_width=300)
self.label_align = gtk.Alignment()
self.label_align.set(0.5, 0.5, 0, 0)
self.label_align.set_padding(0, 0, 8, 8)
self.label = Label(message, text_x_align=ALIGN_MIDDLE, text_size=55)
self.confirm_button = Button(confirm_button_text)
self.cancel_button = Button(cancel_button_text)
self.confirm_button.connect("clicked", lambda w: self.click_confirm_button())
self.cancel_button.connect("clicked", lambda w: self.click_cancel_button())
self.body_box.pack_start(self.title_align, False, False)
self.title_align.add(self.title_label)
self.body_box.pack_start(self.label_align, True, True)
self.label_align.add(self.label)
self.right_button_box.set_buttons([self.cancel_button, self.confirm_button])
示例5: create_lyrics_dir_table
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
示例6: __init__
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: BluetoothReplyDialog
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)
示例8: __init__
def __init__(self, title="(无文件)"):
Button.__init__(self, title)
self.filename = None # conv file name.
self.uri = None # uri file name.
self.folder_path = None # dir path.
# button connect signal (clicked).
self.connect("clicked", self.fil_choose_button_clicked)
示例9: __init__
def __init__(self):
"""
init docs
"""
gtk.VBox.__init__(self)
self.__background_settings = deepin_gsettings.new("com.deepin.dde.background")
self.draw_title_background = self.draw_tab_title_background
self.theme = None
self.wallpaper_box = gtk.VBox()
self.window_theme_box = gtk.VBox()
self.wallpaper_view = WallpaperView(padding_x=30, padding_y=ITEM_PADDING_Y)
self.wallpaper_view_sw = self.wallpaper_view.get_scrolled_window()
self.wallpaper_view_sw.set_size_request(-1, 426)
position_group, self.position_combobox = get_combo_group(
_("Position"), DRAW_COMBO_ITEM, self.on_position_combox_selected
)
time_group, self.time_combobox = get_combo_group(_("Duration"), TIME_COMBO_ITEM, self.on_time_combox_selected)
self.__is_random = True
if self.__background_settings.get_int("background-duration") == 0:
self.__is_random = False
self.unorder_play, self.random_toggle = get_toggle_group(
_("Random"), self.__on_random_toggled, self.__is_random
)
self.button_align = gtk.Alignment()
self.button_box = gtk.HBox(spacing=5)
self.select_all_button = Button(_("Select all"))
self.select_all_button.set_size_request(80, WIDGET_HEIGHT)
self.select_all_button.connect("clicked", self.__on_select_all)
self.delete_button = Button(_("Delete"))
self.delete_button.set_size_request(80, WIDGET_HEIGHT)
self.delete_button.connect("clicked", self.__on_delete)
self.button_box.pack_start(self.select_all_button, False, False)
self.button_box.pack_start(self.delete_button, False, False)
self.button_align.add(self.button_box)
self.action_bar = gtk.HBox(spacing=26)
self.action_bar.pack_start(position_group, False, False)
self.action_bar.pack_start(time_group, False, False)
self.action_bar.pack_start(self.unorder_play, False, False)
self.action_bar.pack_end(self.button_align, False, False)
action_bar_align = gtk.Alignment()
action_bar_align.set_size_request(-1, STATUS_HEIGHT)
action_bar_align.set_padding(5, 5, 50, 20)
action_bar_align.add(self.action_bar)
self.wallpaper_box.pack_start(self.wallpaper_view_sw, True, True)
self.wallpaper_box.pack_start(action_bar_align, False, False)
self.pack_start(self.wallpaper_box, False, False)
event_manager.add_callback("select-wallpaper", self.on_wallpaper_select)
event_manager.add_callback("apply-wallpaper", self.__on_wallpaper_apply)
event_manager.add_callback("add-wallpapers", self.__on_add_wallpapers)
示例10: __init__
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
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
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
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__
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)
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)
search_button = Button(_("Search"))
search_button.connect("clicked", self.search_lyric_cb)
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(search_button, False, False)
scrolled_window = ScrolledWindow(0, 0)
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
sort_items = [(lambda item: item.title, cmp), (lambda item: item.artist, cmp)]
self.result_view = ListView(sort_items)
self.result_view.connect("double-click-item", self.double_click_cb)
self.result_view.add_titles([_("Title"), _("Artist")])
self.result_view.draw_mask = self.get_mask_func(self.result_view)
scrolled_window.add_child(self.result_view)
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(scrolled_window, 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()
示例15: create_location_box
def create_location_box(self):
location_align = gtk.Alignment()
location_align.set(1.0, 1.0, 0.5, 0.5)
location_box = gtk.HBox(spacing=5)
location_label = Label(_("Location:"))
self.location_entry = InputEntry("")
self.location_entry.set_size(250, 25)
open_button = Button(_("Open directory"))
open_button.connect("clicked", self.open_song_location)
location_box.pack_start(location_label, False, True)
location_box.pack_start(self.location_entry, False, True)
location_box.pack_start(open_button, False, True)
location_align.add(location_box)
return location_align