def infosrecap(self): while True: # These lines create the form and populate it with widgets. # A fairly complex screen in only 8 or so lines of code - a line for each control. npyscreen.setTheme(npyscreen.Themes.DefaultTheme) form = npyscreen.Form(name="Création d'un utilisateur Linux", ) form.add(npyscreen.TitleFixedText, name="*---------------------------------*", value="") form.add(npyscreen.TitleFixedText, name="| Récapitulatif des données |", value="") form.add(npyscreen.TitleFixedText, name="*---------------------------------*", value="") form.add(npyscreen.TitleFixedText, name="| Username :"******"| Password :"******"| Mail :", value=self.infos[2]) form.add(npyscreen.TitleFixedText, name="| usergroup :", value=self.infos[3]) form.add(npyscreen.TitleFixedText, name="| database :", value=self.infos[4]) form.add(npyscreen.TitleFixedText, name="| domaine :", value=self.infos[5]) form.add(npyscreen.TitleFixedText, name="*----------------------------------*", value="") check = form.add(npyscreen.TitleText, name="Confirm Y/N :") # Interact with User form.edit() if check.value == 'Y' or check.value == 'y': return True elif check.value == 'N' or check.value == 'n': return False
def main(self): while True: os.system("clear") self.infos.clear() # These lines create the form and populate it with widgets. # A fairly complex screen in only 8 or so lines of code - a line for each control. npyscreen.setTheme(npyscreen.Themes.DefaultTheme) form = npyscreen.Form(name="Création d'un utilisateur Linux", ) username = form.add(npyscreen.TitleText, name="username:"******"usergroup:") usermail = form.add(npyscreen.TitleText, name="mail:") password = form.add(npyscreen.TitlePassword, name="password:"******"dbname:") domain = form.add(npyscreen.TitleText, name="domain:") # Interact with User form.edit() self.infos.append(username.value) self.infos.append(password.value) self.infos.append(usermail.value) self.infos.append(usergroup.value) self.infos.append(dbname.value) self.infos.append(domain.value) if self.checkuser(): check = self.infosrecap() if check: return True
def main(self): """Main""" main_server_list = [] server = namedtuple("Server", ["country", "resp_time", "last_sync", "url"]) header_cols = ({ "country": txt.I_COUNTRY, "resp_time": txt.I_RESPONSE, "last_sync": txt.I_LAST_SYNC, "url": txt.I_URL }) main_server_list.append(header_cols) main_server_list.extend(self.server_list) servers = consoleFn.list_to_tuple(main_server_list, server) server_rows = consoleFn.rows_from_tuple(servers) header_row = ("{:<5}".format(txt.I_USE) + (server_rows[0].replace("|", " ").strip())) del server_rows[0] # setup form mainform = npyscreen.Form(name=self.title) mainform.add(npyscreen.TitleFixedText, name=txt.I_LIST_TITLE) mainform.add(npyscreen.TitleFixedText, name=header_row) selected_servers = mainform.add(npyscreen.MultiSelect, max_height=0, name=txt.I_LIST_TITLE, value=[], values=server_rows, scroll_exit=True) mainform.edit() # activate form self.done(selected_servers.get_selected_objects()) # done
def main(self): self.F = npyscreen.Form(name="Welcome to Npyscreen") self.t = self.F.add(npyscreen.TitleText, name="Text:") while 1: self.update_values() curses.flash() curses.napms(100)
def main(self): # These lines create the form and populate it with widgets. # A fairly complex screen in only 8 or so lines of code - a line for each control. F = npyscreen.Form(name="Baixar Filme/Série") t = F.add( npyscreen.TitleText, name="URL:", ) global name name = t.value fn = F.add( npyscreen.TitleFilename, name="Nome:", ) # fn2 = F.add(npyscreen.TitleFilenameCombo, name="Filename2:") ms = F.add(npyscreen.TitleSelectOne, max_height=4, value=[ 1, ], name="Categorias", values=["Option1", "Option2", "Option3"], scroll_exit=True) ms2 = F.add(npyscreen.TitleSelectOne, max_height=4, value=[ 1, ], name="Tipo", values=["Filme", "Série"], scroll_exit=True) # This lets the user play with the Form. F.edit()
def pwd_reset(self): reset_form = npyscreen.Form(name="Reset Password", lines=0, columns=0, minimum_lines=24, minimum_columns=80) user_list = [] check_user = "******" cursor.execute(check_user) exist = cursor.fetchall() for line in range(0, len(exist)): user_list.append(exist[line][0]) select = reset_form.add(npyscreen.TitleSelectOne, max_height=4, name="Utente:", values=user_list, scroll_exit=True) password = reset_form.add(npyscreen.TitlePassword, name="Password:"******"Conferma:") pwd = PBKDF2PasswordHasher() reset_form.edit() if password.get_value() == password_confirm.get_value( ) and password.get_value() != '': sql_ctx = "UPDATE aron.auth_user SET password=\"%s\" WHERE username=\"%s\";" % \ (str(pwd.encode(password.get_value(), str(uuid.uuid4()), 12)), str(select.get_selected_objects())[2:-2]) cursor.execute(sql_ctx) db.commit() npyscreen.notify_confirm( "La password per l'utente %s e' stata cambiata." % str(select.get_selected_objects())[1:-1]) else: npyscreen.notify_confirm( "La password NON sono uguale. Controllare di nuovo")
def main(self): F = npyscreen.Form(name = "Welcome to Npyscreen",) t = F.add(npyscreen.BoxBasic, name = "Basic Box:", max_width=30, relx=2, max_height=3) t.footer = "This is a footer" t1 = F.add(npyscreen.BoxBasic, name = "Basic Box:", rely=2, relx=32, max_width=30, max_height=3) t2 = F.add(npyscreen.BoxTitle, name="Box Title:", max_height=6) t3 = F.add(npyscreen.BoxTitle, name="Box Title2:", max_height=6, scroll_exit = True, contained_widget_arguments={ 'color': "WARNING", 'widgets_inherit_color': True,} ) t2.entry_widget.scroll_exit = True t2.values = ["Hello", "This is a Test", "This is another test", "And here is another line", "And here is another line, which is really very long. abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", "And one more."] t3.values = t2.values F.edit()
def configPage(self): formConfig = npyscreen.Form(name="Virtual Screening TUI") seperator1 = formConfig.add(npyscreen.FixedText, value="---------Config-----------") if self.configMethod == 1: textSizeX = formConfig.add(npyscreen.TitleText, name="Size X:") textSizeY = formConfig.add(npyscreen.TitleText, name="Size Y:") textSizeZ = formConfig.add(npyscreen.TitleText, name="Size Z:") textCenterX = formConfig.add(npyscreen.TitleText, name="Center X:") textCenterY = formConfig.add(npyscreen.TitleText, name="Center Y:") textCenterZ = formConfig.add(npyscreen.TitleText, name="Center Z:") textExhaust = formConfig.add(npyscreen.TitleText, name="Exhaustiveness:") formConfig.edit() self.sizeX = textSizeX.value self.sizeY = textSizeY.value self.sizeZ = textSizeZ.value self.centerX = textCenterX.value self.centerY = textCenterY.value self.centerZ = textCenterZ.value self.exhaustiveness = textExhaust.value elif self.configMethod == 0: selectConfigFile = formConfig.add(npyscreen.TitleFilenameCombo, name="Config File") formConfig.edit() self.configFile = selectConfigFile.value
def make_form(self): # These lines create the form and populate it with widgets. # A fairly complex screen in only 8 or so lines of code - a line for each control. F = npyscreen.Form(name="Welcome to Npyscreen", ) t = F.add( npyscreen.TitleText, name="Text:", ) fn = F.add(npyscreen.TitleFilename, name="Filename:") fn2 = F.add(npyscreen.TitleFilenameCombo, name="Filename2:") dt = F.add(npyscreen.TitleDateCombo, name="Date:") s = F.add(npyscreen.TitleSlider, out_of=12, name="Slider") ml = F.add( npyscreen.MultiLineEdit, value= """try typing here!\nMutiline text, press ^R to reformat.\n""", max_height=5, rely=9) ms = F.add(npyscreen.TitleSelectOne, max_height=4, value=[ 1, ], name="Pick One", values=["Option1", "Option2", "Option3"], scroll_exit=True) ms2 = F.add(npyscreen.TitleMultiSelect, max_height=-2, value=[ 1, ], name="Pick Several", values=["Option1", "Option2", "Option3"], scroll_exit=True) return F
def searchButton(*args): licence_data_search = Search.Search_Driver_Licence(self.serNo.value) results = list() try: curs.execute(licence_data_search) rows = curs.fetchall() if len(rows) > 0: results.append("name, licence number, address, birthday, driving class, driving condition, expiring date") for row in rows: row = str(row) row = row.strip(" ") results.append(row) else: results = list() results.append("No results found") F = np.Form(name = "Query:") F.add(np.TitlePager,name = "Results:", values = results) F.edit() except cx_Oracle.DatabaseError as exc: self.parentApp.switchForm("ERROR")
def main(self): F = npyscreen.Form(name="Testing Tree class", ) #wgtree = F.add(npyscreen.MLTree) wgtree = F.add(TestTree) treedata = npyscreen.NPSTreeData(content='Root', selectable=True, ignoreRoot=False) c1 = treedata.newChild(content='Child 1', selectable=True, selected=True) c2 = treedata.newChild(content='Child 2', selectable=True) g1 = c1.newChild(content='Grand-child 1', selectable=True) g2 = c1.newChild(content='Grand-child 2', selectable=True) g3 = c1.newChild(content='Grand-child 3') gg1 = g1.newChild(content='Great Grand-child 1', selectable=True) gg2 = g1.newChild(content='Great Grand-child 2', selectable=True) gg3 = g1.newChild(content='Great Grand-child 3') wgtree.values = treedata F.edit() global RETURN #RETURN = wgtree.values RETURN = wgtree.get_selected_objects()
def searchButton(*args): vehicle_history_search = Search.Search_Vehic_History(self.serNo.value) results = list() try: curs.execute(vehicle_history_search) rows = curs.fetchall() if len(rows) > 0: results.append("vehicle id, number of transactions, average price, number of violations") for row in rows: row = str(row) row = row.strip() results.append(row) else: results = list() results.append("No results found") F = np.Form(name = "Query") F.add(np.TitlePager,name = "Results:",values = results) F.edit() except cx_Oracle.DatabaseError as exc: self.parentApp.switchForm("ERROR")
def main(self): F = npyscreen.Form(name="Welcome to Npyscreen", ) t = F.add(npyscreen.BoxBasic, name="Basic Box:", max_width=30, relx=2, max_height=3) t.footer = "This is a footer" t1 = F.add(npyscreen.BoxBasic, name="Basic Box:", rely=2, relx=32, max_width=30, max_height=3) t2 = F.add(npyscreen.BoxTitle, name="Box Title:", max_height=6) t2.entry_widget.scroll_exit = True t2.values = [ "Hello", "This is a Test", "This is another test", "And here is another line", "And here is another line, which is really very long. abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", "And one more." ] F.edit()
def main(self): Form = npyscreen.Form(name="GNU/Linux Magazine") text = Form.add(MyTitleAutocomplete, name="Texte :") Form.edit() npyscreen.notify_wait("Valeur saisie : " + text.value, title="Vérification")
def main(self): msgFront = npyscreen.Form(name = 'Please Answer Following questions to configure your settings') self.username = msgFront.add(npyscreen.TitleText, name = "User Name: ", ) self.email = msgFront.add(npyscreen.TitleText, name = "email: ") ml = msgFront.add(npyscreen.MultiLineEdit,value = "",max_height=3, rely=4) self.logName= msgFront.add(npyscreen.TitleMultiSelect, max_height =-2, value = [1,], name="Pick application You want to store",values = getTxTFile(), scroll_exit=True) msgFront.edit()
def main(self): F = npyscreen.Form(name="Generate STL files for selected parts") self.mult = F.add(npyscreen.TitleMultiSelect, max_height=-2, name="Select:", values=self.parts, scroll_exit=True) F.edit()
def start(self, *args): groups = [tup[0] for tup in list(self._track.getAllGroups())] solvers = self._res.getSolvers() F = npyscreen.Form(name='Configure Table Generation') outputloc = F.add(npyscreen.TitleText, name='Output to') G = npyscreen.Form(name='Select Benchmarks Groups') selgroup = G.add( npyscreen.MultiSelect, name='Select Benchmark Groups', values=groups, scroll_exit= True # Let the user move out of the widget by pressing the down arrow instead of tab. Try it without #to see the difference. ) H = npyscreen.Form(name='Select Solvers') selsolv = H.add( npyscreen.MultiSelect, name='Solvers', values=solvers, scroll_exit= True # Let the user move out of the widget by pressing the down arrow instead of tab. Try it without # to see the difference. ) I = npyscreen.Form(name='Select Output Format') seltable = I.add( npyscreen.TitleSelectOne, name='Table Technique', values=self._techniques, scroll_exit= True # Let the user move out of the widget by pressing the down arrow instead of tab. Try it without # to see the difference. ) F.edit() G.edit() H.edit() I.edit() self.groups = [selgroup.values[i] for i in selgroup.value] self.solvers = [selsolv.values[i] for i in selsolv.value] self.tableStyle = [seltable.values[i] for i in seltable.value][0] self.loc = outputloc.value
def mainScreen(*args): while True: n1 = 0 n2 = 0 n3 = 0 F = npyscreen.Form(name='XTEEN POWER INTERFACE 2.3.11') t = F.add( npyscreen.FixedText, value= 'POWER FAILURE - RESTART GENERATORS 1, 2, and 3 TO RESTORE FULL POWER' ) F.nextrely += 2 s = F.add(npyscreen.TitleSlider, value=gen1, out_of=2, name='GENERATOR 1', label=False) F.nextrely += 1 s = F.add(npyscreen.TitleSlider, value=gen2, out_of=4, name='GENERATOR 2', label=False) F.nextrely += 1 s = F.add(npyscreen.TitleSlider, value=n3, out_of=2, name='GENERATOR 3', label=False) F.nextrely += 2 t6 = F.add(npyscreen.FixedText, value='SECURITY CODE: 867-5309') F.nextrely += 1 t2 = F.add( npyscreen.FixedText, value= 'GENERATOR 1 PHASE 1 CODE: "if i cannot inspire Love, i will cause Fear"' ) F.nextrely += 1 t3 = F.add( npyscreen.FixedText, value= 'GENERATOR 1 PHASE 2 CODE: "th0re ishjZhGtbNMUD6ZVa3 1/ecJPLXhEd7ogH bmJPFHKQV1xCMIi/qB/S 1IkzV+NVi0UhM' ) t5 = F.add( npyscreen.FixedText, value= 'Dkp+EyjyxSo10EFLPYw3cI1bohMTEhITMzISE zNCFOl/sQqjCItW/G3o3WMSExMyFaGD4 skSUVNRDXdVkGfMTc8p12Vu' ) t5 = F.add( npyscreen.FixedText, value= 'ubnl1bUmKdMJV9NiSEzOSE5ykQDV E/S0zzle/WljXO9y2aQ3a/Uk56S/SNApbrrdfiDA+5HK9c GrbP34dPhff80GyaiT' ) F.nextrely += 2 t4 = F.add(npyscreen.FixedText, value='ERROR TERMINAL MALFUNCTION - ERROR CODE 0x0045') F.display()
def main(self): F = npyscreen.Form(name = "Welcome to Npyscreen",) s = F.add(ProcessBarBox, max_height=3, out_of=12, value=5, name = "Text:") #s.editable=False # This lets the user play with the Form. F.edit()
def sliderTest(screen): F = npyscreen.Form() F.add(npyscreen.TitleSlider, name="Slider 1") F.add(npyscreen.TitleSlider, color='STANDOUT', name="Slider 2") F.add(npyscreen.Slider, name="Slider 3") wPasses = F.add(TitleScansSlider, name="Scans:", out_of=10, lowest=1, step=1) F.edit()
def main(self): F = np.Form(name = "Baixar Filmes/Séries",) t = F.add(np.TitleText, name = "URL:", ) t2 = F.add(np.TitleText, name = "Nome do Filme", rely=4) opt = F.add(np.TitleSelectOne, name="Pastas", max_height=9, values=self.options, rely=6, scroll_exit=True) #ACABE LOGO COM MINHA DOR AAAAAAAAAAAAAAAAAAAAAAAAAA F.edit() self.name = t2.get_value() self.url = t.get_value() self.dir = opt.get_selected_objects()
def mainloop(scr): S = npyscreen.Form() display = S.add_widget(npyscreen.TitleText, name=unicode('Hello\267World!', 'latin-1').encode('utf-8')) display.value = name = unicode('Hello\267World!', 'latin-1').encode('utf-8') S.display() S.edit()
def main(self): Form = npyscreen.Form(name="GNU/Linux Magazine") cbox_values = ["Option 1", "Option 2", "Option 3"] cbox = Form.add(npyscreen.TitleMultiSelect, max_height=len(cbox_values), value = [1,], name="Choix :", values = cbox_values, scroll_exit=True) Form.edit() npyscreen.notify_wait("Valeur saisie : " + str(cbox.get_selected_objects()), title="Vérification")
def network(self): dev_eth = [] for dev in range(1, 5): dev_eth.append(netifaces.interfaces()[dev]) net = npyscreen.Form( name= "Impostazione Rete per Default, Selezione il modo delle interfaccie", lines=0, columns=0, minimum_lines=24, minimum_columns=80) iface0 = net.add(npyscreen.TitleSelectOne, max_height=4, name="Rete WAN:", values=dev_eth, scroll_exit=True) iface1 = net.add(npyscreen.TitleSelectOne, max_height=4, name="Rete LAN1:", values=dev_eth, scroll_exit=True) net.edit() try: config = open('/etc/network/interfaces', 'w') config.write( str('auto lo %s %s\n' 'iface lo inet loopback\n' 'iface %s inet dhcp\n' 'iface %s inet static\n' ' address 192.168.50.1\n' ' network 255.255.255.0\n\n') % (str(iface0.get_selected_objects()[0]), str(iface1.get_selected_objects()[0]), str(iface0.get_selected_objects()[0]), str(iface1.get_selected_objects()[0]))) config.close() call(["sudo", "/etc/init.d/networking", "stop"]) call(["sudo", "/etc/init.d/networking", "start"]) config = open('/etc/dhcp/dhcpd.conf', 'w') config.write( str('ddns-update-style none;\n' 'authoritative;\n' 'option domain-name "aron.proxy.local";\n' 'option domain-name-servers 8.8.8.8, 8.8.4.4;\n' 'default-lease-time 28800;\n' 'max-lease-time 28800;\n' 'log-facility local7;\n\n' 'subnet 192.168.50.0 netmask 255.255.255.0 {\n' ' interface %s;\n' ' range 192.168.50.10 192.168.50.254;\n' ' option routers 192.168.50.1;\n' '}\n') % (str(iface1.get_selected_objects()[0]))) config.close() call(["sudo", "/etc/init.d/isc-dhcp-server", "restart"]) npyscreen.notify_confirm("Impostazione Rete riuscita.") except: npyscreen.notify_confirm("Impostazione Rete non riuscita.")
def main(): #password = raw_input("enter password: ") password = getpass.getpass('enter password: '******'personal lab') form.edit() return
def main(self): options = [m[0] for m in self._models] form = npyscreen.Form(name='Download models') ms2 = form.add(npyscreen.TitleMultiSelect, value=list(range(len(options))), name='Models to download', values=options) form.edit() self.return_value = [self._models[i][0] for i in ms2.value]
def main(self): F = npyscreen.Form(name="Welcome to Npyscreen", ) t = F.add( npyscreen.TitleText, name="Text:", ) fn = F.add(npyscreen.TitleFilename, name="Filename:") fn2 = F.add(npyscreen.TitleDateCombo, name="Date:") s = F.add(npyscreen.TitleSlider, out_of=12, name="Slider") F.edit()
def main(self): npyscreen.setTheme(BeautifulTheme) Form = npyscreen.Form(name="GNU/Linux Magazine") text = Form.add(npyscreen.FixedText, value="Exemple de formulaire minimal") user_text = Form.add(npyscreen.TitleText, name="Saisir texte:") Form.edit() npyscreen.notify_wait("Valeur saisie : " + user_text.value, title="Vérification")
def main(self): # npyscreen.Form.DEFAULT_LINES=200 self.form = npyscreen.Form(name="Configuration Manager:%s" % self.name, ) self.form.DEFAULT_LINES = 100 # from IPython import embed;embed(colors='Linux') self.config, errors = j.data.serializer.toml.merge(self.template, self.config, listunique=True) self.form_add_items_pre() for key, val in self.config.items(): if key in self.auto_disable: continue ttype = j.data.types.type_detect(val) if ttype.NAME in ["string", "integer", "float", "list", "guid"]: self.widget_add_val(key) elif ttype.NAME in ["bool", "boolean"]: self.widget_add_boolean(key) else: raise RuntimeError("did not implement %s" % ttype) self.form_add_items_post() # t = F.add(npyscreen.TitleText, name = "Text:",) # fn = F.add(npyscreen.TitleFilename, name = "Filename:") # fn2 = F.add(npyscreen.TitleFilenameCombo, name="Filename2:") # dt = F.add(npyscreen.TitleDateCombo, name = "Date:") # s = F.add(npyscreen.TitleSlider, out_of=12, name = "Slider") # ml = F.add(npyscreen.MultiLineEdit, # value = """try typing here!\nMutiline text, press ^R to reformat.\n""", # max_height=5, rely=9) # ms = F.add(npyscreen.TitleSelectOne, max_height=4, value = [1,], name="Pick One", # values = ["Option1","Option2","Option3"], scroll_exit=True) # ms2= F.add(npyscreen.TitleMultiSelect, max_height =-2, value = [1,], name="Pick Several", # values = ["Option1","Option2","Option3"], scroll_exit=True) # This lets the user interact with the Form. self.form.edit() # integrate custom results rc = 1 while rc > 0: self.process_results() rc = self.form_pre_save() if rc > 0: self.form.edit() self.form.exit_editing() self.setNextForm(None)
def main(self): # These lines create the form and populate it with widgets. # A fairly complex screen in only 8 or so lines of code - a line for each control. F = npyscreen.Form(name="Welcome to Npyscreen", ) t = F.add(npyscreen.TextfieldUnicode, name="Text:", value='Ω—Ƣ') t.left_margin = 10 a = F.add(npyscreen.Textfield, name="Text:", value='This is the original textfield') # This lets the user play with the Form. F.edit()