本文整理汇总了Python中dtk.ui.label.Label.set_text方法的典型用法代码示例。如果您正苦于以下问题:Python Label.set_text方法的具体用法?Python Label.set_text怎么用?Python Label.set_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.label.Label
的用法示例。
在下文中一共展示了Label.set_text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MessageBar
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class MessageBar(CycleStrip):
'''
class docs
'''
def __init__(self, padding_left=0,):
'''
init docs
'''
# Init.
CycleStrip.__init__(self, app_theme.get_pixbuf("strip/background.png"))
self.label = Label()
self.label_align = gtk.Alignment()
self.label_align.set(0.0, 0.5, 0, 0)
self.label_align.set_padding(0, 0, padding_left, 0)
self.label_align.add(self.label)
self.search_button = ImageButton(
app_theme.get_pixbuf("entry/search_normal.png"),
app_theme.get_pixbuf("entry/search_hover.png"),
app_theme.get_pixbuf("entry/search_press.png"),
)
self.search_entry = InputEntry(action_button=self.search_button)
self.search_entry.set_size(220, 24)
entry_align = gtk.Alignment(0.5, 0.5, 0, 0)
entry_align.set_padding(0, 0, 5, 5)
entry_align.add(self.search_entry)
self.pack_start(self.label_align, True, True)
self.pack_start(entry_align, False, False)
def set_message(self, message):
self.label.set_text(message)
示例2: StatusBar
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class StatusBar(gtk.HBox):
'''docstring for StatusBar'''
def __init__(self):
super(StatusBar, self).__init__(False)
self.__count = 0
self.__timeout_id = None
self.text_label = Label("", text_x_align=ALIGN_MIDDLE,
label_width=500,
enable_select=False,
enable_double_click=False)
text_align = gtk.Alignment()
text_align.set(0.0, 0.5, 0.0, 0.0)
text_align.add(self.text_label)
self.button_hbox = gtk.HBox(False)
self.button_hbox.set_spacing(WIDGET_SPACING)
button_align = gtk.Alignment()
button_align.set(1.0, 0.5, 0.0, 0.0)
button_align.set_padding(0, 0, 0, 10)
button_align.add(self.button_hbox)
self.pack_start(text_align)
self.pack_start(button_align)
self.set_size_request(WINDOW_WIDTH, STATUS_HEIGHT)
self.connect("expose-event", self.draw_background)
def draw_background(self, widget, event):
cr = widget.window.cairo_create()
x, y, w, h = widget.allocation
cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))
cr.rectangle(x, y+1, w, h-1)
cr.fill()
cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
draw_line(cr, x, y + 1, x + w, y + 1)
def set_text(self, text):
self.__count += 1
if self.__timeout_id:
gtk.timeout_remove(self.__timeout_id)
self.text_label.set_text(text)
self.__timeout_id = gobject.timeout_add(3000, self.hide_text)
def hide_text(self):
self.__count -= 1
self.__timeout_id = None
self.text_label.set_text("")
def set_buttons(self, buttons):
self.clear_button()
for bt in buttons:
self.button_hbox.pack_start(bt, False, False)
self.show_all()
def get_buttons(self):
return self.button_hbox.get_children()
def clear_button(self):
self.button_hbox.foreach(self.button_hbox.remove)
示例3: StatusBox
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class StatusBox(gtk.HBox):
def __init__(self, width=800):
gtk.HBox.__init__(self)
self.width = width
self.status_label = Label(
text="", text_size=CONTENT_FONT_SIZE, text_x_align=ALIGN_MIDDLE, label_width=600, enable_select=False
)
self.set_size_request(self.width, -1)
self.pack_start(self.status_label, False, False)
self.connect("expose-event", self.__expose)
def hide_status(self):
self.status_label.set_text("")
def set_status(self, text):
self.status_label.set_text(text)
gobject.timeout_add(3000, self.hide_status)
def __expose(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
draw_line(cr, rect.x, rect.y + 1, rect.x + self.width, rect.y + 1)
示例4: BottomTipBar
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class BottomTipBar(gtk.HBox):
def __init__(self):
gtk.HBox.__init__(self)
self.info_image_box = gtk.VBox()
self.info_image_box.set_size_request(24, 24)
self.info_image_box.connect('expose-event', self.expose_info_image_box)
self.info_label = Label("")
self.end_info_label = Label("")
self.info_callback_button = ActionButton('')
self.close_button = CloseButton()
self.pack_start(self.info_image_box, False, False)
self.pack_start(self.info_label)
self.pack_end(self.close_button, False, False)
self.pack_end(self.info_callback_button, False, False)
self.pack_end(self.end_info_label, False, False)
self.connect('expose-event', self.expose)
def expose(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
cr.set_source_rgb(*color_hex_to_cairo('#cccccc'))
cr.rectangle(rect.x, rect.y, rect.width, 1)
cr.fill()
cr.set_source_rgb(*color_hex_to_cairo('#ffffff'))
cr.rectangle(rect.x, rect.y+1, rect.width, 1)
cr.fill()
cr.set_source_rgb(*color_hex_to_cairo('#fff9c9'))
cr.rectangle(rect.x, rect.y+2, rect.width, rect.height-2)
cr.fill()
def expose_info_image_box(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
msg_pixbuf = get_common_image_pixbuf("msg/msg1.png")
pix_width = msg_pixbuf.get_width()
pix_height = msg_pixbuf.get_height()
draw_pixbuf(cr,
msg_pixbuf,
rect.x + (rect.width-pix_width)/2,
rect.y + (rect.height-pix_height)/2,
)
def update_end_info(self, info):
self.end_info_label.set_text(info)
def update_info(self, info, callback_name='', callback_action=None):
self.info_label.set_text(info)
self.info_callback_button.set_text(callback_name)
self.info_callback_button.callback_action = callback_action
示例5: SongSearchUI
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [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!"))
示例6: ShowTime
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class ShowTime(object):
def __init__(self):
self.time_font1 = ""
self.time_font2 = ""
self.time_box = Label("", enable_gaussian=True)
def set_time_font(self, time_font2, time_font1):
self.time_font1 = str(time_font1) # 右边显示的时间.
self.time_font2 = str(time_font2) # 左边显示的时间.
self.time_box.set_text(self.time_font2 + self.time_font1)
示例7: BluetoothProgressDialog
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class BluetoothProgressDialog(DialogBox):
DIALOG_MASK_SINGLE_PAGE = 0
def __init__(self, default_width=300, default_height=160, cancel_cb=None):
DialogBox.__init__(self, "", default_width, default_height, self.DIALOG_MASK_SINGLE_PAGE)
self.cancel_cb = cancel_cb
self.message_align = gtk.Alignment()
self.message_align.set(0, 0, 0, 0)
self.message_align.set_padding(0, 0, 10, 0)
self.message_label = Label("", label_width=300)
self.message_align.add(self.message_label)
self.progress_align = gtk.Alignment()
self.progress_align.set(0, 0, 0, 0)
self.progress_align.set_padding(20, 0, 10, 10)
self.progress_bar = ProgressBar()
self.progress_bar.set_size_request(default_width, -1)
self.progress_align.add(self.progress_bar)
self.percentage_align = gtk.Alignment()
self.percentage_align.set(0, 0, 0, 0)
self.percentage_align.set_padding(10, 0, 140, 0)
self.percentage_label = Label("0%", label_width=300)
self.percentage_label.set_size_request(default_width, -1)
self.percentage_align.add(self.percentage_label)
self.cancel_align = gtk.Alignment()
self.cancel_align.set(0, 0, 0, 0)
self.cancel_align.set_padding(20, 0, 200, 0)
self.cancel_button = Button(_("Cancel"))
self.cancel_button.set_size_request(70, WIDGET_HEIGHT)
self.cancel_button.connect("clicked", self.__on_cancel_button_clicked)
self.cancel_align.add(self.cancel_button)
self.body_box.pack_start(self.message_align, False, False)
self.body_box.pack_start(self.progress_align, False, False)
self.body_box.pack_start(self.percentage_align, False, False)
self.body_box.pack_start(self.cancel_align)
def set_message(self, message):
self.message_label.set_text(message)
def set_progress(self, progress):
self.progress_bar.set_progress(progress)
self.percentage_label.set_text(_("Sent %d") % progress + "%")
def __on_cancel_button_clicked(self, widget):
if self.cancel_cb:
self.cancel_cb()
self.destroy()
示例8: FootBox
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class FootBox(gtk.HBox):
def __init__(self):
gtk.HBox.__init__(self)
self.set_size_request(-1, 35)
#self.connect("expose-event", self.expose_line)
self.init_ui()
def expose_line(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
style.draw_out_line(cr, rect)
def init_ui(self):
self.tip_align = gtk.Alignment(0, 0.5, 0, 1)
self.tip = Label("")
self.tip_align.set_padding(5, 5, 20, 0)
self.tip_align.add(self.tip)
self.button_box = gtk.HBox()
self.buttons_align = gtk.Alignment(1, 0.5, 0, 0)
self.buttons_align.set_padding(0, 0, 0, 10)
self.buttons_align.add(self.button_box)
self.pack(self, [self.tip_align], True, True)
self.pack_end(self.buttons_align, False, False)
def pack(self, parent, widgets, expand=False, fill=False):
for widget in widgets:
parent.pack_start(widget, expand, fill)
def set_buttons(self, buttons_list):
width = 0
for button in buttons_list:
width += button.get_size_request()[0]
self.button_box.set_size_request(width, -1)
self.pack(self.button_box, buttons_list)
self.queue_draw()
def set_tip(self, new_tip):
self.tip.set_text(new_tip)
示例9: MessageBar
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class MessageBar(CycleStrip):
'''
class docs
'''
def __init__(self, padding_left=0):
'''
init docs
'''
# Init.
CycleStrip.__init__(self, app_theme.get_pixbuf("strip/background.png"))
self.label = Label()
self.label_align = gtk.Alignment()
self.label_align.set(0.0, 0.5, 0, 0)
self.label_align.set_padding(0, 0, padding_left, 0)
self.label_align.add(self.label)
self.pack_start(self.label_align, True, True)
def set_message(self, message):
self.label.set_text(message)
示例10: HumanTimeTip
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class HumanTimeTip(gtk.VBox):
def __init__(self, timestamp):
gtk.VBox.__init__(self)
self.timestamp = timestamp
self.label = Label()
self.pack_start(self.label, False, False)
try:
timestamp = float(self.timestamp)
self.label.set_text(self.to_huamn_str(timestamp))
except:
self.label.set_text(self.timestamp)
gtk.timeout_add(1000, self.tick)
def to_huamn_str(self, timestamp):
now = time.time()
interval = int(now - timestamp)
if interval < 60:
return _("Just now")
else:
mins = interval / 60
if mins < 60:
if mins == 1:
return _("One minute ago")
else:
return _("%s minutes ago") % mins
else:
hours = mins / 60
if hours < 24:
if hours == 1:
return _("One hour ago")
else:
return _("%s hours ago") % hours
else:
days = hours / 24
if days == 1:
return _("Yesterday")
else:
datetime_obj = datetime.fromtimestamp(timestamp)
return datetime_obj.strftime("%Y-%m-%d")
def tick(self):
try:
timestamp = float(self.timestamp)
self.label.set_text(self.to_huamn_str(timestamp))
except:
pass
return True
示例11: IconSetPage
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class IconSetPage(gtk.VBox):
def __init__(self, account_setting):
super(IconSetPage, self).__init__(False)
#self.set_spacing(BETWEEN_SPACING)
self.account_setting = account_setting
self.choose_menu_without_camera = Menu(
[(None, _("Local picture"), self.choose_from_picture), (None, _("Take a screeshot"), self.choose_from_screenshot),], True)
self.choose_menu_with_camera = Menu(
[(None, _("Local picture"), self.choose_from_picture),
(None, _("Take a screeshot"), self.choose_from_screenshot),
(None, _("From camera"), self.choose_from_camera)], True)
self.tips_label = Label("Set icon", label_width=460, enable_select=False, enable_double_click=False)
self.error_label = Label("", wrap_width=560, enable_select=False, enable_double_click=False)
set_page_sw = ScrolledWindow()
self.pack_start(set_page_sw)
main_vbox = gtk.VBox(False)
set_page_sw.add_child(main_vbox)
self.icon_list_tabel = gtk.Table()
self.icon_list_tabel.set_row_spacings(4)
self.icon_list_tabel.set_col_spacings(4)
main_vbox.pack_start(tools.make_align(self.tips_label), False, False)
main_vbox.pack_start(tools.make_align(height=20), False, False)
self.history_list_hbox = gtk.HBox(False)
self.history_list_hbox.set_size_request(-1, 56)
self.history_list_hbox.set_spacing(4)
main_vbox.pack_start(tools.make_align(Label(_("Choose a new picture for your account"), label_width=460, enable_select=False, enable_double_click=False), height=CONTAINNER_HEIGHT), False, False)
main_vbox.pack_start(tools.make_align(self.icon_list_tabel), False, False)
main_vbox.pack_start(tools.make_align(height=20), False, False)
main_vbox.pack_start(tools.make_align(Label(_("Previously used pictures"), label_width=460, enable_select=False, enable_double_click=False), height=CONTAINNER_HEIGHT), False, False)
main_vbox.pack_start(tools.make_align(self.history_list_hbox), False, False)
main_vbox.pack_start(tools.make_align(height=20), False, False)
main_vbox.pack_start(tools.make_align(self.error_label), False, False)
# public picture list
#face_dir = '/usr/share/pixmaps/faces'
face_dir = '/var/lib/AccountsService/icons'
if os.path.exists(face_dir):
pic_list = os.listdir(face_dir)
else:
pic_list = []
pic_list.sort()
self.public_icon_list = []
inital_list = ['001.jpg', '002.jpg', '003.jpg', '004.jpg', '005.jpg',
'006.jpg', '007.jpg', '008.jpg', '009.jpg', '010.jpg',
'011.jpg', '012.jpg', '013.jpg', '014.jpg', '015.jpg',
'016.jpg', '017.jpg', '018.jpg', '019.jpg', '020.jpg']
for pic in pic_list:
if pic not in inital_list:
continue
try:
icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
"%s/%s" %(face_dir, pic)).scale_simple(48, 48, gtk.gdk.INTERP_TILES)
except:
continue
icon_bt = IconButton(icon_pixbuf, "%s/%s" %(face_dir, pic), has_frame=True)
icon_bt.connect("pressed", self.on_icon_bt_pressed_cb)
self.public_icon_list.append(icon_bt)
self.more_icon_button = IconButton(app_theme.get_pixbuf("%s/more.png" % MODULE_NAME).get_pixbuf(), has_frame=True)
self.more_icon_button.connect("button-press-event", self.choose_more_picture)
main_vbox.connect("expose-event", self.draw_white_background)
def refresh(self):
self.error_label.set_text("")
if not self.account_setting.current_set_user:
return
if self.account_setting.current_set_user.get_real_name():
show_name = self.account_setting.current_set_user.get_real_name()
else:
show_name = self.account_setting.current_set_user.get_user_name()
self.tips_label.set_text("<b>%s</b>" % _("Set <u>%s</u>'s picture") % tools.escape_markup_string(show_name))
self.history_icon = HistroyIcon(self.account_setting.current_set_user)
self.history_icon.get_history()
self.history_list_hbox.foreach(lambda w: w.destroy())
# the private history icon files
history_dir = os.path.join(self.account_setting.current_set_user.get_home_directory(), ".config/deepin-system-settings/account/icons")
if os.path.exists(history_dir):
pic_list = os.listdir(history_dir)
else:
pic_list = []
pic_list.sort()
private_icon_list = []
for pic in pic_list:
try:
icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
"%s/%s" %(history_dir, pic)).scale_simple(48, 48, gtk.gdk.INTERP_TILES)
except:
continue
pic_file_path = "%s/%s" %(history_dir, pic)
icon_bt = IconButton(icon_pixbuf, pic_file_path,
has_frame=True, can_del=check_file_writable(pic_file_path))
icon_bt.connect("pressed", self.on_icon_bt_pressed_cb)
#.........这里部分代码省略.........
示例12: SongEditor
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class SongEditor(DialogBox):
def __init__(self, songs, init_index=0):
super(SongEditor, self).__init__(_("Property"), 500, 400, mask_type=DIALOG_MASK_TAB_PAGE)
self.set_position(gtk.WIN_POS_CENTER)
close_button = Button(_("Close"))
close_button.connect("clicked", self.click_close_button)
previous_button = Button(_("Previous"))
previous_button.connect("clicked", lambda w : self.update_previous_song())
next_button = Button(_("Next"))
next_button.connect("clicked", lambda w : self.update_next_song())
self.record_label = Label("0/0")
action_box = gtk.HBox(spacing=5)
action_box.pack_start(previous_button, False, False)
action_box.pack_start(self.record_label, False, False)
action_box.pack_start(next_button, False, False)
MediaDB.connect("simple-changed", self.db_simple_changed)
# action_box.
if len(songs) <= 1:
action_box.set_no_show_all(True)
else:
self.record_label.set_text("%d/%d" % (init_index + 1, len(songs)))
# tabs
self.song_info = SongInfo(songs[init_index])
self.info_setting = InfoSetting(songs[init_index])
self.cover_setting = CoverSetting(songs[init_index])
self.tab_box = TabBox()
self.tab_box.add_items([(_("Track Infomation"), self.song_info),
(_("Edit tags"), self.info_setting),
(_("Edit cover"), self.cover_setting)])
# DialogBox code, simple, ah? :)
self.left_button_box.set_buttons([action_box])
self.right_button_box.set_buttons([close_button])
self.body_box.pack_start(self.tab_box, True, True)
# Constants.
self.current_index = init_index
self.songs = songs
def update_previous_song(self):
new_index = self.current_index - 1
if self.is_vaild_index(new_index):
self.current_index = new_index
self.update_song(self.songs[new_index])
self.update_record_label()
def update_next_song(self):
new_index = self.current_index + 1
if self.is_vaild_index(new_index):
self.current_index = new_index
self.update_song(self.songs[new_index])
self.update_record_label()
def is_vaild_index(self, index):
if 0 <= index < len(self.songs):
return True
return False
def update_record_label(self):
self.record_label.set_text("%d/%d" % (self.current_index + 1, len(self.songs)))
def update_song(self, song):
self.song_info.update_song(song)
self.info_setting.update_song(song)
self.cover_setting.update_song(song)
def db_simple_changed(self, widget, songs):
current_song = self.songs[self.current_index]
if isinstance(songs, list):
if self.songs[self.current_index] in songs:
self.song_info.update_song(songs[songs.index(current_song)])
self.cover_setting.update_song(songs[songs.index(current_song)])
def click_close_button(self, widget):
self.destroy()
示例13: UpdateManager
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class UpdateManager(dbus.service.Object):
def __init__(self, session_bus):
dbus.service.Object.__init__(self, session_bus, DSC_UPDATE_MANAGER_PATH)
self.in_update_list = False
self.in_upgrade_packages = False
self.upgrade_pkg_infos = []
self.application = Application()
self.application.set_default_size(400, 250)
self.application.add_titlebar(
button_mask=['min', 'close'],
app_name='Software Update Manager',
)
self.application.window.set_title("Software Update Manager")
self.application.set_icon(get_common_image('update.png'))
# Init page box.
self.page_box = gtk.VBox()
# Init page align.
self.page_align = gtk.Alignment()
self.page_align.set(0.5, 0.5, 1, 1)
self.page_align.set_padding(0, 0, 2, 2)
self.page_align.add(self.page_box)
self.application.main_box.pack_start(self.page_align, True, True)
# Init status bar.
self.statusbar = Statusbar(28)
status_box = gtk.HBox()
self.statusbar.status_box.pack_start(status_box, True, True)
self.application.main_box.pack_start(self.statusbar, False, False)
self.background = BackgroundBox()
self.background.draw_mask = self.draw_mask
self.page_box.pack_start(self.background)
self.upgrade_button = Button('更新软件')
self.upgrade_button.set_sensitive(False)
button_box = gtk.HBox()
button_box.pack_start(self.upgrade_button, False, False)
button_box_align = gtk.Alignment(0.5, 0.5, 0, 0)
button_box_align.set_padding(3, 8, 4, 4)
button_box_align.add(button_box)
self.statusbar.status_item_box.pack_start(button_box_align)
self.update_info_label = Label("初始化...")
self.update_info_label_align = create_align((0.5, 0.5, 0, 0))
self.update_info_label_align.add(self.update_info_label)
self.upgrade_button.connect('clicked', self.upgrade_packages)
def draw_mask(self, cr, x, y, w, h):
sidebar_color = ui_theme.get_color("menu_select_font").get_color()
draw_vlinear(cr, x, y, w, h,
[(0, (sidebar_color, 0.9)),
(1, (sidebar_color, 0.9)),]
)
def start_dsc_backend(self):
self.system_bus = dbus.SystemBus()
bus_object = self.system_bus.get_object(DSC_SERVICE_NAME, DSC_SERVICE_PATH)
self.bus_interface = dbus.Interface(bus_object, DSC_SERVICE_NAME)
self.system_bus.add_signal_receiver(
self.backend_signal_receiver,
signal_name="update_signal",
dbus_interface=DSC_SERVICE_NAME,
path=DSC_SERVICE_PATH)
def backend_signal_receiver(self, messages):
for message in messages:
(signal_type, action_content) = message
if signal_type == "update-list-update":
self.in_update_list = True
message_str = "正在检查更新,请稍等...(%s%%)" % int(float(action_content[0]))
self.update_info_label.set_text(message_str)
self.upgrade_button.set_sensitive(False)
elif signal_type == 'update-list-finish':
message_str = "正在检查更新,请稍等..."
self.update_info_label.set_text(message_str)
self.in_update_list = False
self.bus_interface.request_upgrade_pkgs(
reply_handler=self.render_upgrade_info,
error_handler=lambda e:handle_dbus_error("request_upgrade_pkgs", e))
elif signal_type == 'update-list-failed':
message_str = '检查更新失败!'
self.update_info_label.set_text(message_str)
elif signal_type == 'upgrade-commit-update':
pkg_names, action_type, percent, status = action_content
#.........这里部分代码省略.........
示例14: AccelEntry
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
class AccelEntry(ShortcutKeyEntry):
''' '''
TYPE_DP_GSETTINGS = 0
TYPE_CMP_GSETTINGS = 1
TYPE_GSETTINGS = 2
TYPE_GCONF = 3
TYPE_STRING = 4
TYPE_STRV = 5
__gsignals__ = {
"accel-key-change" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (str,)),
"accel-del" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
}
def __init__(self, content="",
check_conflict_func=None,
resolve_conflict_func=resolve_accel_entry_conflict,
process_unmodifier_func=process_unmodifier_key,
can_del=False):
'''
@param content: a string container accelerator
@param check_conflict_func: a function return a AccelEntry object, if their AccelBuffer is equal
@param resolve_conflict_func: a function to resolve conflict
@param process_unmodifier_func: a function to check the Accelerator is whether valid
'''
super(AccelEntry, self).__init__()
self.accel_buffer = AccelBuffer()
self.accel_buffer.set_from_accel(content)
self.accel_str = self.accel_buffer.get_accel_label()
if not self.accel_str:
self.accel_str = _('disable')
self.accel_label = Label(self.accel_str, enable_select=False, enable_double_click=False)
self.accel_align = gtk.Alignment()
self.accel_align.set(0.0, 0.5, 0.0, 0.0)
self.accel_align.set_padding(0, 0, 6, 0)
self.accel_align.add(self.accel_label)
self.grab_area = gtk.EventBox()
#self.grab_area.set_size_request(1, -1)
self.grab_area.set_can_focus(True)
self.grab_area.add_events(gtk.gdk.BUTTON_PRESS_MASK)
self.grab_area.add_events(gtk.gdk.KEY_PRESS_MASK)
self.del_button = ImageButton(app_theme.get_pixbuf("keyboard/delete-normal.png"),
app_theme.get_pixbuf("keyboard/delete-hover.png"),
app_theme.get_pixbuf("keyboard/delete-hover.png"))
#self.del_button.set_no_show_all(True)
self.h_box.remove(self.entry)
self.h_box.pack_start(self.accel_align)
self.h_box.pack_start(self.grab_area, False, False)
#self.h_box.pack_start(self.del_button, False, False)
self.grab_area.connect("button-press-event", self.__on_grab_area_button_press_cb)
self.grab_area.connect("key-press-event", self.__on_grab_area_key_press_cb)
self.grab_area.connect("key-release-event", self.__on_grab_area_key_release_cb)
self.accel_label.connect("button-press-event", self.__on_label_button_press_cb)
#self.accel_label.connect("enter-notify-event", self.__on_label_enter_cb)
#self.accel_label.connect("leave-notify-event", self.__on_label_leave_cb)
#self.del_button.connect("leave-notify-event", self.__on_del_button_leave_cb)
self.del_button.connect("clicked", lambda w:self.emit("accel-del"))
self.accel_label.keymap = {}
self.check_conflict_func = check_conflict_func
self.resolve_conflict_func = resolve_conflict_func
self.process_unmodifier_func = process_unmodifier_func
self.can_del = can_del
widget_width = 200
if self.can_del:
widget_width = 220
new_hbox = gtk.HBox()
new_align = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
new_align.add(self.del_button)
self.remove(self.align)
self.pack_start(new_hbox, False, False)
new_hbox.pack_start(self.align, False, False)
new_hbox.pack_start(new_align, False, False)
self.set_size(widget_width, 24)
self.settings_description = ""
self.settings_key = ""
self.settings_obj = None
self.settings_type = None
self.settings_value_type = None
self.connect("accel-key-change", self.__on_accel_key_change_cb)
def __on_label_button_press_cb(self, widget, event):
self.accel_label.set_text(_("Please input new shortcuts"))
if gtk.gdk.keyboard_grab(self.grab_area.window, False, 0) != gtk.gdk.GRAB_SUCCESS:
self.accel_label.set_text(self.accel_str)
return None
if gtk.gdk.pointer_grab(self.grab_area.window, False, gtk.gdk.BUTTON_PRESS_MASK, None, None, 0) != gtk.gdk.GRAB_SUCCESS:
gtk.gdk.keyboard_ungrab(0)
self.accel_label.set_text(self.accel_str)
return None
self.grab_area.grab_focus()
if self.can_del and self.del_button in self.h_box.get_children():
self.del_button.hide()
self.h_box.remove(self.del_button)
self.emit("wait-key-input", self.shortcut_key)
#.........这里部分代码省略.........
示例15: JobsManager
# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_text [as 别名]
#.........这里部分代码省略.........
self.pack_start(btn_pause_align,False,False)
self.pack_start(btn_cancel_align,False,False)
self.show_all()
self.set_no_show_all(True)
self.hide()
self.jobs_label.hide_all()
def draw_bg_mask(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
draw_alpha_mask(cr, rect.x, rect.y, rect.width, rect.height, "frameLight")
def __create_simple_button(self, name, callback):
button = ImageButton(
app_theme.get_pixbuf("jobs/%s_normal.png" % name),
app_theme.get_pixbuf("jobs/%s_hover.png" % name),
app_theme.get_pixbuf("jobs/%s_hover.png" % name),
)
if callback:
button.connect("clicked", callback)
return button
def __create_begin_button(self, callback):
toggle_button = ToggleButton(
app_theme.get_pixbuf("jobs/pause_normal.png"),
app_theme.get_pixbuf("jobs/begin_normal.png"),
app_theme.get_pixbuf("jobs/pause_hover.png"),
app_theme.get_pixbuf("jobs/begin_hover.png")
)
if callback:
toggle_button.connect("toggled", callback)
return toggle_button
def add(self, job):
job_id = job.connect("end",self.__job_end)
self.__jobs.append((job, job_id))
if len(self.__jobs) == 1:
try: gobject.source_remove(self.__id_updater)
except: pass
self.__id_updater = gobject.timeout_add(250,self.__update)
self.__jobs[0][0].start()
if self.__paused:
self.pause(self.__btn_pause)
self.__update()
def __job_end(self, ajob):
gobject.idle_add(self.__job_end_cb, ajob)
def __job_end_cb(self, ajob):
job, job_id = self.__jobs.pop(0)
job.disconnect(job_id)
if self.__paused:
self.pause(self.__btn_pause)
if self.__jobs:
jobs = [ (job[0].priority, job) for job in self.__jobs ]
jobs.sort()
self.__jobs = [ job[1] for job in jobs ]
self.__jobs[0][0].start()
self.__update()
else:
try: gobject.source_remove(self.__id_updater)
except:pass
self.__update()
del job
def pause(self, btn):
if self.__jobs:
if not self.__paused:
self.__jobs[0][0].pause()
self.__paused = True
else:
self.__jobs[0][0].unpause()
self.__paused = False
def stop(self,*args):
if self.__jobs:
if self.__paused:
self.pause(self.__btn_pause)
self.__jobs[0][0].stop()
def __update(self):
if len(self.__jobs)-1 > 0 :
self.jobs_label.set_text("%d "% (len(self.__jobs)-1) + _("jobs waiting!"))
self.jobs_label.show_all()
else:
self.jobs_label.hide_all()
if self.__jobs:
Dispatcher.show_jobs()
message = self.__jobs[0][0].get_info()
self.progress_label.set_text(message)
self.show()
return True
else:
Dispatcher.hide_jobs()
self.hide()
self.__id_updater = None
return False