Beispiel #1
0
class ProxyEntryDialog(Dialog):
    def __init__(self, parent, controller):
        super(ProxyEntryDialog, self).__init__(None, parent, "New Proxy")
        self._protocol = None
        self._url = None
        self._controller = controller

    def body(self, parent, options):
        ttk.Label(parent, text="Protocol:", borderwidth=0,
                  anchor=tk.E).grid(padx=7, pady=6, row=0, sticky='nse')
        self._protocol = EntryCustom(parent, state=tk.NORMAL)
        self._protocol.grid(padx=(0, 7), pady=6, row=0, column=1, sticky='nsw')
        ttk.Label(parent, text="URL:", borderwidth=0,
                  anchor=tk.E).grid(padx=7, pady=6, row=1, sticky='nse')
        self._url = EntryCustom(parent, state=tk.NORMAL, width=50)
        self._url.grid(padx=(0, 7), pady=6, row=1, column=1, sticky='nsew')
        return self._protocol  # initial focus

    def validate(self):
        protocol = self._protocol.get().strip()
        if len(protocol) == 0 or protocol in self._controller._proxy_urls:
            self.initial_focus = self._protocol
            return False

        url = self._url.get().strip()
        if not CredentialsView._validate_url(url):
            self.initial_focus = self._url
            return False

        self.initial_focus = self._protocol
        return True

    def apply(self):
        self.result = (self._protocol.get().strip(), self._url.get().strip())
Beispiel #2
0
class PackageEntryDialog(Dialog):
    
    def __init__(self,parent,controller):
        super(PackageEntryDialog, self).__init__(None,parent,"New Package")
        self._package = None
        self._controller = controller
       
    def body(self, parent,options):
        ttk.Label(parent,
                  text="Package:",
                  borderwidth=0,
                  anchor=tk.E).grid(padx=7,pady=6,row=0,sticky='nse')
        self._package = EntryCustom(parent,state=tk.NORMAL)
        self._package.grid(padx=(0,7),pady=6,row=0, column=1,sticky='nsw')
        return self._package # initial focus
    
    def validate(self):
        package = self._package.get().strip()
        if len(package) == 0 or package in self._controller._packages:
            self.initial_focus = self._package
            return False
                
        self.initial_focus = self._package
        return True
    
    def apply(self):
        self.result = self._package.get().strip()