Beispiel #1
0
    def __init__(self, screen, tui):
        self.screen = screen
        self.tui = tui
        self.tui.alreadyRegistered = 0

        self.server = convert_url_from_puny(self.tui.serverURL)
        fixed_server_url = rhnreg.makeNiceServerUrl(self.server)

        #Save the config only if the url is different
        if fixed_server_url != self.server:
            self.server = fixed_server_url
            config.setServerURL(self.server)
            cfg.save()

        size = snack._snack.size()

        toplevel = snack.GridForm(screen, sstr(SATELLITE_URL_WINDOW), 1, 4)

        prompt_text = SATELLITE_URL_TEXT
        url_label = SATELLITE_URL_PROMPT
        ssl_label = SATELLITE_URL_PROMPT2

        label = snack.Textbox(size[0] - 10,
                              3,
                              sstr(prompt_text),
                              scroll=0,
                              wrap=1)

        toplevel.add(label, 0, 0, anchorLeft=1)

        # spacer
        label = snack.Label(sstr(""))
        toplevel.add(label, 0, 1)

        grid = snack.Grid(2, 3)

        label = snack.Label(sstr(url_label))
        grid.setField(label, 0, 0, padding=(0, 0, 1, 0), anchorRight=1)

        self.urlEntry = snack.Entry(40)
        self.urlEntry.set(self.server)
        grid.setField(self.urlEntry, 1, 0, anchorLeft=1)

        label = snack.Label(sstr(ssl_label))
        grid.setField(label, 0, 1, padding=(0, 0, 1, 0), anchorRight=1)

        self.sslEntry = snack.Entry(40)
        self.sslEntry.set(tui.sslCACert)
        grid.setField(self.sslEntry, 1, 1, anchorLeft=1)

        toplevel.add(grid, 0, 2)

        # BUTTON BAR
        self.bb = snack.ButtonBar(screen, [(sstr(NEXT), "next"),
                                           (sstr(BACK), "back"),
                                           (sstr(CANCEL), "cancel")])

        toplevel.add(self.bb, 0, 3, padding=(0, 1, 0, 0), growx=1)

        self.g = toplevel
Beispiel #2
0
    def __init__(self, screen, tui):
        self.screen = screen
        self.tui = tui
        self.tui.alreadyRegistered = 0

        self.server = self.tui.serverURL

        size = snack._snack.size()

        toplevel = snack.GridForm(screen, REGISTER_WINDOW.encode('utf-8'), 1,
                                  4)

        decoded_server = convert_url_from_pune(self.server)
        url = self.server
        if decoded_server != self.server:
            url += " (%s)" % decoded_server
        login_prompt = LOGIN_PROMPT % url
        login_label = LOGIN
        login_tip = LOGIN_TIP

        label = snack.Textbox(size[0] - 10,
                              3,
                              login_prompt.encode('utf-8'),
                              scroll=0,
                              wrap=1)

        toplevel.add(label, 0, 0, anchorLeft=1)

        grid = snack.Grid(2, 3)

        label = snack.Label(login_label.encode('utf-8'))
        grid.setField(label, 0, 0, padding=(0, 0, 1, 0), anchorRight=1)

        self.userNameEntry = snack.Entry(20)
        self.userNameEntry.set(tui.userName)
        grid.setField(self.userNameEntry, 1, 0, anchorLeft=1)

        label = snack.Label(PASSWORD.encode('utf-8'))
        grid.setField(label, 0, 1, padding=(0, 0, 1, 0), anchorRight=1)

        try:
            self.passwordEntry = snack.Entry(20, password=1)
        except TypeError:
            self.passwordEntry = snack.Entry(20, hidden=1)
        self.passwordEntry.set(tui.password)
        grid.setField(self.passwordEntry, 1, 1, anchorLeft=1)

        toplevel.add(grid, 0, 1)

        label = snack.TextboxReflowed(size[0] - 10, login_tip.encode('utf-8'))
        toplevel.add(label, 0, 2, anchorLeft=1)

        # BUTTON BAR
        self.bb = snack.ButtonBar(screen, [(NEXT.encode('utf-8'), "next"),
                                           (BACK.encode('utf-8'), "back"),
                                           (CANCEL.encode('utf-8'), "cancel")])

        toplevel.add(self.bb, 0, 3, padding=(0, 1, 0, 0), growx=1)

        self.g = toplevel
Beispiel #3
0
 def mostrarListado(self):
     opcion = ""
     while (opcion != "back"):
         self.contenido = self.leerArchivo()
         self.label = snack.Label(self.texto)
         self.botones = snack.ButtonBar(
             self.screen, ((gettext.gettext("Add"), "add"),
                           (gettext.gettext("Delete"), "delete"),
                           (gettext.gettext("Back"), "back")))
         self.lista = snack.Listbox(height=13,
                                    width=60,
                                    returnExit=1,
                                    showCursor=0,
                                    scroll=1)
         for registro in self.contenido:
             fecha = registro.split("\t")[1]
             recordView = registro.split("\t")[0] + "(" + fecha.strip(
                 ":created") + ")"
             self.lista.append(recordView, registro)
         self.grid = snack.GridForm(self.screen, self.titulo, 1, 3)
         self.grid.add(self.label, 0, 0, growx=0, growy=0, anchorLeft=1)
         self.grid.add(self.lista, 0, 1)
         self.grid.add(self.botones, 0, 2, growx=1, growy=0)
         respuesta = self.grid.runOnce()
         opcion = self.botones.buttonPressed(respuesta)
         if (opcion == "add"):
             cargaDeValores = Datos.Datos(self.archivo,
                                          gettext.gettext("New"),
                                          self.texto, self.screen)
             cargaDeValores.altas()
         elif (opcion == "delete"):
             self.guardarArchivo(self.lista.current())
    def runIt(self, mscreen):
        """
        Show and run the screen, save files if necesarry
        """
        g1 = snack.Grid(1, 1)
        g2 = snack.Grid(2, 6)
        g2.setField(snack.Label(_("Name")), 0, 0, anchorLeft=1)
        g2.setField(snack.Label(_("Device")), 0, 1, anchorLeft=1)
        g2.setField(snack.Label(_("ISP Phonenumber")), 0, 2, anchorLeft=1)
        g2.setField(snack.Label(_("ISP Login")), 0, 3, anchorLeft=1)
        g2.setField(snack.Label(_("ISP Password")), 0, 4, anchorLeft=1)
        g2.setField(snack.Label(_("MSN")), 0, 5, anchorLeft=1)
        g2.setField(self.name, 1, 0, (1, 0, 0, 0))
        g2.setField(self.hwdev, 1, 1, (1, 0, 0, 0))
        g2.setField(self.phoneno, 1, 2, (1, 0, 0, 0), anchorLeft=1)
        g2.setField(self.login, 1, 3, (1, 0, 0, 0))
        g2.setField(self.password, 1, 4, (1, 0, 0, 0))
        g2.setField(self.msn, 1, 5, (1, 0, 0, 0))
        bb = snack.ButtonBar(mscreen,
                             ((_("Ok"), "ok"), (_("Cancel"), "cancel")))
        tl = snack.GridForm(mscreen, _("ISDN Configuration"), 1, 3)
        tl.add(g1, 0, 0, (0, 0, 0, 1), anchorLeft=1)
        tl.add(g2, 0, 1, (0, 0, 0, 1))
        tl.add(bb, 0, 2, growx=1)
        self.setState(self.isdn)
        while 1:
            res = tl.run()
            if bb.buttonPressed(res) == "cancel":
                mscreen.popWindow()
                return False

            elif bb.buttonPressed(res) == "ok":
                mscreen.popWindow()
                self.processInfo()
                return True
Beispiel #5
0
def get_ftp_dest(answers):
    text = "Please enter the URL for your FTP directory and, optionally, a username and password"
    url_field = snack.Entry(50)
    user_field = snack.Entry(16)
    passwd_field = snack.Entry(16, password=1)
    url_text = snack.Textbox(11, 1, "URL:")
    user_text = snack.Textbox(11, 1, "Username:"******"Password:"******"Specify Path", 'getftpdest', 1, 3)
    bb = snack.ButtonBar(tui.screen, ['Ok', 'Back'])
    t = snack.TextboxReflowed(50, text)

    entry_grid = snack.Grid(2, 3)
    entry_grid.setField(url_text, 0, 0)
    entry_grid.setField(url_field, 1, 0)
    entry_grid.setField(user_text, 0, 1)
    entry_grid.setField(user_field, 1, 1, anchorLeft=1)
    entry_grid.setField(passwd_text, 0, 2)
    entry_grid.setField(passwd_field, 1, 2, anchorLeft=1)

    gf.add(t, 0, 0, padding=(0, 0, 0, 1))
    gf.add(entry_grid, 0, 1, padding=(0, 0, 0, 1))
    gf.add(bb, 0, 2, growx=1)

    button = bb.buttonPressed(gf.runOnce())

    if button == 'back': return uicontroller.LEFT_BACKWARDS

    url = url_field.value()
    if not url.startswith('ftp://'):
        url = 'ftp://' + url
    if user_field.value() != '':
        quoted_user = urllib.quote(user_field.value(), safe='')
        if passwd_field.value() != '':
            quoted_passwd = urllib.quote(passwd_field.value(), safe='')
            answers['dest-address'] = url.replace(
                '//', '//%s:%s@' % (quoted_user, quoted_passwd), 1)
        else:
            answers['dest-address'] = url.replace('//', '//%s@' % quoted_user,
                                                  1)
    else:
        answers['dest-address'] = url

    return uicontroller.RIGHT_FORWARDS
Beispiel #6
0
        def __init__(self, screen, jobthread):
            snack.GridForm.__init__(self, screen, "hello", 1, 4)
            self.interval = 1000
            self.bb = snack.ButtonBar(screen, (
                (
                    "OK",
                    "ok",
                ),
                (
                    "Cancel",
                    "cancel",
                ),
            ))
            self.add(self.bb, 0, 2)
            self.jobthread = jobthread

            #self.jobthread.start()

            #print "started 0"
            self.screen.suspend()
            print "started 1"
            #time.sleep(3)
            select.select([1], [], [], 1000000)
            print "started 2"
            self.screen.resume()
            #print "started 3"

            self.setTimer(self.interval)
Beispiel #7
0
def _ButtonsWindow(screen, header, text, buttons):
    form = _SnackWindow(screen, header, text, 1)

    btns = snack.ButtonBar(screen, buttons)
    form.add(btns, 0, 1, growx=1)

    return btns.buttonPressed(form.runOnce())
Beispiel #8
0
 def VoteText(self, header, text, buttons=None, watches=None, reflow=False):
     if not buttons:
         buttons = ['Ok']
     if watches is None:
         watches = {}
     with self:
         btnsbar = snack.ButtonBar(self.__screen, buttons)
         form = snack.GridForm(self.__screen, header, 1, 2)
         if text and reflow:
             textbox = snack.TextboxReflowed(width=TEXT_WIDTH,
                                             text=text,
                                             flexDown=FLEX_DOWN,
                                             flexUp=FLEX_UP)
             form.add(textbox, 0, 0, padding=(0, 0, 0, 1))
         elif text:
             width, height, scroll = self.__GetWidgetBounds(5, text=text)
             textbox = snack.Textbox(width,
                                     height,
                                     text=text,
                                     scroll=scroll,
                                     wrap=True)
             form.add(textbox, 0, 0, padding=(0, 0, 0, 1))
         form.add(btnsbar, 0, 1, padding=(0, 0, 0, 0))
         for watch in watches:
             form.form.watchFile(watch, 1)
         ret = form.runOnce()
         if btnsbar.buttonPressed(ret):
             return btnsbar.buttonPressed(ret)
         elif ret in watches:
             return watches[ret]
         else:
             return None
Beispiel #9
0
    def __init__(self, screen, tui):
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()
        toplevel = snack.GridForm(self.screen,
                                  WHY_REGISTER_WINDOW.encode('utf-8'), 1, 2)


        why_register_text = WHY_REGISTER_TEXT + "\n\n" + \
                            WHY_REGISTER_SEC  + "\n" + \
                            WHY_REGISTER_SEC_TXT + "\n\n" + \
                            WHY_REGISTER_DLD + "\n" + \
                            WHY_REGISTER_DLD_TXT + "\n\n" + \
                            WHY_REGISTER_SUPP + "\n" + \
                            WHY_REGISTER_SUPP_TXT + "\n\n" + \
                            WHY_REGISTER_COMP + "\n" + \
                            WHY_REGISTER_COMP_TXT + "\n\n" + \
                            WHY_REGISTER_TIP

        tb = snack.Textbox(size[0] - 10, size[1] - 14,
                           why_register_text.encode('utf-8'), 1, 1)

        toplevel.add(tb, 0, 0, padding=(0, 0, 0, 1))

        self.bb = snack.ButtonBar(self.screen,
                                  [(BACK_REGISTER.encode('utf-8'), "back")])
        toplevel.add(self.bb, 0, 1, growx=1)

        self.g = toplevel
    def runIt(self, screen):
        g1 = snack.Grid(1, 1)
        g2 = snack.Grid(2, 5)
        g2.setField(snack.Label(_("Hostname")), 0, 0, anchorLeft=1)
        g2.setField(snack.Label(_("Primary DNS")), 0, 1, anchorLeft=1)
        g2.setField(snack.Label(_("Secondary DNS")), 0, 2, anchorLeft=1)
        g2.setField(snack.Label(_("Tertiary DNS")), 0, 3, anchorLeft=1)
        g2.setField(snack.Label(_("DNS search path")), 0, 4, anchorLeft=1)
        #g2.setField(snack.Label (_("Default gateway IP")), 0, 5, anchorLeft = 1)
        g2.setField(self.hostname, 1, 0, (1, 0, 0, 0))
        g2.setField(self.primaryDNS, 1, 1, (1, 0, 0, 0))
        g2.setField(self.secondaryDNS, 1, 2, (1, 0, 0, 0))
        g2.setField(self.tertiaryDNS, 1, 3, (1, 0, 0, 0))
        g2.setField(self.searchList, 1, 4, (1, 0, 0, 0))
        #g2.setField(gwy, 1, 5, (1, 0, 0, 0))
        #dynip.setCallback(useDynamicCheckBox)
        bb = snack.ButtonBar(screen,
                             ((_("Ok"), "ok"), (_("Cancel"), "cancel")))
        self.setState(self.prof)
        tl = snack.GridForm(screen, _("DNS configuration"), 1, 3)
        tl.add(g1, 0, 0, (0, 0, 0, 1), anchorLeft=1)
        tl.add(g2, 0, 1, (0, 0, 0, 1))
        tl.add(bb, 0, 2, growx=1)
        # if
        res = tl.run()
        if bb.buttonPressed(res) == "cancel":
            print "cancel"
            screen.popWindow()
            return False

        elif bb.buttonPressed(res) == "ok":
            screen.popWindow()
            self.processInfo()
            return True
Beispiel #11
0
    def __init__(self, screen, tui):

        if not rhnreg.registered() or tui.test:
            raise WindowSkipException()

        self.screen = screen
        self.tui = tui
        size = snack._snack.size()

        systemIdXml = rpclib.xmlrpclib.loads(up2dateAuth.getSystemId())
        oldUsername = systemIdXml[0][0]['username']
        oldsystemId = systemIdXml[0][0]['system_id']

        toplevel = snack.GridForm(self.screen,
                                  SYSTEM_ALREADY_SETUP.encode('utf-8'), 1, 2)
        self.bb = snack.ButtonBar(self.screen,
                                  [(YES_CONT.encode('utf-8'), "next"),
                                   (NO_CANCEL.encode('utf-8'), "exit")])
        toplevel.add(self.bb, 0, 1, growx=1)

        tb = snack.Textbox(
            size[0] - 30, size[1] - 20,
            (SYSTEM_ALREADY_REGISTERED + "\n\n" + _("Spacewalk Location:") +
             " " + convert_url_from_pune(self.tui.serverURL) + "\n" +
             _("Login:"******" " + oldUsername + "\n" + _("System ID:") + " " +
             oldsystemId + "\n\n" + SYSTEM_ALREADY_REGISTERED_CONT +
             "\n").encode('utf-8'), 1, 1)
        toplevel.add(tb, 0, 0, padding=(0, 0, 0, 1))

        self.g = toplevel
Beispiel #12
0
    def __init__(self,screen,Entries,title,width=20,columns=1,ok_text='Ok',cancel_text='Cancel',add_entry_text='Add Entry',**kargs):

        if kargs.get('Buttons',None):
                  self._Buttons=kargs['Buttons']
        else:
            self._Buttons = snack.ButtonBar(screen, ((ok_text,1),(add_entry_text,3),(cancel_text,0)))

        super(DynamicEntryForm,self).__init__(Entries=Entries,screen=screen,title=title,columns=columns,width=width,Buttons=self._Buttons)
Beispiel #13
0
    def __init__(self,screen,title,msg,height=7,width=40,scroll=0,**kargs):

                if kargs.get('Buttons',None):
                        self._Buttons=kargs['Buttons']
                else:
                        self._Buttons=snack.ButtonBar(screen,(('Yes',1),('No',0)))

                super(YesNoForm,self).__init__(screen,title,msg,scroll=scroll,height=height,width=width,Buttons=self._Buttons)
Beispiel #14
0
    def __init__(self, screen, tui):
        self.name = "PackagesWindow"
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()
        toplevel = snack.GridForm(screen, PACKAGES_WINDOW.encode('utf-8'), 1,
                                  5)
        self.g = toplevel

        text = snack.TextboxReflowed(size[0] - 10,
                                     PACKAGES_WINDOW_DESC1.encode('utf-8'))

        toplevel.add(text, 0, 0, anchorLeft=1)

        self.packagesButton = snack.Checkbox(
            PACKAGES_WINDOW_DESC2.encode('utf-8'), 1)
        toplevel.add(self.packagesButton,
                     0,
                     1,
                     padding=(0, 1, 0, 1),
                     anchorLeft=1)

        label = snack.Label(PACKAGES_WINDOW_UNCHECK.encode('utf-8'))
        toplevel.add(label, 0, 2, anchorLeft=1)

        #self.packageList = snack.Listbox(size[1]-18, 1, width = size[0]-10)
        self.packageList = snack.CheckboxTree(size[1] - 18, 1)
        toplevel.add(self.packageList, 0, 3)

        # do we need to read the packages from disk?
        if tui.packageList == []:
            self.pwin = snack.GridForm(screen,
                                       PACKAGES_WINDOW_PKGLIST.encode('utf-8'),
                                       1, 1)

            self.scale = snack.Scale(40, 100)
            self.pwin.add(self.scale, 0, 0)
            self.pwin.draw()
            self.screen.refresh()
            getArch = 0
            if rhnreg.cfg['supportsExtendedPackageProfile']:
                getArch = 1
            tui.packageList = pkgUtils.getInstalledPackageList(getArch=getArch)
            self.screen.popWindow()

        for package in tui.packageList:
            self.packageList.append(
                "%s-%s-%s" %
                (package['name'], package['version'], package['release']),
                item=package['name'],
                selected=1)

        # BUTTON BAR
        self.bb = snack.ButtonBar(screen, [(NEXT.encode('utf-8'), "next"),
                                           (BACK.encode('utf-8'), "back"),
                                           (CANCEL.encode('utf-8'), "cancel")])
        toplevel.add(self.bb, 0, 4, padding=(0, 1, 0, 0), growx=1)
Beispiel #15
0
 def __init__(self,Entries,screen,title,columns=1,width=30,**kargs):
         '''
         Initialize the class basiclly it is just
         '''
         if kargs.get('Buttons',None):
               self.Buttons=kargs['Buttons']
         else:
             self.Buttons = snack.ButtonBar(screen, (('Back',-1),('Cancel',0),('Next',1)))
         super(WizardEntryForm,self).__init__(Entries,screen,title,columns,width,Buttons=self.Buttons)
Beispiel #16
0
 def __init__(self,options,screen,title,height=5,width=20,ok_button=('Ok',1),cancel_button=('Cancel',0),**kargs):
     '''
     Initialize the menu and the BaseForm
     '''
     self.title=title
     self.SnackList=snack.Listbox(height=height,width=width)
     n=1
     for p in options:
          self.SnackList.append( "%d) %s"%(n,p[0]), p[1] )
          n+=1
     if kargs.get('Buttons',None):
         self.Buttons=kargs['Buttons']
     else:
         self.Buttons = snack.ButtonBar(screen, (ok_button,cancel_button))
     super(MenuForm,self).__init__(screen=screen,name=title,Widgets=[self.SnackList,self.Buttons],**kargs)
Beispiel #17
0
    def runIt(self, screen):
        """
        Show and run the screen, save files if necesarry
        """
        self.screen = screen
        g1 = snack.Grid(1, 1)
        g2 = snack.Grid(2, 11)
        g2.setField(snack.Label(_("Name")), 0, 0, anchorLeft=1)
        g2.setField(snack.Label(_("Device")), 0, 1, anchorLeft=1)
        g2.setField(snack.Label(_("Use DHCP")), 0, 2, anchorLeft=1)
        g2.setField(snack.Label(_("Static IP")), 0, 3, anchorLeft=1)
        g2.setField(snack.Label(_("Netmask")), 0, 4, anchorLeft=1)
        g2.setField(snack.Label(_("Default gateway IP")), 0, 5, anchorLeft=1)
        g2.setField(snack.Label(_("Read Device Bus ID")), 0, 6, anchorLeft=1)
        g2.setField(snack.Label(_("Data Device Bus ID")), 0, 7, anchorLeft=1)
        g2.setField(snack.Label(_("Write Device Bus ID")), 0, 8, anchorLeft=1)
        g2.setField(snack.Label(_("Options")), 0, 9, anchorLeft=1)
        g2.setField(snack.Label(_("MAC Address")), 0, 10, anchorLeft=1)
        g2.setField(self.name, 1, 0, (1, 0, 0, 0))
        g2.setField(self.hwdev, 1, 1, (1, 0, 0, 0))
        g2.setField(self.dynip, 1, 2, (1, 0, 0, 0), anchorLeft=1)
        g2.setField(self.statip, 1, 3, (1, 0, 0, 0))
        g2.setField(self.netmask, 1, 4, (1, 0, 0, 0))
        g2.setField(self.gwy, 1, 5, (1, 0, 0, 0))
        g2.setField(self.ioport, 1, 6, (1, 0, 0, 0))
        g2.setField(self.ioport1, 1, 7, (1, 0, 0, 0))
        g2.setField(self.ioport2, 1, 8, (1, 0, 0, 0))
        g2.setField(self.options, 1, 9, (1, 0, 0, 0))
        g2.setField(self.macaddr, 1, 10, (1, 0, 0, 0))

        self.dynip.setCallback(self.useDynamicCheckBox)
        bb = snack.ButtonBar(self.screen,
                             ((_("Ok"), "ok"), (_("Cancel"), "cancel")))
        self.setState(self.dev)
        tl = snack.GridForm(screen, _("Devernet Configuration"), 1, 3)
        tl.add(g1, 0, 0, (0, 0, 0, 1), anchorLeft=1)
        tl.add(g2, 0, 1, (0, 0, 0, 1))
        tl.add(bb, 0, 2, growx=1)
        self.useDynamicCheckBox()
        while 1:
            res = tl.run()
            if bb.buttonPressed(res) == "cancel":
                screen.popWindow()
                return False
            elif bb.buttonPressed(res) == "ok":
                screen.popWindow()
                self.processInfo()
                return True
Beispiel #18
0
def _make_grid_input_path(insScreen, title, label, strText):

    l = snack.Label(label)
    l1 = snack.Label(" ")
    e = snack.Entry(50, strText)
    b = snack.ButtonBar(insScreen,
                        (("   OK   ", "ok"), (" Cancel ", "cancel")))

    g = snack.GridForm(insScreen, title, 3, 6)
    g.add(l, 0, 1)
    g.add(l1, 0, 2)
    g.add(e, 0, 3)
    g.add(l1, 0, 4)
    g.add(b, 0, 5)

    return e, b, g
Beispiel #19
0
def _make_grid_search(insScreen, search_id):

    l = snack.Label("Search Value:")
    l1 = snack.Label(" ")
    e = snack.Entry(30, search_id)
    b = snack.ButtonBar(insScreen,
                        (("Search", "search"), ("Search off", "cancel")))

    g = snack.GridForm(insScreen, "Enter Search String", 3, 6)
    g.add(l, 0, 1)
    g.add(l1, 0, 2)
    g.add(e, 0, 3)
    g.add(l1, 0, 4)
    g.add(b, 0, 5)

    return e, b, g
Beispiel #20
0
    def __init__(self, screen, tui):
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()

        toplevel = snack.GridForm(screen, sstr(FINISH_WINDOW), 1, 2)

        text = snack.TextboxReflowed(size[0] - 11,
                                     sstr(FINISH_WINDOW_TEXT_TUI))
        toplevel.add(text, 0, 0)

        # BUTTON BAR
        self.bb = snack.ButtonBar(screen, [(sstr(_("Finish")), "next")])
        toplevel.add(self.bb, 0, 1, padding=(0, 1, 0, 0), growx=1)

        self.g = toplevel
Beispiel #21
0
    def edit_repos(self):
        """
List box

Add Edit Delete Cancel
        """
        screen = self.screen

        while True:
            listbox = snack.CListbox(screen.height - 10,
                                     2, (20, 40),
                                     scroll=1,
                                     returnExit=1,
                                     col_labels=("Name", "Path"),
                                     adjust_width=1)
            for name, path in pull_repos.items():
                listbox.append((name, path), name)

            grid = snack.GridForm(screen, "Repos Setup", 1, 2)
            grid.add(listbox, 0, 0, growx=1, growy=1)

            buttons = snack.ButtonBar(
                screen,
                self._NormalizeButtons([("Add", "add"), ("Edit", "edit"),
                                        ("Remove", "remove"), self.MB_CANCEL]))
            grid.add(buttons, 0, 1, growx=1)

            result = grid.runOnce()

            button = buttons.buttonPressed(result)
            if not pull_repos:
                repo = None
            else:
                repo = listbox.current()

            if button == "cancel":
                break

            elif repo and button in (None, "edit"):
                self.edit_repo(repo)

            elif repo is None or button == "add":
                self.add_repo()

            elif repo and button == "remove":
                self.remove_repo(repo)
Beispiel #22
0
 def __init__(self,Entries,screen,title,columns=1,width=30,ok_button=('Ok',1),cancel_button=('Cancel',0),**kargs):
     '''
     Initialize the form
     '''
     self.width=width
     self.MsgBox=snack.TextboxReflowed(width,' ')
     self.Entries=Entries
     self.EntriesLen=len(Entries)
     self.columns=columns
     self.EntriesGrid=snack.Grid(columns *2,self.EntriesLen )
     self.Members={} # {<lable-text>:<entry-text-obj>,...}
     if kargs.get('Buttons',None):
        self.Buttons=kargs['Buttons']
     else:
        self.Buttons = snack.ButtonBar(screen, (ok_button,cancel_button))
     EntriesGrid=self.getEntriesGrid()
     super(EntryForm,self).__init__(screen,title,Widgets=[self.MsgBox,EntriesGrid,self.Buttons])
Beispiel #23
0
    def __init__(self, screen, tui):
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()

        toplevel = snack.GridForm(screen, sstr(SEND_WINDOW), 1, 2)

        text = snack.TextboxReflowed(size[0] - 15, sstr(SEND_WINDOW_DESC))
        toplevel.add(text, 0, 0)

        # BUTTON BAR
        self.bb = snack.ButtonBar(screen, [(sstr(NEXT), "next"),
                                           (sstr(BACK), "back"),
                                           (sstr(CANCEL), "cancel")])
        toplevel.add(self.bb, 0, 1, padding=(0, 1, 0, 0), growx=1)

        self.g = toplevel
Beispiel #24
0
    def __init__(self, screen, tui):
        self.name = "FinishWindow"
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()

        toplevel = snack.GridForm(screen, FINISH_WINDOW.encode('utf-8'), 1, 2)

        text = snack.TextboxReflowed(size[0] - 11,
                                     FINISH_WINDOW_TEXT_TUI.encode('utf-8'))
        toplevel.add(text, 0, 0)

        # BUTTON BAR
        self.bb = snack.ButtonBar(screen,
                                  [(_("Finish").encode('utf-8'), "next")])
        toplevel.add(self.bb, 0, 1, padding=(0, 1, 0, 0), growx=1)

        self.g = toplevel
Beispiel #25
0
 def selectDevice(self, mscreen):
     #li = self.Listbox(5, returnExit=1)
     g = snack.GridForm(mscreen, _("Select A Device"), 1, 3)
     bb = snack.ButtonBar(mscreen,
                          ((_("Save"), "save"), (_("Cancel"), "cancel")))
     g.add(self.li, 0, 1)
     g.add(bb, 0, 2, growx=1)
     res = g.run()
     mscreen.popWindow()
     if bb.buttonPressed(res) == "save":
         ret = -1
     elif bb.buttonPressed(res) == "cancel":
         ret = None
     else:
         ret = self.li.current()
         if not ret:
             ret = self.newDevice(mscreen)
     return ret
Beispiel #26
0
def error_dialog(screen, title, msg):
	"Print error dialog"
	
	width = len(msg)
	
	if (newt):
		width = width_fix(screen, width)
		
		buttonbar = snack.ButtonBar(screen, ['Ok'])
		textbox = snack.TextboxReflowed(width, msg)
		
		grid = snack.GridForm(screen, title, 1, 2)
		grid.add(textbox, 0, 0, padding = (0, 0, 0, 1))
		grid.add(buttonbar, 0, 1, growx = 1)
		grid.runOnce()
	elif (dialog):
		call_dlg(dlgcmd, '--title', title, '--msgbox', msg, '6', str(width + width_extra))
	else:
		sys.stdout.write("\n%s: %s\n" % (title, msg))
Beispiel #27
0
    def __init__(self, screen, tui):
        self.screen = screen
        self.tui = tui
        self.name = "SendWindow"
        size = snack._snack.size()

        toplevel = snack.GridForm(screen, SEND_WINDOW.encode('utf-8'), 1, 2)

        text = snack.TextboxReflowed(size[0] - 15,
                                     SEND_WINDOW_DESC.encode('utf-8'))
        toplevel.add(text, 0, 0)

        # BUTTON BAR
        self.bb = snack.ButtonBar(screen, [(NEXT.encode('utf-8'), "next"),
                                           (BACK.encode('utf-8'), "back"),
                                           (CANCEL.encode('utf-8'), "cancel")])
        toplevel.add(self.bb, 0, 1, padding=(0, 1, 0, 0), growx=1)

        self.g = toplevel
Beispiel #28
0
    def __init__(self, screen, tui):
        self.screen = screen
        self.tui = tui
        size = snack._snack.size()
        toplevel = snack.GridForm(self.screen, START_REGISTER_WINDOW.encode('utf-8'),
                                  1, 2)

        start_register_text = START_REGISTER_TEXT.encode('utf-8')

        tb = snack.Textbox(size[0]-10, size[1]-14, start_register_text, 1, 1)
        toplevel.add(tb, 0, 0, padding = (0, 0, 0, 1))

        self.bb = snack.ButtonBar(self.screen,
                                  [(WHY_REGISTER.encode('utf-8'), "why_register"),
                                   (NEXT.encode('utf-8'), "next"),
                                   (CANCEL.encode('utf-8'), "cancel")])
        toplevel.add(self.bb, 0, 1, growx = 1)

        self.g = toplevel
Beispiel #29
0
    def runIt(self, screen):
        """
        Show and run the screen, save files if necesarry
        """
        self.screen = screen
        g1 = snack.Grid(1, 1)
        g2 = snack.Grid(2, 8)
        g2.setField(snack.Label (_("Name")), 0, 0, anchorLeft = 1)
        g2.setField(snack.Label (_("Device")), 0, 1, anchorLeft = 1)
        g2.setField(snack.Label (_("Use DHCP")), 0, 2, anchorLeft = 1)
        g2.setField(snack.Label (_("Static IP")), 0, 3, anchorLeft = 1)
        g2.setField(snack.Label (_("Netmask")), 0, 4, anchorLeft = 1)
        g2.setField(snack.Label (_("Default gateway IP")), 0, 5, anchorLeft = 1)
        g2.setField(snack.Label (_("Primary DNS Server")), 0, 6, anchorLeft = 1)
        g2.setField(snack.Label (_("Secondary DNS Server")), 0, 7, anchorLeft = 1)
        g2.setField(self.name, 1, 0, (1, 0, 0, 0))
        g2.setField(self.hwdev, 1, 1, (1, 0, 0, 0))
        g2.setField(self.dynip, 1, 2, (1, 0, 0, 0), anchorLeft = 1)
        g2.setField(self.statip, 1, 3, (1, 0, 0, 0))
        g2.setField(self.netmask, 1, 4, (1, 0, 0, 0))
        g2.setField(self.gwy, 1, 5, (1, 0, 0, 0))
        g2.setField(self.dnsserver1, 1, 6, (1, 0, 0, 0))
        g2.setField(self.dnsserver2, 1, 7, (1, 0, 0, 0))
        self.dynip.setCallback(self.useDynamicCheckBox)
        bb = snack.ButtonBar(self.screen, ((_("Ok"), "ok"),
                                           (_("Cancel"), "cancel")))
        self.setState(self.dev)
        tl = snack.GridForm(screen, _("Network Configuration"), 1, 3)
        tl.add(g1, 0, 0, (0, 0, 0, 1), anchorLeft = 1)
        tl.add(g2, 0, 1, (0, 0, 0, 1))
        tl.add(bb, 0, 2, growx = 1)
        self.useDynamicCheckBox()
        while 1:
            res = tl.run()
            if bb.buttonPressed(res) == "cancel":
                screen.popWindow()
                return False

            elif bb.buttonPressed(res) == "ok":
                screen.popWindow()
                self.processInfo()
                return True
Beispiel #30
0
    def __call__(self):
        global backup_path
        clean_list = get_rpm_clean_list()
        if not clean_list:
            self.InfoBox("No files need cleaning.")
            return

        screen = self.screen
        chktree = snack.CheckboxTree(height=screen.height - 10, scroll=1)
        for rpm, sel in clean_list:
            chktree.append(rpm, selected=sel)

        grid = snack.GridForm(screen, "Clean Rpm Old Files", 1, 2)
        grid.add(chktree, 0, 0, growx=1, growy=1)

        buttons = snack.ButtonBar(
            screen, self._NormalizeButtons(["Clean", self.MB_CANCEL]))
        grid.add(buttons, 0, 1, growx=1)

        while True:
            result = grid.run()

            if buttons.buttonPressed(result) != "clean":
                screen.popWindow()
                return

            selection = chktree.getSelection()

            if not selection:
                self.WarningBox("No files selected. Please select some.")
                continue

            result, backup_path = check_backup_path(backup_path, self)
            if not result:
                continue

            break

        screen.popWindow()

        self.do_backup(selection)