本文整理汇总了Python中ttk.Entry.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.insert方法的具体用法?Python Entry.insert怎么用?Python Entry.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Entry
的用法示例。
在下文中一共展示了Entry.insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
def initUI(self, parameterDict, callback, validate, undoCallback):
self.parent.title("Choose parameters for fit")
Style().configure("TButton", padding=(0, 5, 0, 5),
font='serif 10')
self.columnconfigure(0, pad=3)
self.columnconfigure(1, pad=3)
count = 0
entries = {}
for key, value in parameterDict.iteritems():
self.rowconfigure(count, pad=3)
label = Label(self, text=key)
label.grid(row=count, column=0)
entry = Entry(self)
entry.grid(row=count, column=1)
entry.insert(0, value)
entries[key] = entry
count = count + 1
def buttonCallback(*args): #the *args here is needed because the Button needs a function without an argument and the callback for function takes an event as argument
try:
newParameterDict = {}
for key, value in entries.iteritems():
newParameterDict[key] = value.get()
self.parent.withdraw() #hide window
feedback = callback(newParameterDict)
if validate:
if(askyesno("Validate", feedback, default=YES)):
self.parent.destroy() #clean up window
else:
undoCallback() #rollback changes done by callback
self.parent.deiconify() #show the window again
else:
self.parent.withdraw()
self.parent.destroy()
except Exception as e:
import traceback
traceback.print_exc()
self.parent.destroy()
self.parent.bind("<Return>", buttonCallback)
self.parent.bind("<KP_Enter>", buttonCallback)
run = Button(self, text="Run fit", command=buttonCallback)
run.grid(row=count, column=0)
count = count + 1
self.pack()
示例2: editarParroquia
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
def editarParroquia(self):
t = Toplevel(self)
t.wm_title("Estudio")
Label(t, text="Nombre").grid(row=0, column=1)
E2 = Entry(t)
E2.insert(END, self.selectorParroquial.get())
E2.grid(row=1, column=1)
nombreOld = self.selectorParroquial.get()
button1 = Button(t, text="Cancelar", command=lambda: t.destroy())
button2 = Button(t, text="Guardar", command=lambda: self.actualizarParroquia(nombreOld, E2.get(), t))
button3 = Button(t, text="Borrar", command=lambda: self.BorrarParroquial(E2.get(), t))
button1.grid(row=2, column=0)
button2.grid(row=2, column=1)
button3.grid(row=2, column=2)
示例3: initUI
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
def initUI(self):
self.parent.title("Software Activation")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
if(self.needsActivated()):
idEntry = Entry(self, width=36)
idEntry.place(x=175, y=20)
idEntry.delete(0, END)
idEntry.insert(0, "Enter a product id")
keyEntry = Entry(self, width=36)
keyEntry.place(x=175, y=40)
keyEntry.delete(0, END)
keyEntry.insert(0, "Enter your license key")
activateButton = Button(self, text="Activate",
command=lambda:self.activate(
idEntry.get(), keyEntry.get()))
activateButton.place(x=250, y=65)
else:
label = Label(self, text="Product has already been activated")
label.pack()
示例4: Example
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.date = (time.strftime("%m_%d_%Y"))
self.initUI()
def initUI(self):
self.parent.title("Experiment")
self.pack(fill=BOTH, expand=True)
self.frame1 = Frame(self)
self.frame1.pack(fill=X)
self.lbl1 = Label(self.frame1, text="Participant", width=10)
self.lbl1.pack(side=LEFT, padx=5, pady=5)
self.entry1 = Entry(self.frame1)
self.entry1.pack(fill=X, padx=5, expand=True)
self.frame2 = Frame(self)
self.frame2.pack(fill=X)
self.lbl2 = Label(self.frame2, text="Date", width=10)
self.lbl2.pack(side=LEFT, padx=5, pady=5)
self.entry2 = Entry(self.frame2)
self.entry2.insert(0, self.date)
self.entry2.state()
self.entry2.pack(fill=X, padx=5, expand=True)
self.frame3 = Frame(self)
self.frame3.pack(fill=X)
self.lbl3 = Label(self.frame3, text="COM Port", width=10)
self.lbl3.pack(side=LEFT, padx=5, pady=5)
self.entry3 = Entry(self.frame3)
self.entry3.pack(fill=X, padx=5, expand=True)
self.frame4 = Frame(self)
self.frame4.pack(fill=X)
self.accept = Button(self.frame4, text="Ok", command=self.makeVariables)
self.accept.pack(fill=X, padx=5)
def makeVariables(self):
self.participant = self.entry1.get()
self.port = self.entry3.get()
self.verify()
Frame.quit(self)
def verify(self):
mbox.showwarning('Check', 'Have you set the markers on Emotiv Toolbox?')
def getName(self):
return self.participant
def getDate(self):
return self.date
def get_port(self):
return self.port
示例5: ChooseType
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
class ChooseType(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.controller = controller
ChooseType.socket = None
ChooseType.create_player = None
self.plx_name = "PLAYER"
ChooseType.plx_type = "SPECTATOR"
ChooseType.start_game = None
label_1 = Label(self, text="Create character", font=TITLE_FONT, justify=CENTER, anchor=CENTER)
label_2 = Label(self, text="Name: ")
self.entry_1 = Entry(self)
self.entry_1.insert(0, 'Player_')
label_3 = Label(self, text="Join as: ")
button1 = Button(self, text="FROG", command=self.callback_frog)
button2 = Button(self, text="FLY", command=self.callback_fly)
button3 = Button(self, text="SPECTATOR", command=self.callback_spec)
ChooseType.button4 = Button(self, text="Back", command=lambda: controller.show_frame("StartPage"))
label_1.pack(side="top", fill="x", pady=10)
label_2.pack()
self.entry_1.pack()
label_3.pack()
button1.pack()
button2.pack()
button3.pack()
ChooseType.button4.pack(pady=20)
def check_name(self,s):
temp = False
try:
s.decode('ascii')
except UnicodeEncodeError:
print "it was not a ascii-encoded unicode string"
tkMessageBox.showwarning("Error message", "Invalid player name")
except UnicodeDecodeError:
print "it was not a ascii-encoded unicode string"
tkMessageBox.showwarning("Error message", "Invalid player name")
else:
if len(s) < 10 and len(s) >= 1:
temp = True
else:
tkMessageBox.showwarning("Error message", "String lenght must be 1-10 characters")
return temp
# this frame works on callbacks so each button is processed separately
# 1. get name
# 2. check if the name is valid
# 3. set player type
# 4. **create server localy if the user comes from create server frame
# 5. add player to the game (parameters: name, type)
def callback_frog(self):
self.plx_name = self.entry_1.get()
if self.check_name(self.plx_name):
ChooseType.plx_type = "FROG"
self.create_server(CreateServer.plx_name,CreateServer.game_dim)
self.callback_add_player()
def callback_fly(self):
self.plx_name = self.entry_1.get()
if self.check_name(self.plx_name):
ChooseType.plx_type = "FLY"
self.create_server(CreateServer.plx_name,CreateServer.game_dim)
self.callback_add_player()
def callback_spec(self):
self.plx_name = self.entry_1.get()
if self.check_name(self.plx_name):
ChooseType.plx_type = "SPECTATOR"
self.create_server(CreateServer.plx_name,CreateServer.game_dim)
self.callback_add_player()
# join the game
def callback_add_player(self):
set_shut_down_level(1)
data = "JOIN;"+ChooseType.plx_type
if global_state==1:
# directly (locally) access the game engine
ChooseType.create_player = CreateServer.local_world.add_player(self.plx_name)
CLIENTS.append((ChooseType.create_player, 'Local Player'))
CreateServer.local_world.set_player_attr(ChooseType.create_player, 1, 'character', data)
ChooseType.start_game = True
else:
GameWindow.vSer.set(globvar[0])
host,_ = globvar[1]
try:
ChooseType.socket = s = socket.socket(AF_INET,SOCK_STREAM)
s.connect((host,QUAD_AXE))
# ping-pong communication:
# 1. client: ADD_ME;Player1 -> server: ADDED -> client
# 2. client: JOIN;FROG -> server
data2 = 'ADD_ME;'+self.plx_name
self.socket.send(data2.encode())
buf = ChooseType.socket.recv(100)
message = buf.decode('utf-8')
if message == "ADDED":
#.........这里部分代码省略.........
示例6: CreateServer
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
class CreateServer(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.controller = controller
CreateServer.local_world = None
label_1 = Label(self, text="Create server\n\n\n\n", font=TITLE_FONT, justify=CENTER, anchor=CENTER)
label_2 = Label(self, text="Server name:")
label_3 = Label(self, text="Gamefield (MxN):")
CreateServer.plx_name = 'none'
CreateServer.game_dim = '10X10'
self.entry_1 = Entry(self)
self.entry_2 = Entry(self)
self.entry_2.insert(0, '10x10')
self.entry_1.bind("<Key>", self.checkString)
self.button1 = Button(self, text="Create",state="disabled", command= self.callback_set)
self.button2 = Button(self, text="Back", command=lambda: controller.show_frame("StartPage"))
label_1.pack(side="top", fill="x", pady=10)
label_2.pack()
self.entry_1.pack()
label_3.pack()
self.entry_2.pack()
self.button1.pack(pady=10)
self.button2.pack(pady=20)
def com(self, controller, next_frame):
controller.show_frame(next_frame)
def checkString(self, event):
if self.entry_1:
self.button1.config(state="normal")
def callback_set(self):
set_global_state(1)
if self.get_name_field():
self.controller.show_frame("ChooseType")
# process user inputs
def get_name_field(self):
CreateServer.plx_name = self.entry_1.get()
CreateServer.game_dim = self.entry_2.get().upper()
flag2 = False
flag1 = self.string_check(CreateServer.plx_name,"Invalid server name")
if flag1:
flag2 = self.string_check(CreateServer.game_dim,"Invalid game field parameters")
if flag2:
m_split=CreateServer.game_dim.split('X')
if len(m_split)==2:
try:
_ = int(m_split[0])
except:
flag2 = False
try:
_ = int(m_split[1])
except:
flag2 = False
else:
flag2 = False
if flag2 == False:
tkMessageBox.showwarning("Error message", "Invalid game field parameters!")
return flag1 & flag2
# check if the string is usable
def string_check(self,s,msg):
temp = False
try:
s.decode('ascii')
except UnicodeEncodeError:
print "it was not an ascii-encoded unicode string"
tkMessageBox.showwarning("Error message", msg)
except UnicodeDecodeError:
print "it was not an ascii-encoded unicode string"
tkMessageBox.showwarning("Error message", msg)
else:
if len(CreateServer.plx_name) < 11 and len(CreateServer.plx_name) >= 1:
temp = True
else:
tkMessageBox.showwarning("Error message", "Please input 1-10 characters!")
return temp
示例7: ventanaVoluntarios
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
#.........这里部分代码省略.........
# Etiqueta y seleccion de Estudios
Label(t, text="Estudios").grid(row=4)
box_value = StringVar()
self.getEstudios()
self.selectorEstudios = Combobox(t, textvariable=box_value, state='readonly')
self.selectorEstudios['values'] = self.listadoEstudios[0]
self.selectorEstudios.configure(width=25)
self.selectorEstudios.current(0)
self.selectorEstudios.grid(row=4, column=1)
botonEditarEstudios = Button(t, text="Editar", command=self.editarEstudio)
botonNuevosEstudios = Button(t, text="Nuevo", command=self.nuevoEstudio)
botonEditarEstudios.grid(row=4, column=2)
botonNuevosEstudios.grid(row=4, column=3)
# Etiqueta y seleccion de Genero
Label(t, text="Genero").grid(row=5)
seleccionGenero = Combobox(t, values=["Masculino (M)", "Femenino (F)"], state='readonly')
seleccionGenero.grid(row=5, column=1)
# Etiqueta y seleccion de Parroquial
Label(t, text="Parroquial").grid(row=6)
box_value = StringVar()
self.getParroquial()
self.selectorParroquial = Combobox(t, textvariable=box_value, state='readonly')
self.selectorParroquial['values'] = self.listadoParroquial[0]
self.selectorParroquial.configure(width=25)
self.selectorParroquial.current(0)
self.selectorParroquial.grid(row=6, column=1)
botonEditarParroquial = Button(t, text="Editar", command=self.editarParroquia)
botonNuevaParroqual = Button(t, text="Nuevo", command=self.nuevaParroquia)
botonEditarParroquial.grid(row=6, column=2)
botonNuevaParroqual.grid(row=6, column=3)
# Etiqueta y seleccion de Correo
Label(t, text="Correo").grid(row=0, column=4)
entradaCorreo = Entry(t)
entradaCorreo.grid(row=0, column=5)
Label(t, text="Telefono 1").grid(row=1, column=4)
entradaTelefono1 = Entry(t)
entradaTelefono1.grid(row=1, column=5)
Label(t, text="Telefono 2").grid(row=2, column=4)
entradaTelefono2 = Entry(t)
entradaTelefono2.grid(row=2, column=5)
# Etiqueta y entrada de Fecha
Label(t, text="Fecha").grid(row=3, column=4)
entradaAno = Entry(t)
entradaMes = Entry(t)
entradaDia = Entry(t)
entradaAno.grid(row=3, column=5)
entradaMes.grid(row=3, column=6)
entradaDia.grid(row=3, column=7)
# Etiqueta y seleccion de Pais
Label(t, text="Pais").grid(row=4, column=4)
box_value = StringVar()
self.getPais()
self.selectorPais = Combobox(t, textvariable=box_value, state='readonly')
self.selectorPais['values'] = self.listadoPais[0]
self.selectorPais.configure(width=25)
self.selectorPais.current(0)
self.selectorPais.grid(row=4, column=5)
botonEditarPais = Button(t, text="Editar", command=self.editarPais)
botonNuevaPais = Button(t, text="Nuevo", command=self.nuevoPais)
botonEditarPais.grid(row=4, column=6)
botonNuevaPais.grid(row=4, column=7)
#Rellenamos los cambos si estamos editando
if row > -1:
voluntario = self.table.model.getRecordAtRow(row)
entradaNombre.insert(END,voluntario['nombre'])
entradaApellidos.insert(END,voluntario['apellidos'])
entradaCorreo.insert(END,voluntario['correo_electronico'])
entradaTelefono1.insert(END,voluntario['telefono_1'])
entradaTelefono2.insert(END,voluntario['telefono_2'])
entradaDireccion.insert(END,voluntario['direccion'])
entradaDNI.insert(END,voluntario['dni'])
self.selectorEstudios.set(voluntario['estudio'])
self.selectorParroquial.set(voluntario['parroquial'])
guardar = FALSE
id = voluntario['id']
button5 = Button(t, text="Guardar", command=lambda: self.nuevoVoluntario(entradaNombre.get(),
entradaApellidos.get(),entradaDNI.get(),entradaDireccion.get(),
entradaCorreo.get(),1,self.listadoEstudios[1][self.selectorEstudios.current()],
self.listadoParroquial[1][self.selectorParroquial.current()],
1,entradaTelefono1.get(),entradaTelefono2.get(),"M","2001-01-01",t,guardar,id))
button6 = Button(t, text="Cancelar", command=t.destroy)
button5.grid(row=7, column=4)
button6.grid(row=7, column=5)
示例8: Metadator
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
#.........这里部分代码省略.........
self.nb.tab(1, text=self.blabla.get('gui_tab2'))
self.caz_cat.config(text=self.blabla.get('tab2_merge'))
# tab3
self.nb.tab(2, text=self.blabla.get('gui_tab3'))
self.lab_chps.config(text=self.blabla.get('tab3_sele'))
self.supr.config(text=self.blabla.get('tab3_supp'))
self.FrRekur.config(text=self.blabla.get('tab3_tit'))
self.tab3_LBnom.config(text=self.blabla.get('tab3_nom'))
self.tab3_LBdesc.config(text=self.blabla.get('tab3_desc'))
self.tab3_CBcass.config(text=self.blabla.get('tab3_cass'))
self.tab3_CBstat.config(text=self.blabla.get('tab3_stat'))
self.save.config(text=self.blabla.get('tab3_save'))
# End of function
return self.blabla
def load_texts(self, lang='FR'):
u"""
Load texts according to the selected language
"""
# clearing the text dictionary
self.blabla.clear()
# open xml cursor
xml = ET.parse('locale/{0}/lang_{0}.xml'.format(lang))
# Looping and gathering texts from the xml file
for elem in xml.getroot().getiterator():
self.blabla[elem.tag] = elem.text
# updating the GUI
self.update()
# en of function
return self.blabla
def setpathtarg(self):
""" ...browse and insert the path of target folder """
foldername = askdirectory(parent=self,
initialdir=self.def_rep,
mustexist=True,
title=self.blabla.get('gui_cible'))
# check if a folder has been choosen
if foldername:
try:
self.target.delete(0, END)
self.target.insert(0, foldername)
except:
info(title=self.blabla.get('nofolder'),
message=self.blabla.get('nofolder'))
return
# count shapefiles and MapInfo files in a separated thread
proc = threading.Thread(target=self.li_geofiles,
args=(foldername, ))
proc.daemon = True
proc.start()
# end of function
return foldername
def li_geofiles(self, foldertarget):
u""" List shapefiles and MapInfo files (.tab, not .mid/mif) contained
in the folders structure """
# reseting global variables
self.li_shp = []
self.li_tab = []
self.browsetarg.config(state=DISABLED)
# Looping in folders structure
self.status.set(self.blabla.get('tab1_prog1'))
示例9: Window
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
class Window(Frame):
def __init__(self, parent, window_type):
Frame.__init__(self, parent, msg = None)
self.parent = parent
if window_type == "main":
self.initUI_main()
if window_type == "err":
self.initUI_err()
def initUI_main(self):
self.parent.title("Personal Helper")
self.pack(fill=BOTH, expand=True)
self.columnconfigure(0, weight=1)
self.columnconfigure(7, weight=1)
self.columnconfigure(5, pad=10)
self.columnconfigure(3, pad=10)
self.columnconfigure(1, weight=3)
self.rowconfigure(0, weight=0)
self.rowconfigure(5, weight=1)
self.rowconfigure(5, pad=7)
self.rowconfigure(6, pad=6)
lbl = Label(self, text="Windows")
lbl.grid(sticky=W+N, pady=4, padx=5)
check_box = {"work": IntVar(),
"boost": IntVar()}
check1 = Checkbutton(self, text="work-Mode", variable=check_box["work"])
check1.grid(row=7, column=0)
check2 = Checkbutton(self, text="boost games", variable=check_box["boost"])
check2.grid(row=7, column=1)
### old version, may be used again later
area = Treeview(self)
area['show'] = 'headings'
area["columns"] = ("one", "two", "three", "four")
area.column("one", width=10)
area.column("two", width=10)
area.column("three", width=10)
area.column("four", width=10)
area.heading("one", text="process name")
area.heading("two", text="Priority")
area.heading("three", text="PID")
area.heading("four", text="Usage")
###about this part
#area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N)
#######
#comboboxes and relevant buttons
self.block_drop = Combobox(self, postcommand= self.update_blocked)
self.block_drop['values'] = working_bans
self.block_drop.current(0)
self.block_drop.grid(row=1, column=1, pady=1)
self.entry = Entry(self)
self.entry.insert(0, "enter to block")
self.entry.grid(row=1, column=4)
block_btn_remv = Button(self, text="Remove", command=lambda: remove_from_list(working_bans, self.block_drop.get()))
block_btn_remv.grid(row=1, column=2)
block_btn_add = Button(self, text="Add", command=lambda: add_to_list(working_bans, self.entry.get(), self.entry, defults["block"]))
block_btn_add.grid(row=1, column=3)
############
#boosted combo
self.boost_drop = Combobox(self, postcommand=self.update_boosted)
self.boost_drop['values'] = boosted
self.boost_drop.current(0)
self.boost_drop.grid(row=2, column=1, pady=1)
self.entry2 = Entry(self)
self.entry2.insert(0, "enter to buff priority")
self.entry2.grid(row=2, column=4, pady=4)
boost_btn_remv = Button(self, text="Remove", command=lambda: remove_from_list(boosted, self.boost_drop.get()))
boost_btn_remv.grid(row=2, column=2)
boost_btn_add = Button(self, text="Add", command=lambda: add_to_list(boosted, self.entry2.get(), self.entry2, defults["boost"]))
boost_btn_add.grid(row=2, column=3)
#########################################
#degraded combo
self.deg_drop = Combobox(self, postcommand=self.update_degraded)
self.deg_drop['values'] = degraded
self.deg_drop.current(0)
self.deg_drop.grid(row=3, column=1, pady=1)
self.entry3 = Entry(self)
self.entry3.insert(0, "enter to lower priority")
self.entry3.grid(row=3, column=4, pady=4)
deg_btn_remv = Button(self, text="Remove", command=lambda: remove_from_list(degraded, self.deg_drop.get()))
deg_btn_remv.grid(row=3, column=2)
#.........这里部分代码省略.........
示例10: Example
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
#.........这里部分代码省略.........
#######################################
framexxx = Frame(self)
framexxx.pack()
framexxx.place(x=700, y=600)
self.xxx = Label(framexxx,text="Recent Changes Will Appear Here")
self.xxx.config(font=labelfont8)
self.xxx.pack()
#######################################
frame000 = Frame(self)
frame000.pack()
frame000.place(x=50, y=600)
self.lbl000= Label(frame000, text="Beta/Sample2.0 | (c) Nakul Rathore")
self.lbl000.config(font=labelfont8)
self.lbl000.pack( padx=5, pady=5)
def openResume(self):
ftypes = [('All files', '*')]
dlg = tkFileDialog.Open(self, filetypes = ftypes,initialdir='C:/Users/')
global x15
fl = dlg.show()
#file name
x15 = fl
temp1 = os.path.basename(fl)
global temp2
temp2 = os.path.splitext(temp1)[0]
self.entry15.delete(0, 'end')
self.entry15.insert(0,temp2)
#####################
def getDatax(self):
x1 = self.entry1.get()
x2 = self.entry2.get()
x3 = self.entry3.get()
x4 = self.entry4.get()
x5 = v.get()
x6 = int(self.entry6.get())
x7 = int(self.entry7.get())
x8 = self.entry8.get()
x9 = self.entry9.get()
x10 = self.entry10.get('1.0', 'end')
x11 = int(self.entry11.get())
x11a = int(self.entry11a.get())
x11b = self.entry11b.get()
x12 = int(self.entry12.get())
x12a = int(self.entry12a.get())
示例11: initUI
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
def initUI(self):
self.parent.title("Resistor Calculator")
Style().configure("TButton", padding=(0, 5, 0, 5),
font='serif 10')
self.columnconfigure(0, pad=3)
self.columnconfigure(1, pad=3)
self.columnconfigure(2, pad=3)
self.columnconfigure(3, pad=3)
self.columnconfigure(4, pad=3)
self.columnconfigure(5, pad=3)
self.rowconfigure(0, pad=3)
self.rowconfigure(1, pad=3)
self.rowconfigure(2, pad=3)
self.rowconfigure(3, pad=3)
self.rowconfigure(4, pad=3)
self.rowconfigure(5, pad=3)
self.rowconfigure(6, pad=3)
self.rowconfigure(7, pad=3)
self.rowconfigure(8, pad=3)
self.rowconfigure(9, pad=3)
self.rowconfigure(10, pad=3)
self.rowconfigure(11, pad=3)
self.rowconfigure(12, pad=3)
entry = Entry(self)
entry.grid(row=0, columnspan=4, sticky=W+E)
global resistance
resistance=""
def ringOne(number):
entry.delete(0, END)
entry.insert(0, str(number))
global resistance
resistance = resistance + str(number)
def ringTwo(number):
ent=str(number)
entry.insert(END, str(number))
global resistance
resistance = resistance + str(number)
def ringThree(number):
ent=str(number)
entry.insert(END, str(number))
global resistance
resistance = resistance + str(number)
def ringFour(number):
global resistance
entry.delete(0, END)
for x in range (0, number):
resistance = resistance + "0"
ent = "Resistance is: " + resistance
entry.insert(END,ent)
resistance = ""
def cls():
global resistance
resistance = ""
entry.delete(0, END)
entry.insert(0,"Please Select ring colors")
entry.insert(0,"Please Select ring colors")
entry.config(justify=RIGHT)
black = Button(self, text="Black", command=lambda: ringOne(0))
black.grid(row=2, column=0)
brown = Button(self, text="Brown", command=lambda: ringOne(1))
brown.grid(row=3, column=0)
red = Button(self, text = "Red", command=lambda: ringOne(2))
red.grid(row=4, column=0)
orange = Button(self, text="Orange", command=lambda: ringOne(3))
orange.grid(row=5, column=0)
yellow = Button(self, text="Yellow", command=lambda: ringOne(4))
yellow.grid(row=6, column=0)
green = Button(self, text="Green", command=lambda: ringOne(5))
green.grid(row=7, column=0)
blue = Button(self, text="Blue", command=lambda: ringOne(6))
blue.grid(row=8, column=0)
violet = Button(self, text="Violet", command=lambda: ringOne(7))
violet.grid(row=9, column=0)
grey = Button(self, text = "Grey", command=lambda: ringOne(8))
grey.grid(row=10, column = 0)
white = Button(self, text="White", command=lambda: ringOne(9))
white.grid(row=11,column = 0)
black2 = Button(self, text="Black", command=lambda: ringTwo(0))
black2.grid(row=2, column=1)
brown2 = Button(self, text="Brown", command=lambda: ringTwo(1))
brown2.grid(row=3, column=1)
red2 = Button(self, text = "Red", command=lambda: ringTwo(2))
red2.grid(row=4, column=1)
orange2 = Button(self, text="Orange", command=lambda: ringTwo(3))
orange2.grid(row=5, column=1)
yellow2 = Button(self, text="Yellow", command=lambda: ringTwo(4))
yellow2.grid(row=6, column=1)
green2 = Button(self, text="Green", command=lambda: ringTwo(5))
green2.grid(row=7, column=1)
blue2 = Button(self, text="Blue", command=lambda: ringTwo(6))
blue2.grid(row=8, column=1)
#.........这里部分代码省略.........
示例12: IniGenGui
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
#.........这里部分代码省略.........
button_gen.grid(row=1, column=0, columnspan=2, sticky=W+E)
self.pack()
def generate_files(self):
algs = []
for alg in self.check_algs_map:
if self.check_algs_map[alg].get() == 1:
algs.append(alg)
if self.radio_loc_string.get() == "Other Location":
location = self.entry_otherloc.get()
else:
location = self.radio_loc_string.get()
name_raw = self.entry_nameselected.get()
name = self.entry_name.get()
ref_name = self.entry_refnameselected.get()
uuid_map = self.get_uuid_map(name_raw)
reference_uuid_map = self.get_ref_uuid_map(ref_name)
IniGenAutomation(location, name_raw, name, uuid_map, ref_name, reference_uuid_map, algs)
def namesearch(self):
searchterm = self.entry_namesearch.get()
searchphrase = '/upmu/%{0}%/%'.format(searchterm)
search_results = self.search(searchterm, searchphrase)
self.lstbx_namelist.delete(0, END)
if len(search_results) == 0:
tkMessageBox.showwarning('Search Error', 'No matches from search for \'{0}\''.format(searchterm))
else:
for result in search_results:
self.lstbx_namelist.insert(END, result)
def refnamesearch(self):
searchterm = self.entry_refnamesearch.get()
searchphrase = '/Clean/%{0}%/%'.format(searchterm)
search_results = self.search(searchterm, searchphrase, ref=True)
self.lstbx_refnamelist.delete(0, END)
if len(search_results) == 0:
tkMessageBox.showwarning('Search Error', 'No matches from search for \'{0}\''.format(searchterm))
else:
for result in search_results:
self.lstbx_refnamelist.insert(END, result)
def search(self, searchterm, searchphrase, ref=False):
connection = _mysql.connect(host="128.32.37.231", port=3306, user="upmuteam",
passwd="moresecuredataftw", db='upmu')
connection.query("SELECT * FROM uuidpathmap WHERE path LIKE '{0}'".format(searchphrase))
results = connection.store_result()
queried_data = {}
result = results.fetch_row()
while result != tuple():
queried_data[result[0][0]] = result[0][1]
result = results.fetch_row()
search_results = set()
for path in queried_data:
dirs = path.split('/')
if ref:
if searchterm in '/'.join(dirs[2:-2]):
search_results.add('/'.join(dirs[2:-2]))
else:
if searchterm in '/'.join(dirs[2:-1]):
search_results.add('/'.join(dirs[2:-1]))
return search_results
示例13: initUI
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
def initUI(self):
self.parent.title("One Time Pad Generator")
self.style = Style()
self.style.theme_use("default")
self.grid()
#string
text_to_encrypt = Entry(self)
text_to_encrypt.grid(row=0, column=0)
text_to_encrypt.delete(0, Tkinter.END)
text_to_encrypt.insert(0, "text you want to encrypt or decrypt")
#pad
encrypt_pad = Entry(self)
encrypt_pad.grid(row=0, column=1)
encrypt_pad.delete(0, Tkinter.END)
encrypt_pad.insert(0, "padOutput")
#start
start_encrypt = Entry(self)
start_encrypt.grid(row=0, column=2)
start_encrypt.delete(0, Tkinter.END)
start_encrypt.insert(0, 0)
#encrypt button
encodeButton = Button(self, text="Encrypt",
command=lambda: self.encrypt(text_to_encrypt.get(), encrypt_pad.get(), start_encrypt.get()))
encodeButton.grid(row=1, column=0)
#decrypt button
encodeButton = Button(self, text="Decrypt",
command=lambda: self.decrypt(str(text_to_encrypt.get()), encrypt_pad.get(), start_encrypt.get()))
encodeButton.grid(row=1, column=2)
#generate pad
padgen = Entry(self)
padgen.grid(row=2, column=0)
padgen.delete(0, Tkinter.END)
padgen.insert(0, 0)
#gen key button
genkey = Button(self, text="Generate Key",
command=lambda: Cryptography.outputPad(Cryptography.GenerateKey(int(padgen.get())), encrypt_pad.get()))
genkey.grid(row=2, column=1)
#encrypted text
self.T = Tkinter.Text(self)
S = Scrollbar(self.T)
S.grid(column=2);
S.config(command=self.T.yview)
self.T.config(yscrollcommand=S.set)
self.T.insert(Tkinter.END,self.encrypted[0])
self.T.grid(row=5, column=0, sticky="nsew", rowspan = 10, columnspan = 3)
#input email
e = Entry(self)
e.grid(row = 3, column = 0)
e.delete(0, Tkinter.END)
e.insert(0, "Send encrypted message via email")
#send email
email = Button(self, text="Send Email",command=lambda:self.sendmail(e.get()))
email.grid(row=3, column=1)
示例14: display_reporting_procedure
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
def display_reporting_procedure(*args):
no_log_file = not _error_file_name
path_name = os.path.join(user_directory, 'log', _error_file_name)
size=500
fr = Toplevel(height=size, width=size)
fr.title(string='Diagnil Problem Reporting Procedure')
Message(fr, aspect=300,
text=display_messages['reporting_procedure']
).pack(padx=10, pady=10)
def copy_entry_clipboard(ent):
ent.selection_range(0, END) # for Unix/Linux
ent.clipboard_clear()
ent.clipboard_append(ent.get()) # needed for Windows
if using_ttk or using_tile:
addr_ent = Entry(fr, background=text_bg_color, width=60)
else:
addr_ent = Entry(fr, background=text_bg_color, width=60, relief=SUNKEN)
addr_ent.insert(END, email_addr)
addr_ent.pack(padx=20, pady=5)
fr_email = Frame(fr)
Button(fr_email, text='Copy',
command=EventHandler('Reporting proc',
lambda : copy_entry_clipboard(addr_ent))
).pack(side=LEFT, padx=5)
Label(fr_email, text='E-mail Address to Clipboard').pack(side=LEFT, padx=5)
fr_email.pack(pady=5)
Frame(fr).pack(pady=5)
if using_ttk or using_tile:
file_ent = Entry(fr, background=text_bg_color, width=60)
else:
file_ent = Entry(fr, background=text_bg_color, width=60, relief=SUNKEN)
file_ent.insert(END, path_name)
file_ent.pack(padx=20, pady=5)
fr_file = Frame(fr)
copy_file_button = \
Button(fr_file, text='Copy',
command=EventHandler('Reporting proc',
lambda : copy_entry_clipboard(file_ent)))
copy_file_button.pack(side=LEFT, padx=5)
Label(fr_file, text='File name to Clipboard').pack(side=LEFT, padx=5)
fr_file.pack(pady=5)
if no_log_file:
file_ent['state'] = DISABLED
copy_file_button['state'] = DISABLED
Frame(fr).pack(pady=5)
Message(fr, aspect=800,
text=display_messages['privacy_notice']).pack(padx=10, pady=5)
if using_ttk or using_tile:
close_button = Button(fr, text=close_button_text, default=ACTIVE,
command=EventHandler('Reporting proc',
lambda : fr.destroy()))
else:
close_button = Button(fr, text=close_button_text, default=ACTIVE,
width=6,
command=EventHandler('Reporting proc',
lambda : fr.destroy()))
close_button.pack(side=RIGHT, padx=30, pady=10)
wrapped_bind(fr, '<Return>', lambda *ev: fr.destroy())
rx,ry = root.winfo_rootx(), root.winfo_rooty()
x = (root.winfo_width() - size) // 2
y = (root.winfo_height() - size) // 2
fr.geometry(newGeometry='+%d+%d'%(rx+x, ry+y))
示例15: Window
# 需要导入模块: from ttk import Entry [as 别名]
# 或者: from ttk.Entry import insert [as 别名]
class Window(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Network/Port Scan")
self.style = Style()
self.style.configure("TFrame", background = "#000000")
self.style.configure("TCheckbutton", background = "#000000")
self.style.configure("TButton", background = "#000000")
self.pack(fill=BOTH, expand=1)
# Configure layout
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(2, weight=1)
self.rowconfigure(5, weight = 1)
self.rowconfigure(6, weight = 1)
# Title of program
lbl = Label(self, text="Network/Port Scan")
lbl.grid(sticky = W, pady=5, padx=5)
# Text Box
area = ScrolledText(self, height = 20)
area.grid(row=1, column=0, columnspan=3, rowspan=4, padx=3, sticky = N+S+E+W)
self.area = area
# IP Address Button
self.ip = BooleanVar()
ip_add_button = Checkbutton(self, text="IP Address",variable=self.ip, width=10)
ip_add_button.grid(row = 1, column = 3, sticky = N)
ip_add_button.config(anchor = W, activebackground = "red")
# Port Button
self.port = BooleanVar()
port_button = Checkbutton(self, text="Ports", variable=self.port, width=10)
port_button.grid(row = 1, column = 3)
port_button.config(anchor = W, activebackground = "orange")
# Host Name Button
self.host = BooleanVar()
host_name_button = Checkbutton(self, text="Host Name",variable=self.host, width=10)
host_name_button.grid(row = 1, column = 3, sticky = S)
host_name_button.config(anchor = W, activebackground = "yellow")
# Gateway Button
self.gateway = BooleanVar()
gateway_btn = Checkbutton(self, text="Gateway", variable=self.gateway, width=10)
gateway_btn.grid(row = 2, column = 3, sticky = N)
gateway_btn.config(anchor = W, activebackground = "green")
# Services Button
self.service = BooleanVar()
service_btn = Checkbutton(self, text="Services", variable = self.service, width=10)
service_btn.grid(row = 2, column = 3)
service_btn.config(anchor = W, activebackground = "blue")
# Starting IP label
ip_label = Label(self, text = "Starting IP: ")
ip_label.grid(row = 5, column = 0, pady = 1, padx = 3, sticky = W)
self.ip_from = Entry(self, width = 15)
self.ip_from.insert(0, start_ip)
self.ip_from.grid(row = 5 , column = 0, pady = 1, padx = 3, sticky = E)
# Ending IP label
ip_label_two = Label(self, text = "Ending IP: ")
ip_label_two.grid(row = 5, column = 1, pady = 1, padx = 5, sticky = W)
self.ip_to = Entry(self, width = 15)
self.ip_to.insert(0, end_ip)
self.ip_to.grid(row = 5 , column = 1, pady = 1, padx = 5, sticky = E)
# Starting Port Label
port_label = Label(self, text = "Starting Port: ")
port_label.grid(row = 5, column = 0, pady = 3, padx = 5, sticky = S+W)
self.port_from = Entry(self, width = 15)
self.port_from.insert(0, 0)
self.port_from.grid(row = 5 , column = 0, pady = 1, padx = 5, sticky = S+E)
# Ending Port Label
port_label_two = Label(self, text = "Ending Port: ")
port_label_two.grid(row = 5, column = 1, pady = 3, padx = 5, sticky = S+W)
self.port_to = Entry(self, width = 15)
self.port_to.insert(0, 1025)
self.port_to.grid(row = 5 , column = 1, pady = 1, padx = 5, sticky = S+E)
# Scan Me
self_scan_button = Button(self, text="Scan Me", command = lambda : self.onClick(1), width = 33)
self_scan_button.grid(row = 6, column = 1, sticky = N)
# Scan near me Button
scan_other_button = Button(self, text="Scan Near Me", width = 33, command = lambda : self.onClick(2))
scan_other_button.grid(row = 6, column = 0, pady=1, sticky = N)
# Clear button
clear_button = Button(self, text="Clear text", command = self.clear_text, width = 12)
clear_button.grid(row = 6, column = 3, pady=1, sticky = N)
#.........这里部分代码省略.........