Con este scripts de python podrás recoger datos de una ventana gráfica.
Es necesario importar pysimplebox.
batchBox.py
batchBox.bat Ejemplo
batchBox.py
# -*- coding: utf-8 -*- ''' By: HackLoper version: 1.0 python version: 2.7 blog: http://hackloper.blogspot.com twiter: https://twitter.com/HackLoper o @HackLoper youtuve: https://www.youtube.com/user/hackdeveloper tuenti: HackLoper gmail: hackloper.soporte@gmail.com ''' from __future__ import print_function import argparse,pysimplebox,Tkinter parser = argparse.ArgumentParser(); parser.add_argument("type",help="tipo de ventana: simple, input_data ."); parser.add_argument("-b","--box",help="simple: ABORTRETRYIGNORE, CANCELTRYCONTINUE,\ HELP, OK, OKCANCEL, RETRYCANCEL, YESNO, YESNOCANCEL."); parser.add_argument("-i","--icon",help="simple: ICONEXCLAMATION, ICONWARNING,\ ICONINFORMATION, ICONASTERISK, ICONQUESTION, ICONSTOP, ICONERROR, ICONHAND ."); parser.add_argument("-o","--option",help="simple: NORMAL, PERMANET ."); parser.add_argument("-tt","--title",help="name title"); parser.add_argument("-t","--text",help="simple: text message.\n\ input_data: texto label"); args = parser.parse_args(); var = vars(args); class input_data(Tkinter.Tk): def __init__(self,box,title='title',label='text'): Tkinter.Tk.__init__(self); self.label = label; self.title(title); self.resizable(width=False,height=False); self.pady = 10 t = ['frame','label_text','input_text','button_data','configure']; for i in t: eval('self.'+i+'()'); def command(self): print(self.e.get()); self.destroy(); def frame(self): self.f = Tkinter.Frame(self); self.f.grid(row=0,column=0); def label_text(self): self.l = Tkinter.Label(self.f,text=self.label); self.l.grid(row=0,column=0,pady=self.pady); def input_text(self): self.e = Tkinter.Entry(self.f); self.e.grid(row=1,column=0,sticky='n',pady=self.pady,ipadx=60); def button_data(self): self.b = Tkinter.Button(self.f,text='enviar',command=lambda:self.command()); self.b.grid(row=2,column=0,sticky='n',pady=self.pady); def configure(self): self.f.columnconfigure('all',minsize=300); def argument(variables,type_election): if type_election == 'input_data': default = {'box':'input_text', 'title':'title', 'text':'text'} t = (); for v in variables: if var[v] == None: t = t+(default[v],); else: t = t+(var[v],); return t else: default = {'box':'OK', 'icon':'ICONEXCLAMATION', 'option':'NORMAL', 'title':'title', 'text':'text'} t = (); for v in variables: if var[v] == None: t = t+(default[v],); else: t = t+(var[v],); return t def main(): if var['type'] == 'simple': del var['type']; data = argument(var,'simple'); s = pysimplebox.show(data[0],data[4],data[1],data[2],data[3]); print(s); elif var['type'] == 'input_data': delete = ('option','icon','type'); fake_var = var.copy(); for v in fake_var: for d in delete: if v == d: del var[v]; data = argument(var,'input_data'); root = input_data(data[0],data[1],data[2]); root.mainloop(); if __name__ == '__main__': main();
batchBox.bat Ejemplo
@echo off FOR /F "tokens=*" %%A IN ('batchbox.py simple -b OKCANCEL') DO ( echo %%A if %%A == OK ( echo fue ok ) else ( echo no fue ok ) ) pause
0 comentarios:
Publicar un comentario