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


Python HIGTable.set_sensitive方法代码示例

本文整理汇总了Python中higwidgets.higtables.HIGTable.set_sensitive方法的典型用法代码示例。如果您正苦于以下问题:Python HIGTable.set_sensitive方法的具体用法?Python HIGTable.set_sensitive怎么用?Python HIGTable.set_sensitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在higwidgets.higtables.HIGTable的用法示例。


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

示例1: NSEPreferencesNetwork

# 需要导入模块: from higwidgets.higtables import HIGTable [as 别名]
# 或者: from higwidgets.higtables.HIGTable import set_sensitive [as 别名]
class NSEPreferencesNetwork(HIGVBox):
    
    def __init__(self, preferences, config, show_label=True):
	HIGVBox.__init__(self)
	self.set_border_width(8)
	if show_label:
	    self.pack_start(HIGSectionLabel(_("Proxy Server")), False, False)
	self.preferences = preferences
	self.config = config
	self.create_widgets()
	    
    def create_widgets(self):
	proxies = self.config.get_proxies()

        vbox = HIGVBox()
        
        self.no_proxy_radio = gtk.RadioButton(None, _("Direct connection to the Internet"))
        vbox.pack_start(self.no_proxy_radio, False, False)
        self.proxy_radio = gtk.RadioButton(self.no_proxy_radio, _("Manual proxy configuration"))
        vbox.pack_start(self.proxy_radio, False, False)
        if proxies:
            http_proxy = proxies.get('http', ":3128")
            ftp_proxy = proxies.get('ftp', ":3128") 
        else:
            http_proxy = self.preferences.http_proxy
            ftp_proxy = self.preferences.ftp_proxy

        self.proxy_table = HIGTable(2, 4)
        self.http_host, self.http_port = self.create_proxy_row(self.proxy_table, 0, "HTTP", http_proxy)
        self.ftp_host, self.ftp_port = self.create_proxy_row(self.proxy_table, 1, "FTP", ftp_proxy)
        vbox.pack_start(HIGSpacer(self.proxy_table), False, False)

        if proxies:
            self.proxy_radio.set_active(True)
            self.proxy_table.set_sensitive(True)
        else:
            self.no_proxy_radio.set_active(True)
            self.proxy_table.set_sensitive(False)

        self.proxy_radio.connect("toggled",
                                 lambda b: self._update_use_proxy())
	
	self.http_host.connect("focus-out-event",
                                       self._update_http_proxy)
	
	self.ftp_host.connect("focus-out-event",
                                       self._update_ftp_proxy)
	
	self.http_port.connect("focus-out-event",
                                       self._update_http_proxy)
	
	self.ftp_port.connect("focus-out-event",
                                       self._update_ftp_proxy)	
        
        self.pack_start(HIGSpacer(vbox), False, False)
	
    def parse_proxy(self, s):
	return (s + ":").split(":")[0:2]
        
    def create_proxy_row(self, table, level, name, default = ""):
	host, port = self.parse_proxy(default)
	try:
	    port = float(port)
	except ValueError:
	    port = 3128

	lbl = HIGEntryLabel(name + " " + _("proxy") + ":")
	lbl.set_justify(gtk.JUSTIFY_LEFT)
	host_entry = HIGTextEntry()
	host_entry.set_text(host)
	lbl.set_mnemonic_widget(host_entry)
	table.attach(lbl, 0, 1, level, level + 1, 0, 0)
	table.attach(host_entry, 1, 2, level, level + 1)
	
	lbl = HIGEntryLabel(_("Port") + ":")
	lbl.set_justify(gtk.JUSTIFY_LEFT)
	port_entry = gtk.SpinButton(gtk.Adjustment(port, 0, 65536, 1, 100), 1.0, 0)
	lbl.set_mnemonic_widget(port_entry)
	table.attach(lbl, 2, 3, level, level + 1, 0, 0)
	table.attach(port_entry, 3, 4, level, level + 1, 0, 0)
	return host_entry, port_entry
    
    def _update_use_proxy(self):
	self.proxy_table.set_sensitive(self.proxy_radio.get_active())
	if self.proxy_radio.get_active():
            proxies = {'http' : self.preferences.http_proxy,
                       'ftp'  : self.preferences.ftp_proxy}
            self.config.set_proxies(proxies)
	else:
            self.config.set_proxies(dict())
	    
    def _update_http_proxy(self, a=None, b=None):
	self.preferences.http_proxy = self.http_host.get_text() + ":" + self.http_port.get_text()
	
    def _update_ftp_proxy(self, a=None, b=None):
	self.preferences.ftp_proxy = self.ftp_host.get_text() + ":" + self.ftp_port.get_text()
    
    def save(self):
	self._update_ftp_proxy()
	self._update_http_proxy()
#.........这里部分代码省略.........
开发者ID:aregee,项目名称:network-scanner,代码行数:103,代码来源:ScriptManager.py


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