當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。