本文整理汇总了Python中dtk.ui.button.Button.set_sensitive方法的典型用法代码示例。如果您正苦于以下问题:Python Button.set_sensitive方法的具体用法?Python Button.set_sensitive怎么用?Python Button.set_sensitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.button.Button
的用法示例。
在下文中一共展示了Button.set_sensitive方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_share_box
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import set_sensitive [as 别名]
#.........这里部分代码省略.........
self.__weibo_check_button_list = []
self.__weibo_image_button_list = []
# create Thumbnail
if exists(self.upload_image):
pixbuf = gtk.gdk.pixbuf_new_from_file(self.upload_image)
pix_w = pixbuf.get_width()
pix_h = pixbuf.get_height()
if pix_w > pix_h:
pix_s_w = self.thumb_width
pix_s_h = int(pix_h / (float(pix_w) / self.thumb_width))
else:
pix_s_h = self.thumb_height
pix_s_w = int(pix_w / (float(pix_h) / self.thumb_height))
pixbuf = pixbuf.scale_simple(pix_s_w, pix_s_h, gtk.gdk.INTERP_TILES)
thumb = gtk.image_new_from_pixbuf(pixbuf)
else:
thumb = gtk.Image()
thumb.set_size_request(self.thumb_width, self.thumb_height)
# weibo context input
text_box = gtk.HBox(False, 2)
text_vbox = gtk.VBox(False, 2)
text_bg_vbox = gtk.VBox(False)
text_bg_align = gtk.Alignment()
text_bg_align.set(0.5, 0.5, 0, 0)
text_bg_align.set_padding(5, 5, 16, 5)
text_bg_align.connect("expose-event", self.text_view_bg_expose)
text_scrolled_win = ScrolledWindow()
text_scrolled_win.set_size_request(340, 157)
text_view = gtk.TextView()
text_view.set_left_margin(10)
text_view.set_right_margin(10)
text_view.set_pixels_above_lines(5)
text_view.set_pixels_below_lines(5)
text_view.set_wrap_mode(gtk.WRAP_WORD| gtk.WRAP_CHAR)
text_view.connect("expose-event", self.text_view_expose)
buf = text_view.get_buffer()
text_scrolled_win.add(text_view)
text_bg_vbox.pack_start(text_scrolled_win)
text_bg_align.add(text_bg_vbox)
text_align = gtk.Alignment()
text_align.set(0.5, 0.5, 0, 0)
text_align.set_padding(25, 30, 10, 10)
text_box.pack_start(thumb, False, False, 10)
text_box.pack_start(text_bg_align)
text_vbox.pack_start(text_box, False, False, 10)
text_align.add(text_vbox)
#tmp_align = gtk.Alignment()
#tmp_align.set(0.5, 0, 0, 1)
#self.share_box.pack_start(tmp_align, False, False)
self.share_box.pack_start(text_align, False, False)
# dialog button box
left_box = self.window.left_button_box
right_box = self.window.right_button_box
# input tip label
self.input_num_label = Label("%d" % self.MAX_CHAR,
text_size=16, text_x_align=pango.ALIGN_CENTER, label_width=50, enable_select=False)
self.input_num_label.text_color = app_theme.get_color("left_char_num")
# login box
#weibo_box = gtk.HBox(False, 1)
#weibo_box.set_size_request(-1, 50)
weibo_box_list = []
self.loading_label = Label("%s..." % _("Loading"), text_size=12,
label_width=70, enable_select=False)
weibo_box_list.append(self.loading_label)
for weibo in self.__weibo_list:
box = gtk.HBox(False, 2)
weibo.set_box(box)
weibo_box_list.append(box)
left_box.set_buttons(weibo_box_list)
# share button
button = Button(_("Share"))
#button.set_size_request(75, 25)
button.connect("clicked", self.share_button_clicked, text_view)
buf.connect("changed", self.text_view_changed, button) # check char num
tmp_vbox = gtk.VBox(False)
tmp_align = gtk.Alignment()
tmp_align.set(0.5, 0.5, 0, 0)
tmp_vbox.pack_start(button, False, False)
#tmp_vbox.pack_start(tmp_align)
tmp_align.add(tmp_vbox)
right_box.set_buttons([self.input_num_label, tmp_align])
# at first, set widget insensitive
button.set_sensitive(False)
text_view.set_editable(False)
t = threading.Thread(target=self.init_user_info_thread, args=(button, text_view))
t.setDaemon(True)
t.start()
示例2: FootBox
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import set_sensitive [as 别名]
class FootBox(gtk.HBox):
def __init__(self):
gtk.HBox.__init__(self)
self.set_size_request(-1, 35)
self.apply_method = None
self.init_ui()
self.timer = Timer(3000, self.__clear_tips)
Dispatcher.connect("button-change", self.set_button)
Dispatcher.connect("set-tip", self.set_tip)
event_manager.add_callback("update-delete-button", self.__on_update_delete_button)
def __on_update_delete_button(self, name, obj, data):
#self.btn_delete.set_child_visible(data)
self.queue_draw()
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("",
text_x_align=pango.ALIGN_CENTER,
label_width=500)
self.tip_align.set_padding(5, 5, 20, 0)
self.tip_align.add(self.tip)
self.btn_delete = Button(_("Delete"))
self.btn_delete.connect("clicked", self.delete_click)
self.btn_delete.set_no_show_all(True)
self.btn_save = Button()
self.btn_save.connect("clicked", self.button_click)
button_box = gtk.HBox(spacing=10)
button_box.pack_start(self.btn_delete)
button_box.pack_start(self.btn_save)
self.buttons_align = gtk.Alignment(1, 0.5, 0, 0)
self.buttons_align.set_padding(0, 0, 0, 10)
self.buttons_align.add(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_lock(self, state):
self.__setting_module.set_lock(state)
def get_lock(self):
return self.__setting_module.get_lock()
def set_button(self, widget, content, state):
self.btn_save.set_label(_("Save"))
self.btn_save.set_sensitive(state)
def delete_click(self, widget):
if self.focus_connection:
Dispatcher.delete_setting(self.focus_connection)
Dispatcher.to_main_page()
def show_delete(self, connection):
self.btn_delete.show()
self.focus_connection = connection
def hide_delete(self):
self.btn_delete.hide()
self.focus_connection = None
#if content == "save":
#if state and not self.get_lock():
#Dispatcher.emit("setting-saved")
#else:
#self.btn_save.set_label(_("connect"))
#self.btn_save.set_sensitive(False)
#else:
#self.btn_save.set_label(_("connect"))
#self.btn_save.set_sensitive(True)
def get_button(self):
return self.__setting_module.get_button_state()
def set_setting(self, module):
self.__setting_module = module
def button_click(self, widget):
#if self.btn_save.label == "save":
Dispatcher.emit("setting-saved")
#elif self.btn_save.label == _("connect"):
#Dispatcher.set_tip("setting saved")
#Dispatcher.emit("setting-appled")
#.........这里部分代码省略.........
示例3: SessionView
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import set_sensitive [as 别名]
class SessionView(gtk.VBox):
def __init__(self):
gtk.VBox.__init__(self)
self.open_dialog = False
self.tmp_editing_session = None
# UI style
style.draw_background_color(self)
self.tree = TreeView([],enable_drag_drop=False,
enable_hover=True,
enable_multiple_select=False,
)
self.tree.set_expand_column(3)
self.tree.set_column_titles((_("Active"), _("Application"), _("Description"), _("Exec")),)
self.tree.set_size_request(800, -1)
self.tree.connect("right-press-items", self.right_press_item)
self.tree.draw_mask = self.draw_mask
self.tree.add_items(self.get_list())
align = gtk.Alignment(0, 0, 0, 1)
align.set_padding(15, 0, 20, 20)
align.add(self.tree)
align.connect("expose-event", self.expose_line)
add_button = Button(_("New"))
self.delete_button = Button(_("Delete"))
add_button.connect("clicked", self.add_autostart)
self.delete_button.connect("clicked", self.delete_autostart)
self.delete_button.set_sensitive(False)
foot_box = FootBox(adjustment=15)
foot_box.set_buttons([add_button, self.delete_button])
self.pack_start(align, True, True)
self.pack_end(foot_box, False, False)
#self.pack_end(self.new_box, False, False)
self.show_all()
self._init_monitor()
def disable_delete_button(self, value):
self.delete_button.set_sensitive(not value)
def _init_monitor(self):
self.library_monitor = LibraryMonitor(get_user_config_dir())
self.library_monitor.set_property("monitored", True)
self.library_monitor.connect("file-added", self.refresh_list)
self.library_monitor.connect("location-removed", self.refresh_list)
def right_press_item(self, widget, x_root, y_root, current_item, select_items):
self.tmp_editing_session = current_item.item
for item in select_items:
item.unselect()
if current_item != None:
current_item.select()
if self.open_dialog == False:
dialog = NewSessionDialog(confirm_callback = self.edit_done, cancel_callback = self.cancel_callback)
dialog.name_entry.set_text(current_item.item.name)
dialog.exec_entry.set_text(current_item.item.exec_)
dialog.desc_entry.set_text(current_item.item.comment)
dialog.place_center()
dialog.show_all()
self.open_dialog = True
def create_session_item(self, dialog):
name = dialog.name_entry.get_text()
exec_ = dialog.exec_entry.get_text()
comment = dialog.desc_entry.get_text()
session_manager.add(name, exec_, comment)
self.open_dialog = False
def expose_line(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
style.draw_out_line(cr, rect, exclude=["left", "right", "top"])
def sort_method(self):
pass
def add_autostart(self, widget):
if self.open_dialog == False:
dialog = NewSessionDialog(confirm_callback= self.create_session_item, cancel_callback = self.cancel_callback)
dialog.show_all()
self.open_dialog = True
def delete_autostart(self, widget):
items = map(lambda row: self.tree.visible_items[row], self.tree.select_rows)
item = items[0].item
item.delete()
self.tree.delete_select_items()
if self.tree.visible_items == []:
self.tree.add_items([NothingItem()])
def edit_done(self, dialog):
self.tmp_editing_session.set_name(dialog.name_entry.get_text())
self.tmp_editing_session.set_exec(dialog.exec_entry.get_text())
self.tmp_editing_session.set_comment(dialog.desc_entry.get_text())
#.........这里部分代码省略.........
示例4: BlueToothView
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import set_sensitive [as 别名]
class BlueToothView(gtk.VBox):
'''
class docs
'''
def __init__(self, module_frame):
'''
init docs
'''
gtk.VBox.__init__(self)
self.module_frame = module_frame
self.my_bluetooth = MyBluetooth(self.__on_adapter_removed,
self.__on_default_adapter_changed,
self.__device_found)
self.periodic_timer = None
self.is_discoverable = False
self.is_searching = False
'''
enable open
'''
if self.my_bluetooth.adapter:
self.my_bluetooth.adapter.connect("property-changed", self.__on_property_changed)
if self.my_bluetooth.adapter.get_powered():
self.title_align, self.title_label = self.__setup_title_align(
app_theme.get_pixbuf("bluetooth/enable_open.png"), _("Bluetooth"))
self.title_label.set_sensitive(True)
else:
self.title_align, self.title_label = self.__setup_title_align(
app_theme.get_pixbuf("bluetooth/enable_open_disable.png"), _("Bluetooth"))
else:
self.title_align, self.title_label = self.__setup_title_align(
app_theme.get_pixbuf("bluetooth/enable_open_disable.png"), _("Bluetooth"))
self.title_label.set_sensitive(False)
self.enable_align = self.__setup_align()
self.enable_box = gtk.HBox(spacing=WIDGET_SPACING)
self.enable_open_label = self.__setup_label(_("Enable bluetooth"))
if self.my_bluetooth.adapter:
self.my_bluetooth.adapter.set_powered(permanent_settings.get_powered())
self.enable_open_label.set_sensitive(self.my_bluetooth.adapter.get_powered())
else:
self.enable_open_label.set_sensitive(False)
self.enable_open_toggle_align = self.__setup_align(padding_top = 4, padding_left = 158)
self.enable_open_toggle = self.__setup_toggle()
if self.my_bluetooth.adapter:
self.enable_open_toggle.set_active(self.my_bluetooth.adapter.get_powered())
self.enable_open_toggle.connect("toggled", self.__toggled, "enable_open")
self.enable_open_toggle_align.add(self.enable_open_toggle)
self.__widget_pack_start(self.enable_box,
[self.enable_open_label,
self.enable_open_toggle_align])
self.enable_align.add(self.enable_box)
'''
display
'''
self.display_align = self.__setup_align()
self.display_box = gtk.HBox(spacing=WIDGET_SPACING)
self.display_device_label = self.__setup_label(_("Device name"))
if self.my_bluetooth.adapter:
self.display_device_label.set_sensitive(self.my_bluetooth.adapter.get_powered())
else:
self.display_device_label.set_sensitive(False)
self.display_device_entry = InputEntry()
if self.my_bluetooth.adapter:
self.display_device_entry.set_text(self.my_bluetooth.adapter.get_name())
self.display_device_entry.set_sensitive(self.my_bluetooth.adapter.get_powered())
else:
self.display_device_entry.set_sensitive(False)
self.display_device_entry.set_size(HSCALEBAR_WIDTH, WIDGET_HEIGHT)
self.display_device_entry.entry.connect("changed", self.__display_device_changed)
self.__widget_pack_start(self.display_box,
[self.display_device_label, self.display_device_entry])
self.display_align.add(self.display_box)
'''
enable searchable
'''
self.search_align = self.__setup_align()
self.search_box = gtk.HBox(spacing=WIDGET_SPACING)
self.search_label = self.__setup_label(_("Discoverable"))
if self.my_bluetooth.adapter:
self.search_label.set_sensitive(self.my_bluetooth.adapter.get_powered())
else:
self.search_label.set_sensitive(False)
self.search_timeout_align = self.__setup_align(padding_top = 0, padding_left = 0)
self.search_timeout_label = self.__setup_label("", width = 110, align = ALIGN_START)
self.search_timeout_align.add(self.search_timeout_label)
self.search_toggle_align = self.__setup_align(padding_top = 4, padding_left = 18)
self.search_toggle = self.__setup_toggle()
if self.my_bluetooth.adapter:
self.search_toggle.set_active(self.my_bluetooth.adapter.get_discoverable())
self.search_toggle.connect("toggled", self.__toggled, "search")
self.search_toggle_align.add(self.search_toggle)
self.__widget_pack_start(self.search_box,
[self.search_label,
self.search_timeout_align,
self.search_toggle_align
])
self.search_align.add(self.search_box)
'''
#.........这里部分代码省略.........
示例5: UpdateManager
# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import set_sensitive [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
#.........这里部分代码省略.........