当前位置: 首页>>代码示例>>Python>>正文


Python translations._函数代码示例

本文整理汇总了Python中wicd.translations._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_settings

    def save_settings(self):
        """ Save settings to disk. """
        # Check encryption info
        if self.encryption_chkbox.get_state():
            encrypt_info = self.encryption_info
            encrypt_methods = self.encrypt_types
            self.set_net_prop(
                "enctype",
                encrypt_methods[self.encryption_combo.get_focus()[1]]['type']
            )
            # Make sure all required fields are filled in.
            for entry_info in encrypt_info.itervalues():
                if entry_info[0].get_edit_text() == "" \
                    and entry_info[1] == 'required':
                    error(
                        self.ui,
                        self.parent,
                        "%s (%s)" % (
                            _('Required encryption information is missing.'),
                            entry_info[0].get_caption()[0:-2]
                        )
                    )
                    return False

            for entry_key, entry_info in encrypt_info.iteritems():
                self.set_net_prop(entry_key, noneToString(entry_info[0].
                                                   get_edit_text()))
        elif not self.encryption_chkbox.get_state() and \
             wireless.GetWirelessProperty(self.networkid, "encryption"):
            # Encrypt checkbox is off, but the network needs it.
            error(
                self.ui,
                self.parent,
                _('This network requires encryption to be enabled.')
            )
            return False
        else:
            self.set_net_prop("enctype", "None")
        AdvancedSettingsDialog.save_settings(self)

        # Save the autoconnect setting.  This is not where it originally was
        # in the GTK UI.
        self.set_net_prop("automatic", self.autoconnect_chkbox.get_state())

        if self.global_settings_chkbox.get_state():
            self.set_net_prop('use_settings_globally', True)
        else:
            self.set_net_prop('use_settings_globally', False)
            wireless.RemoveGlobalEssidEntry(self.networkid)

        self.set_net_prop(
            'bitrate',
            self.bitrates[self.bitrate_combo.get_focus()[1]]
        )
        self.set_net_prop(
            'allow_lower_bitrates',
            self.allow_lower_bitrates_chkbox.get_state()
        )
        wireless.SaveWirelessNetworkProfile(self.networkid)
        return True
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:60,代码来源:netentry_curses.py

示例2: __init__

    def __init__(self, networkID):
        """ Build the wireless network entry. """
        NetworkEntry.__init__(self)

        self.networkID = networkID
        self.image.set_padding(0, 0)
        self.image.set_alignment(.5, .5)
        self.image.set_size_request(60, -1)
        self.image.show()
        self.essid = noneToBlankString(wireless.GetWirelessProperty(networkID,
                                                                    "essid"))
        self.lbl_strength = GreyLabel()
        self.lbl_encryption = GreyLabel()
        self.lbl_channel = GreyLabel()
        
        print "ESSID : " + self.essid
        self.chkbox_autoconnect = gtk.CheckButton(_('Automatically connect to this network'))
        self.chkbox_neverconnect = gtk.CheckButton(_('Never connect to this network'))
        
        self.set_signal_strength(wireless.GetWirelessProperty(networkID, 
                                                              'quality'),
                                 wireless.GetWirelessProperty(networkID, 
                                                              'strength'))
        self.set_encryption(wireless.GetWirelessProperty(networkID, 
                                                         'encryption'),
                            wireless.GetWirelessProperty(networkID, 
                                                 'encryption_method')) 
        self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
        self.name_label.set_use_markup(True)
        self.name_label.set_label("<b>%s</b>    %s    %s    %s" % (self._escape(self.essid),
                                                         self.lbl_strength.get_label(),
                                                         self.lbl_encryption.get_label(),
                                                         self.lbl_channel.get_label(),
                                                        )
                                 )
        # Add the wireless network specific parts to the NetworkEntry
        # VBox objects.
        self.vbox_top.pack_start(self.chkbox_autoconnect, False, False)
        self.vbox_top.pack_start(self.chkbox_neverconnect, False, False)

        if to_bool(self.format_entry(networkID, "automatic")):
            self.chkbox_autoconnect.set_active(True)
        else:
            self.chkbox_autoconnect.set_active(False)
        
        if to_bool(self.format_entry(networkID, "never")):
            self.chkbox_autoconnect.set_sensitive(False)
            self.connect_button.set_sensitive(False)
            self.chkbox_neverconnect.set_active(True)
        else:
            self.chkbox_neverconnect.set_active(False)

        # Connect signals.
        self.chkbox_autoconnect.connect("toggled", self.update_autoconnect)
        self.chkbox_neverconnect.connect("toggled", self.update_neverconnect)
        
        # Show everything
        self.show_all()
        self.advanced_dialog = WirelessSettingsDialog(networkID)
        self.wifides = self.connect("destroy", self.destroy_called)
开发者ID:FedericoCeratto,项目名称:wicd,代码行数:60,代码来源:netentry.py

示例3: refresh_networks

    def refresh_networks(self, widget=None, fresh=True, hidden=None):
        """ Refreshes the network list.

        If fresh=True, scans for wireless networks and displays the results.
        If a ethernet connection is available, or the user has chosen to,
        displays a Wired Network entry as well.
        If hidden isn't None, will scan for networks after running
        iwconfig <wireless interface> essid <hidden>.

        """
        if fresh:
            if hidden:
                wireless.SetHiddenNetworkESSID(noneToString(hidden))
            self.refresh_clicked()
            return
        print "refreshing..."
        self.network_list.set_sensitive(False)
        self._remove_items_from_vbox(self.network_list)
        self.wait_for_events()
        printLine = False  # We don't print a separator by default.
        if self._wired_showing:
            printLine = True
        num_networks = wireless.GetNumberOfNetworks()
        instruct_label = self.wTree.get_object("label_instructions")
        if num_networks > 0:
            skip_never_connect = not daemon.GetShowNeverConnect()
            instruct_label.show()
            for x in xrange(0, num_networks):
                if skip_never_connect and \
                  misc.to_bool(get_wireless_prop(x, 'never')):
                    continue
                if printLine:
                    sep = gtk.HSeparator()
                    self.network_list.pack_start(sep, padding=10, fill=False,
                                                 expand=False)
                    sep.show()
                else:
                    printLine = True
                tempnet = WirelessNetworkEntry(x)
                self.network_list.pack_start(tempnet, False, False)
                tempnet.connect_button.connect("clicked",
                                               self.connect, "wireless", x,
                                               tempnet)
                tempnet.disconnect_button.connect("clicked",
                                                  self.disconnect, "wireless",
                                                  x, tempnet)
                tempnet.advanced_button.connect("clicked",
                                                self.edit_advanced, "wireless",
                                                x, tempnet)
        else:
            instruct_label.hide()
            if wireless.GetKillSwitchEnabled():
                label = gtk.Label(_('Wireless Kill Switch Enabled') + ".")
            else:
                label = gtk.Label(_('No wireless networks found.'))
            self.network_list.pack_start(label)
            label.show()
        self.update_connect_buttons(force_check=True)
        self.network_list.set_sensitive(True)
        self.refreshing = False
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:60,代码来源:gui.py

示例4: run_configscript

def run_configscript(parent,netname,nettype):
    configfile = wpath.etc+netname+'-settings.conf'
    if nettype != 'wired':
        header = 'profile'
    else:
        header ='BSSID'
    if nettype == 'wired':
        profname = nettype
    else:
        profname = wireless.GetWirelessProperty( int(netname),'bssid')
    theText = [
    _('To avoid various complications, wicd-curses does not support directly editing the scripts. '\
      'However, you can edit them manually. First, (as root), open the "$A" config file, and look '\
      'for the section labeled by the $B in question. In this case, this is:').
        replace('$A', configfile).replace('$B', header),
"\n\n["+profname+"]\n\n",
    _('You can also configure the wireless networks by looking for the "[<ESSID>]" field in the config file.'),
    _('Once there, you can adjust (or add) the "beforescript", "afterscript", "predisconnectscript" '\
      'and "postdisconnectscript" variables as needed, to change the preconnect, postconnect, '\
      'predisconnect and postdisconnect scripts respectively.  Note that you will be specifying '\
      'the full path to the scripts - not the actual script contents.  You will need to add/edit '\
      'the script contents separately.  Refer to the wicd manual page for more information.')
    ]
    dialog = TextDialog(theText,20,80)
    dialog.run(ui,parent)
    # This code works with many distributions, but not all of them.  So, to
    # limit complications, it has been deactivated.  If you want to run it,
    # be my guest.  Be sure to deactivate the above stuff first.
    """
开发者ID:FedericoCeratto,项目名称:wicd,代码行数:29,代码来源:wicd-curses.py

示例5: keypress

    def keypress(self, size, key):
        """ Handle keypresses. """
        prev_focus = self.get_focus()[1]
        key = ComboBox.keypress(self, size, key)
        if key == ' ':
            if self.get_focus()[1] == len(self.list) - 1:
                dialog = InputDialog(
                    ('header', _('Add a new wired profile')),
                    7, 30
                )
                exitcode, name = dialog.run(ui, self.parent)
                if exitcode == 0:
                    name = name.strip()
                    if not name:
                        error(ui, self.parent, 'Invalid profile name')
                        self.set_focus(prev_focus)
                        return key

                    wired.CreateWiredNetworkProfile(name, False)
                    self.set_list(wired.GetWiredProfileList())
                    self.rebuild_combobox()
                self.set_focus(prev_focus)
            else:
                wired.ReadWiredNetworkProfile(self.get_selected_profile())
        if key == 'delete':
            if len(self.theList) == 1:
                error(
                    self.ui,
                    self.parent,
                    _('wicd-curses does not support deleting the last wired '
                    'profile.  Try renaming it ("F2")')
                )
                return key
            wired.DeleteWiredNetworkProfile(self.get_selected_profile())
            # Return to the top of the list if something is deleted.

            if wired.GetDefaultWiredNetwork() is not None:
                self.set_focus(
                    self.theList.index(wired.GetDefaultWiredNetwork())
                )
            else:
                prev_focus -= 1
                self.set_focus(prev_focus)
            self.set_list(wired.GetWiredProfileList())
            self.rebuild_combobox()
        if key == 'f2':
            dialog = InputDialog(
                ('header', _('Rename wired profile')),
                7, 30,
                edit_text=unicode(self.get_selected_profile())
            )
            exitcode, name = dialog.run(ui, self.parent)
            if exitcode == 0:
                # Save the new one, then kill the old one
                wired.SaveWiredNetworkProfile(name)
                wired.DeleteWiredNetworkProfile(self.get_selected_profile())
                self.set_list(wired.GetWiredProfileList())
                self.set_focus(self.theList.index(name))
                self.rebuild_combobox()
        return key
开发者ID:cpyarger,项目名称:wicd,代码行数:60,代码来源:wicd-curses.py

示例6: wrapper

 def wrapper(*args, **kargs):
     try:
         return func(*args, **kargs)
     except KeyboardInterrupt:
         #gobject.source_remove(redraw_tag)
         loop.quit()
         ui.stop()
         print >> sys.stderr, "\n" + _('Terminated by user')
         #raise
     except DBusException:
         loop.quit()
         ui.stop()
         print >> sys.stderr, "\n" + _('DBus failure! '
             'This is most likely caused by the wicd daemon '
             'stopping while wicd-curses is running. '
             'Please restart the daemon, and then restart wicd-curses.')
         raise
     except:
         # Quit the loop
         #if 'loop' in locals():
         loop.quit()
         # Zap the screen
         ui.stop()
         # Print out standard notification:
         # This message was far too scary for humans, so it's gone now.
         # print >> sys.stderr, "\n" + _('EXCEPTION! Please report this '
         # 'to the maintainer and file a bug report with the backtrace '
         # 'below:')
         # Flush the buffer so that the notification is always above the
         # backtrace
         sys.stdout.flush()
         # Raise the exception
         raise
开发者ID:cpyarger,项目名称:wicd,代码行数:33,代码来源:wicd-curses.py

示例7: __init__

    def __init__(self):
        self.to_remove = dict(essid=[], bssid=[])

        header = urwid.AttrWrap(
            urwid.Text('  %20s %20s' % ('ESSID', 'BSSID')),
            'listbar'
        )
        title = urwid.Text(_('Please select the networks to forget'))
        l = [title, header]
        for entry in wireless.GetSavedWirelessNetworks():
            label = '%20s %20s'
            if entry[1] != 'None':
                label = label % (entry[0], entry[1])
                data = entry
            else:
                label = label % (entry[0], 'global')
                data = (entry[0], 'essid:' + entry[0])

            cb = urwid.CheckBox(
                label,
                on_state_change=self.update_to_remove,
                user_data=data
            )
            l.append(cb)
        body = urwid.ListBox(l)

        header = ('header', _('List of saved networks'))
        Dialog2.__init__(self, header, 15, 50, body)
        self.add_buttons([(_('Remove'), 1), (_('Cancel'), -1)])
        self.frame.set_focus('body')
开发者ID:cpyarger,项目名称:wicd,代码行数:30,代码来源:wicd-curses.py

示例8: about_dialog

def about_dialog(body):
    """ About dialog. """
    # This looks A LOT better when it is actually displayed.  I promise :-).
    # The ASCII Art "Wicd" was made from the "smslant" font on one of those
    # online ASCII big text generators.
    theText = [
('green', "   ///       \\\\\\"), "       _      ___        __\n",
('green', "  ///         \\\\\\"), "     | | /| / (_)______/ /\n",
('green', " ///           \\\\\\"), "    | |/ |/ / / __/ _  / \n",
('green', "/||  //     \\\\  ||\\"), "   |__/|__/_/\__/\_,_/  \n",
('green', "|||  ||"), "(|^|)", ('green', "||  |||"),
"         ($VERSION)       \n".replace("$VERSION", daemon.Hello()),

('green', "\\||  \\\\"), " |+| ", ('green', "//  ||/    \n"),
('green', " \\\\\\"), "    |+|    ", ('green', "///"),
    "      http://wicd.net\n",
('green', "  \\\\\\"), "   |+|   ", ('green', "///"), "      ",
    _('Brought to you by:'), "\n",
('green', "   \\\\\\"), "  |+|  ", ('green', "///"), "       Adam Blackburn\n",
"     ___|+|___         Dan O'Reilly\n",
"    ____|+|____        Andrew Psaltis\n",
"   |-----------|       David Paleino\n",
"-----------------------------------------------------"]
    about = TextDialog(theText, 16, 55, header=('header', _('About Wicd')))
    about.run(ui, body)
开发者ID:cpyarger,项目名称:wicd,代码行数:25,代码来源:wicd-curses.py

示例9: setup_dbus

def setup_dbus(force=True):
    """ Initialize DBus. """
    global bus, daemon, wireless, wired
    try:
        dbusmanager.connect_to_dbus()
    except DBusException:
        print >> sys.stderr, \
          _("Can't connect to the daemon, trying to start it automatically...")

    try:
           bus = dbusmanager.get_bus()
           dbus_ifaces = dbusmanager.get_dbus_ifaces()
           daemon = dbus_ifaces['daemon']
           wireless = dbus_ifaces['wireless']
           wired = dbus_ifaces['wired']
    except DBusException:
        print >> sys.stderr, \
          _("Can't automatically start the daemon, this error is fatal...")

    if not daemon:
        print 'Error connecting to wicd via D-Bus. ' \
            'Please make sure the wicd service is running.'
        sys.exit(3)

    netentry_curses.dbus_init(dbus_ifaces)
    return True
开发者ID:somasis,项目名称:wicd,代码行数:26,代码来源:wicd-curses.py

示例10: __init__

    def __init__(self, name, parent):
        AdvancedSettingsDialog.__init__(self)
        self.wired = True

        self.set_default = urwid.CheckBox(
            _('Use as default profile (overwrites any previous default)')
        )
        #self.cur_default =
        # Add widgets to listbox
        self._w.body.body.append(self.set_default)

        self.parent = parent
        encryption_t = _('Use Encryption')

        self.encryption_chkbox = urwid.CheckBox(
            encryption_t,
            on_state_change=self.
            encryption_toggle
        )
        self.encryption_combo = ComboBox(callback=self.combo_on_change)
        self.pile_encrypt = None
        # _w is a Frame, _w.body is a ListBox, _w.body.body is the ListWalker
        # pylint: disable-msg=E1103
        self._listbox.body.append(self.encryption_chkbox)
        # pylint: disable-msg=E1103
        self._listbox.body.append(self.encryption_combo)
        self.encrypt_types = misc.LoadEncryptionMethods(wired=True)
        self.set_values()

        self.prof_name = name
        title = _('Configuring preferences for wired profile "$A"'). \
            replace('$A', self.prof_name)
        self._w.header = urwid.Text(('header', title), align='right')

        self.set_values()
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:35,代码来源:netentry_curses.py

示例11: run_configscript

def run_configscript(parent, netname, nettype):
    """ Run configuration script. """
    configfile = wpath.etc + netname + '-settings.conf'
    if nettype != 'wired':
        header = 'profile'
    else:
        header = 'BSSID'
    if nettype == 'wired':
        profname = nettype
    else:
        profname = wireless.GetWirelessProperty(int(netname), 'bssid')
    theText = [
_('To avoid various complications, wicd-curses does not support directly '
'editing the scripts. However, you can edit them manually. First, (as root), '
'open the "$A" config file, and look for the section labeled by the $B in '
'question. In this case, this is:').
replace('$A', configfile).replace('$B', header),
"\n\n[" + profname + "]\n\n",
_('You can also configure the wireless networks by looking for the "[<ESSID>]" '
'field in the config file.'),
_('Once there, you can adjust (or add) the "beforescript", "afterscript", '
'"predisconnectscript" and "postdisconnectscript" variables as needed, to '
'change the preconnect, postconnect, predisconnect and postdisconnect scripts '
'respectively.  Note that you will be specifying the full path to the scripts '
'- not the actual script contents.  You will need to add/edit the script '
'contents separately.  Refer to the wicd manual page for more information.')
    ]
    dialog = TextDialog(theText, 20, 80)
    dialog.run(ui, parent)
开发者ID:cpyarger,项目名称:wicd,代码行数:29,代码来源:wicd-curses.py

示例12: __init__

    def __init__(self,networkID,parent):
        global wireless, daemon
        AdvancedSettingsDialog.__init__(self)
        self.wired = False
        
        self.networkid = networkID
        self.parent = parent
        global_settings_t = _('Use these settings for all networks sharing this essid')
        encryption_t = _('Use Encryption')
        autoconnect_t = _('Automatically connect to this network')
        
        self.global_settings_chkbox = urwid.CheckBox(global_settings_t)
        self.encryption_chkbox = urwid.CheckBox(encryption_t,on_state_change=self.encryption_toggle)
        self.encryption_combo = ComboBox(callback=self.combo_on_change)
        self.autoconnect_chkbox = urwid.CheckBox(autoconnect_t)
        self.pile_encrypt = None
        # _w is a Frame, _w.body is a ListBox, _w.body.body is the ListWalker :-)
        self._listbox.body.append(self.global_settings_chkbox)
        self._listbox.body.append(self.autoconnect_chkbox)
        self._listbox.body.append(self.encryption_chkbox)
        self._listbox.body.append(self.encryption_combo)
        self.encrypt_types = misc.LoadEncryptionMethods()
        self.set_values()

        title = _('Configuring preferences for wireless network "$A" ($B)').replace('$A',wireless.GetWirelessProperty(networkID,'essid')).replace('$B',wireless.GetWirelessProperty(networkID,'bssid'))
        self._w.header = urwid.Text(('header',title),align='right' )
开发者ID:mcagl,项目名称:wicd,代码行数:26,代码来源:netentry_curses.py

示例13: init_other_optcols

 def init_other_optcols(self):
     """ Init "tabbed" preferences dialog. """
     self.prefCols = OptCols(
         [("S", _("Save")), ("page up", _("Tab Left")), ("page down", _("Tab Right")), ("esc", _("Cancel"))],
         self.handle_keys,
     )
     self.confCols = OptCols([("S", _("Save")), ("esc", _("Cancel"))], self.handle_keys)
开发者ID:M157q,项目名称:wicd,代码行数:7,代码来源:wicd-curses.py

示例14: forget_network

    def forget_network(self, widget=None):
        """
        Shows a dialog that lists saved wireless networks, and lets the user
        delete them.
        """
        wireless.ReloadConfig()
        dialog = gtk.Dialog(title = _('List of saved networks'),
                            flags = gtk.DIALOG_MODAL,
                            buttons=(gtk.STOCK_DELETE, 1, gtk.STOCK_OK, 2))
        dialog.set_has_separator(True)
        dialog.set_size_request(400, 200)

        networks = gtk.ListStore(str, str)
        for entry in wireless.GetSavedWirelessNetworks():
            if entry[1] != 'None':
                networks.append(entry)
            else:
                networks.append((entry[0], _('Global settings for this ESSID')))
        tree = gtk.TreeView(model=networks)
        tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

        cell = gtk.CellRendererText()

        column = gtk.TreeViewColumn(_('ESSID'), cell, text = 0)
        tree.append_column(column)

        column = gtk.TreeViewColumn(_('BSSID'), cell, text = 1)
        tree.append_column(column)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.add(tree)
        dialog.vbox.pack_start(scroll)
        dialog.vbox.set_spacing(5)
        dialog.show_all()
        response = dialog.run()
        if response == 1:
            model, pathlist = tree.get_selection().get_selected_rows()
            to_remove = dict(essid=[], bssid=[])
            if pathlist:
                for row in pathlist:
                    iter = model.get_iter(path=row)
                    to_remove['essid'].append(misc.noneToString(model.get_value(iter, 0)))
                    to_remove['bssid'].append(model.get_value(iter, 1))

                confirm = gtk.MessageDialog(
                        flags = gtk.DIALOG_MODAL,
                        type = gtk.MESSAGE_INFO,
                        buttons = gtk.BUTTONS_YES_NO,
                        message_format = _('Are you sure you want to discard' +
                            ' settings for the selected networks?')
                    )
                confirm.format_secondary_text('\n'.join(to_remove['essid']))
                response = confirm.run()
                if response == gtk.RESPONSE_YES:
                    map(wireless.DeleteWirelessNetwork, to_remove['bssid'])
                    wireless.ReloadConfig()
                confirm.destroy()
        dialog.destroy()
开发者ID:mcagl,项目名称:wicd,代码行数:59,代码来源:gui.py

示例15: set_encryption

 def set_encryption(self, on, ttype):
     """ Set the encryption value for the WirelessNetworkEntry. """
     if on and ttype:
         self.lbl_encryption.set_label(str(ttype))
     if on and not ttype: 
         self.lbl_encryption.set_label(_('Secured'))
     if not on:
         self.lbl_encryption.set_label(_('Unsecured'))
开发者ID:FedericoCeratto,项目名称:wicd,代码行数:8,代码来源:netentry.py


注:本文中的wicd.translations._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。