本文整理汇总了Python中sugar3.graphics.palettemenu.PaletteMenuItem.set_visible方法的典型用法代码示例。如果您正苦于以下问题:Python PaletteMenuItem.set_visible方法的具体用法?Python PaletteMenuItem.set_visible怎么用?Python PaletteMenuItem.set_visible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.palettemenu.PaletteMenuItem
的用法示例。
在下文中一共展示了PaletteMenuItem.set_visible方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WirelessNetworkView
# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import set_visible [as 别名]
#.........这里部分代码省略.........
icon_name = 'network-adhoc-%s' % channel
self.props.icon_name = icon_name
icon = self._palette.props.icon
icon.props.icon_name = icon_name
else:
if self._device_state == network.NM_DEVICE_STATE_ACTIVATED and \
self._active_ap is not None:
icon_name = '%s-connected' % _AP_ICON_NAME
else:
icon_name = _AP_ICON_NAME
icon_name = get_icon_state(icon_name, self._strength)
if icon_name:
self.props.icon_name = icon_name
icon = self._palette.props.icon
icon.props.icon_name = icon_name
def _update_badge(self):
badge = None
favorite = False
if self._mode != network.NM_802_11_MODE_ADHOC:
locked = (self._flags == network.NM_802_11_AP_FLAGS_PRIVACY)
connection = network.find_connection_by_ssid(self._ssid)
if connection is not None:
favorite = True
self._connect_removed(connection)
if locked:
badge = 'emblem-favorite-locked'
else:
badge = 'emblem-favorite'
elif locked:
badge = 'emblem-locked'
self.props.badge_name = self._palette_icon.props.badge_name = badge
self._forget_item.set_visible(favorite)
def _connect_removed(self, connection):
if self._removed_hid is not None:
return
self._removed_hid = connection.connect('removed',
self._connection_removed_cb)
def _disconnect_removed(self, connection):
connection.disconnect(self._removed_hid)
self._removed_hid = None
def _connection_removed_cb(self, connection):
self._update_badge()
self._disconnect_removed(connection)
def _update_state(self):
if self._active_ap is not None:
state = self._device_state
else:
state = network.NM_DEVICE_STATE_UNKNOWN
if state == network.NM_DEVICE_STATE_PREPARE or \
state == network.NM_DEVICE_STATE_CONFIG or \
state == network.NM_DEVICE_STATE_NEED_AUTH or \
state == network.NM_DEVICE_STATE_IP_CONFIG:
if self._disconnect_item:
self._disconnect_item.show()
self._connect_item.hide()
self._palette.props.secondary_text = _('Connecting...')
self.props.pulsing = True
elif state == network.NM_DEVICE_STATE_ACTIVATED:
示例2: PrimaryToolbar
# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import set_visible [as 别名]
class PrimaryToolbar(ToolbarBase):
__gtype_name__ = 'PrimaryToolbar'
__gsignals__ = {
'go-home': (GObject.SignalFlags.RUN_FIRST,
None,
([])),
'set-home': (GObject.SignalFlags.RUN_FIRST,
None,
([])),
'reset-home': (GObject.SignalFlags.RUN_FIRST,
None,
([])),
'go-library': (GObject.SignalFlags.RUN_FIRST,
None,
([])),
}
def __init__(self, tabbed_view, act):
ToolbarBase.__init__(self)
self._url_toolbar = UrlToolbar()
self._activity = act
self._tabbed_view = tabbed_view
self._loading = False
toolbar = self.toolbar
activity_button = ActivityToolbarButton(self._activity)
toolbar.insert(activity_button, 0)
self._go_home = ToolButton('go-home')
self._go_home.set_tooltip(_('Home page'))
self._go_home.connect('clicked', self._go_home_cb)
# add a menu to save the home page
menu_box = PaletteMenuBox()
self._go_home.props.palette.set_content(menu_box)
menu_item = PaletteMenuItem()
menu_item.set_label(_('Select as initial page'))
menu_item.connect('activate', self._set_home_cb)
menu_box.append_item(menu_item)
self._reset_home_menu = PaletteMenuItem()
self._reset_home_menu.set_label(_('Reset initial page'))
self._reset_home_menu.connect('activate', self._reset_home_cb)
menu_box.append_item(self._reset_home_menu)
if os.path.isfile(LIBRARY_PATH):
library_menu = PaletteMenuItem()
library_menu.set_label(_('Library'))
library_menu.connect('activate', self._go_library_cb)
menu_box.append_item(library_menu)
menu_box.show_all()
# verify if the home page is configured
client = GConf.Client.get_default()
self._reset_home_menu.set_visible(
client.get_string(HOME_PAGE_GCONF_KEY) is not None)
toolbar.insert(self._go_home, -1)
self._go_home.show()
self.entry = WebEntry()
self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
'entry-stop')
self.entry.connect('icon-press', self._stop_and_reload_cb)
self.entry.connect('activate', self._entry_activate_cb)
self.entry.connect('focus-in-event', self.__focus_in_event_cb)
self.entry.connect('focus-out-event', self.__focus_out_event_cb)
self.entry.connect('key-press-event', self.__key_press_event_cb)
self.entry.connect('changed', self.__changed_cb)
self._entry_item = Gtk.ToolItem()
self._entry_item.set_expand(True)
self._entry_item.add(self.entry)
self.entry.show()
toolbar.insert(self._entry_item, -1)
self._entry_item.show()
self._back = ToolButton('go-previous-paired')
self._back.set_tooltip(_('Back'))
self._back.props.sensitive = False
self._back.connect('clicked', self._go_back_cb)
toolbar.insert(self._back, -1)
self._back.show()
palette = self._back.get_palette()
self._back_box_menu = Gtk.VBox()
self._back_box_menu.show()
palette.set_content(self._back_box_menu)
# FIXME, this is a hack, should be done in the theme:
palette._content.set_border_width(1)
self._forward = ToolButton('go-next-paired')
self._forward.set_tooltip(_('Forward'))
#.........这里部分代码省略.........
示例3: PrimaryToolbar
# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import set_visible [as 别名]
class PrimaryToolbar(ToolbarBase):
__gtype_name__ = "PrimaryToolbar"
__gsignals__ = {
"add-link": (GObject.SignalFlags.RUN_FIRST, None, ([])),
"go-home": (GObject.SignalFlags.RUN_FIRST, None, ([])),
"set-home": (GObject.SignalFlags.RUN_FIRST, None, ([])),
"reset-home": (GObject.SignalFlags.RUN_FIRST, None, ([])),
"go-library": (GObject.SignalFlags.RUN_FIRST, None, ([])),
"go-to-JSshell": (GObject.SignalFlags.RUN_FIRST, None, ([])),
"get-shell-input": (GObject.SignalFlags.RUN_FIRST, None, ([])),
}
def __init__(self, tabbed_view, act):
ToolbarBase.__init__(self)
self._url_toolbar = UrlToolbar()
self._activity = act
self._tabbed_view = self._canvas = tabbed_view
self._loading = False
toolbar = self.toolbar
activity_button = ActivityToolbarButton(self._activity)
toolbar.insert(activity_button, 0)
separator = Gtk.SeparatorToolItem()
save_as_pdf = ToolButton("save-as-pdf")
save_as_pdf.set_tooltip(_("Save page as pdf"))
save_as_pdf.connect("clicked", self.save_as_pdf)
activity_button.props.page.insert(separator, -1)
activity_button.props.page.insert(save_as_pdf, -1)
separator.show()
save_as_pdf.show()
self._go_home = ToolButton("go-home")
self._go_home.set_tooltip(_("Home page"))
self._go_home.connect("clicked", self._go_home_cb)
# add a menu to save the home page
menu_box = PaletteMenuBox()
self._go_home.props.palette.set_content(menu_box)
menu_item = PaletteMenuItem()
menu_item.set_label(_("Select as initial page"))
menu_item.connect("activate", self._set_home_cb)
menu_box.append_item(menu_item)
self._reset_home_menu = PaletteMenuItem()
self._reset_home_menu.set_label(_("Reset initial page"))
self._reset_home_menu.connect("activate", self._reset_home_cb)
menu_box.append_item(self._reset_home_menu)
if os.path.isfile(LIBRARY_PATH):
library_menu = PaletteMenuItem()
library_menu.set_label(_("Library"))
library_menu.connect("activate", self._go_library_cb)
menu_box.append_item(library_menu)
menu_box.show_all()
# verify if the home page is configured
client = GConf.Client.get_default()
self._reset_home_menu.set_visible(client.get_string(HOME_PAGE_GCONF_KEY) is not None)
toolbar.insert(self._go_home, -1)
self._go_home.show()
self.entry = WebEntry()
self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY, "entry-stop")
self.entry.connect("icon-press", self._stop_and_reload_cb)
self.entry.connect("activate", self._entry_activate_cb)
self.entry.connect("focus-in-event", self.__focus_in_event_cb)
self.entry.connect("focus-out-event", self.__focus_out_event_cb)
self.entry.connect("key-press-event", self.__key_press_event_cb)
self.entry.connect("changed", self.__changed_cb)
self._entry_item = Gtk.ToolItem()
self._entry_item.set_expand(True)
self._entry_item.add(self.entry)
self.entry.show()
toolbar.insert(self._entry_item, -1)
self._entry_item.show()
self._back = ToolButton("go-previous-paired")
self._back.set_tooltip(_("Back"))
self._back.props.sensitive = False
self._back.connect("clicked", self._go_back_cb)
toolbar.insert(self._back, -1)
self._back.show()
palette = self._back.get_palette()
self._back_box_menu = Gtk.VBox()
self._back_box_menu.show()
palette.set_content(self._back_box_menu)
# FIXME, this is a hack, should be done in the theme:
#.........这里部分代码省略.........
示例4: PrimaryToolbar
# 需要导入模块: from sugar3.graphics.palettemenu import PaletteMenuItem [as 别名]
# 或者: from sugar3.graphics.palettemenu.PaletteMenuItem import set_visible [as 别名]
class PrimaryToolbar(ToolbarBase):
__gtype_name__ = 'PrimaryToolbar'
__gsignals__ = {
'add-link': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'remove-link': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'go-home': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'set-home': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'reset-home': (GObject.SignalFlags.RUN_FIRST, None, ([])),
'go-library': (GObject.SignalFlags.RUN_FIRST, None, ([])),
}
def __init__(self, tabbed_view, act):
ToolbarBase.__init__(self)
self._url_toolbar = UrlToolbar()
self._activity = act
self.model = act.model
self.model.link_removed_signal.connect(self.__link_removed_cb)
self._tabbed_view = self._canvas = tabbed_view
self._loading = False
self._download_running_hid = None
toolbar = self.toolbar
activity_button = ActivityToolbarButton(self._activity)
toolbar.insert(activity_button, 0)
separator = Gtk.SeparatorToolItem()
'''
Disabled since the python gi bindings don't expose the critical
WebKit2.PrintOperation.print function
save_as_pdf = ToolButton('save-as-pdf')
save_as_pdf.set_tooltip(_('Save page as pdf'))
save_as_pdf.connect('clicked', self.save_as_pdf)
activity_button.props.page.insert(separator, -1)
activity_button.props.page.insert(save_as_pdf, -1)
separator.show()
save_as_pdf.show()
'''
inspect_view = ToolButton('emblem-view-source')
inspect_view.set_tooltip(_('Show Web Inspector'))
inspect_view.connect('clicked', self.inspect_view)
activity_button.props.page.insert(separator, -1)
activity_button.props.page.insert(inspect_view, -1)
separator.show()
inspect_view.show()
self._go_home = ToolButton('go-home')
self._go_home.set_tooltip(_('Home page'))
self._go_home.connect('clicked', self._go_home_cb)
# add a menu to save the home page
menu_box = PaletteMenuBox()
self._go_home.props.palette.set_content(menu_box)
menu_item = PaletteMenuItem()
menu_item.set_label(_('Select as initial page'))
menu_item.connect('activate', self._set_home_cb)
menu_box.append_item(menu_item)
self._reset_home_menu = PaletteMenuItem()
self._reset_home_menu.set_label(_('Reset initial page'))
self._reset_home_menu.connect('activate', self._reset_home_cb)
menu_box.append_item(self._reset_home_menu)
if os.path.isfile(LIBRARY_PATH):
library_menu = PaletteMenuItem()
library_menu.set_label(_('Library'))
library_menu.connect('activate', self._go_library_cb)
menu_box.append_item(library_menu)
menu_box.show_all()
# verify if the home page is configured
client = GConf.Client.get_default()
self._reset_home_menu.set_visible(
client.get_string(HOME_PAGE_GCONF_KEY) is not None)
toolbar.insert(self._go_home, -1)
self._go_home.show()
self.entry = WebEntry()
self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
'entry-stop')
self.entry.connect('icon-press', self._stop_and_reload_cb)
self.entry.connect('activate', self._entry_activate_cb)
self.entry.connect('focus-in-event', self.__focus_in_event_cb)
self.entry.connect('focus-out-event', self.__focus_out_event_cb)
self.entry.connect('key-press-event', self.__key_press_event_cb)
self.entry.connect('changed', self.__changed_cb)
# In an event box so that it can render the background
entry_box = Gtk.EventBox()
entry_box.add(self.entry)
entry_box.show()
#.........这里部分代码省略.........