from tkinter import *
import tkinter.ttk as ttk
import sys
def cmd1(txt_entry1,txt_entry2,txt_entry3,txt_combo1,txt_combo2,form):
txt = ("<form name=" + '"' + txt_entry1.get() + '"' +
" action=" + '"' + txt_entry2.get() + '"' +
" id=" + '"' + txt_entry3.get() + '"' +
" method="+ '"'+txt_combo1.get() + '"' +
" enctype="+ '"'+txt_combo2.get() + '" ' +">" + "\n"
)
global text
text.insert(END,txt)
form.destroy()
def idCreateForm():
form = Tk()
form.title("Свойства формы")
lab1=Label(form,text="имя формы")
lab1.pack()
entry1=Entry(form,width=50)
entry1.pack()
lab2=Label(form,text="имя обработчика")
lab2.pack()
entry2=Entry(form,width=50)
entry2.pack()
lab3=Label(form,text="идентификатор")
lab3.pack()
entry3=Entry(form,width=50)
entry3.pack()
lab4=Label(form,text="Метод")
lab4.pack()
combobox1 = ttk.Combobox(form,values = ["get","post"],width=50,height=3)
combobox1.pack()
lab5=Label(form,text="Способ кодирования")
lab5.pack()
combobox2 = ttk.Combobox(form,values = ["application/x-www-form-urlencoded","multipart/form-data","text/plain"],width=50,height=3)
combobox2.pack()
button1=Button(form,text='создать форму',font='arial 14',command= lambda: cmd1(entry1,entry2,entry3,combobox1,combobox2,form))
button1.pack()
form.geometry('350x350')
form.mainloop()
def cmd2(txt_entry1,txt_entry2,txt_combo1,form):
txt = ("<input type=" + '"' +"checkbox" + '"' +
" name=" +'"'+ txt_entry1.get() +'"'+
" value="+'"'+txt_entry1.get()+'"'+
" checked="+'"'+ txt_combo1.get()+ '" ' +">" + "\n"
)
global text
text.insert(END,txt)
form.destroy()
def idCreateCheckbox():
form = Tk()
form.title("Свойства флажка")
lab1=Label(form,text="имя флажка")
lab1.pack()
entry1=Entry(form,width=50)
entry1.pack()
lab2=Label(form,text="значение флажка")
lab2.pack()
entry2=Entry(form,width=50)
entry2.pack()
lab3=Label(form,text="Пометка флажка")
lab3.pack()
combobox1 = ttk.Combobox(form,values = ["checked"],width=50,height=3)
combobox1.pack()
button1=Button(form,text='создать флажок',font='arial 14',command= lambda: cmd2(entry1,entry2,combobox1,form))
button1.pack()
form.geometry('350x350')
form.mainloop()
def cmd3(txt_entry1,txt_entry2,txt_combo1,form):
txt = ("<input type=" + '"' +"radio" + '"' +
" name=" +'"'+ txt_entry1.get() +'"'+
" value="+'"'+txt_entry1.get()+'"'+
" checked="+'"'+ txt_combo1.get()+ '" ' +">" + "\n"
)
global text
text.insert(END,txt)
form.destroy()
def idCreateRadio():
form = Tk()
form.title("Свойства переключателя")
lab1=Label(form,text="имя переключателя")
lab1.pack()
entry1=Entry(form,width=50)
entry1.pack()
lab2=Label(form,text="значение переключателя")
lab2.pack()
entry2=Entry(form,width=50)
entry2.pack()
lab3=Label(form,text="Пометка переключателя")
lab3.pack()
combobox1 = ttk.Combobox(form,values = ["checked"],width=50,height=3)
combobox1.pack()
button1=Button(form,text='создать переключатель',font='arial 14',command= lambda: cmd3(entry1,entry2,combobox1,form))
button1.pack()
form.geometry('350x350')
form.mainloop()
def cmd4(txt_entry3,listbox1):
listbox1.insert(END,txt_entry3.get())
txt_entry3.delete(0, END)
def cmd5(txt_entry1,txt_entry2,txt_entry3,listbox1,form):
options =""
for i in range(0,listbox1.size()):
options+="<option value="+'"' + listbox1.get(i)+'">' +listbox1.get(i)+"</option>"+"\n"
txt = ("<select id= " +'"'+ txt_entry1.get() +'"'+
" size="+'"'+ txt_entry2.get() +'">'+"\n"+options+
"</select>"+"\n"
)
text.insert(END,txt)
form.destroy()
def idCreateSelect():
form = Tk()
form.title("Свойства списка")
lab1=Label(form,text="идентикатор")
lab1.pack()
entry1=Entry(form,width=50)
entry1.pack()
lab2=Label(form,text="размер")
lab2.pack()
entry2=Entry(form,width=50)
entry2.pack()
lab3=Label(form,text="Пункты списка")
lab3.pack()
listbox1 = Listbox(form,width=50)
listbox1.pack()
entry3=Entry(form,width=50)
entry3.pack()
button1=Button(form,text='добавить пункт',font='arial 14',command= lambda: cmd4(entry3,listbox1))
button1.pack()
button2=Button(form,text='создать список',font='arial 14',command= lambda: cmd5(entry1,entry2,entry3,listbox1,form))
button2.pack()
form.geometry('350x350')
form.mainloop()
root = Tk()
root.geometry('500x500')
scrollbar = Scrollbar(root)
text = Text(root, yscrollcommand = scrollbar.set ,wrap=WORD,width=50)
text.place(x = 0 , y = 0)
mainmenu = Menu(root)
root.config(menu=mainmenu)
filemenu = Menu(mainmenu, tearoff=0)
filemenu.add_command(label="Создать форму",command=idCreateForm)
filemenu.add_command(label="Создать флажок",command=idCreateCheckbox)
filemenu.add_command(label="Создать переключатель",command=idCreateRadio)
filemenu.add_command(label="Создать список",command=idCreateSelect)
mainmenu.add_cascade(label="Работа с формами", menu=filemenu)
root.mainloop()
|