本文整理汇总了Python中Tkinter.Tk.protocol方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.protocol方法的具体用法?Python Tk.protocol怎么用?Python Tk.protocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.protocol方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
def main():
global ROOT
ROOT = Tk()
ROOT.protocol('WM_DELETE_WINDOW', terminateAll)
w = ROOT.winfo_screenwidth()
h = ROOT.winfo_screenheight()
ROOT.geometry("%dx%d" % (w/1.6, h/3))
app = Window(ROOT)
ROOT = mainloop()
示例2: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
def main():
global ROOT, APP
host.initialize(LOCALNAME, "GSN", GSNID, IP, int(PORT))
ROOT = Tk()
ROOT.protocol("WM_DELETE_WINDOW", close_handler)
ROOT.geometry("320x480+300+300")
APP = MainFrame(ROOT)
ROOT.mainloop()
示例3: test
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
def test():
from Tkinter import Tk
root = Tk()
root.protocol("WM_DELETE_WINDOW", root.destroy)
class MyScrolledList(ScrolledList):
def fill_menu(self): self.menu.add_command(label="pass")
def on_select(self, index): print "select", self.get(index)
def on_double(self, index): print "double", self.get(index)
s = MyScrolledList(root)
for i in range(30):
s.append("item %02d" % i)
return root
示例4: __init__
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
class Display:
def __init__(self, fps=FPS, width=WIDTH, height=HEIGHT,
board_offset_bottom=BOARD_OFFSET_BOTTOM,
board_width=BOARD_WIDTH,
board_height=BOARD_HEIGHT):
self.root=Tk()
self.root.protocol("WM_DELETE_WINDOW", self.root.destroy)
self.width = width
self.height = height
self.canvas=Canvas(self.root, bg="black",width=width,height=height)
self.board_width = board_width
self.board_height = board_height
self.board_offset_bottom = board_offset_bottom
self.canvas.pack()
self.fps = fps
self.controllers = []
#For reset
self.root.bind("<space>", lambda e:self.reset_all())
self.root.bind("<Escape>", lambda e:self.root.destroy())
def run(self):
self.root.after(1000//self.fps, self.loop)
try:
self.root.mainloop()
except KeyboardInterrupt:
self.root.destroy()
def loop(self):
actions = [controller.get_action(self.model) for controller in self.controllers]
self.model.update(1./self.fps, actions)
self.draw()
self.root.after(1000//self.fps, self.loop)
def draw(self):
self.canvas.delete('all')
self.board = self.canvas.create_rectangle(
self.model.x()-self.board_width/2,
self.board_offset_bottom+self.height-self.board_height,
self.model.x()+self.board_width/2,
self.board_offset_bottom+self.height, fill="green")
self.pendulum = self.canvas.create_line(
self.model.x(),
self.board_offset_bottom+self.height-self.board_height,
self.model.x()+self.model.arm_length*math.sin(self.model.alpha()),
self.board_offset_bottom+self.height-self.board_height-self.model.arm_length*math.cos(self.model.alpha()),
fill="blue", width=20)
def attach_model(self, model):
self.model = model
self.draw()
def attach_controller(self, controller):
self.controllers.append(controller)
def reset_all(self):
self.model.randomize()
示例5: BusyWin
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
class BusyWin(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.w=Tk()
Label(self.w,text="Processing. Please Wait").pack()
self.w.protocol("WM_DELETE_WINDOW", self.buyWinCloseHandler)
def buyWinCloseHandler(self):
pass
def show(self):
self.start()
def run(self):
self.w.mainloop()
def close(self):
self.w.destroy()
示例6: quickentry
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
def quickentry(labels, callback, title='', defaults=None):
"Simple dialog from grabbing parameters from the user."
if defaults is None:
defaults = {}
root = Tk()
root.title(title)
root['padx'] = 20
root['pady'] = 10
widgets = {}
for label in labels:
# Create a text frame to hold the text Label and the Entry widget
f = Frame(root)
#Create a Label in textFrame
l = Label(f)
l['text'] = label
l['width'] = 10
l.pack(side=LEFT)
w = Entry(f)
w['width'] = 20
w.pack(side=LEFT)
w.insert(0, defaults.get(label, ''))
widgets[label] = w
f.pack()
def cb():
callback({label: widgets[label].get().strip() for label in labels})
Button(root, text="Quit", command=lambda root=root: root.destroy()).pack(side=RIGHT)
Button(root, text='Submit', command=cb).pack(side=RIGHT)
root.protocol("WM_DELETE_WINDOW", lambda root=root: root.destroy())
print '[quickentry] running'
root.bind("<Return>", lambda e: cb())
root.bind("<Escape>", lambda e: root.destroy())
root.mainloop()
print '[quickentry] done'
return root
示例7: run
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
def run():
"""
Esegue l'emulatore del pdp8
"""
CD = pdp8()
principale = Tk()
principale.title("Pdp8 Emulator : Assembly Editor")
emulatore = Toplevel()
emulatore.title("Pdp8 Emulator")
emulatore.geometry("1015x589")
edit = Editor(principale, CD)
scrollbar1 = AutoScrollbar(emulatore)
scrollbar1.grid(row=0, column=1, sticky=N + S)
scrollbar2 = AutoScrollbar(emulatore, orient=HORIZONTAL)
scrollbar2.grid(row=1, column=0, sticky=E + W)
finestra = Canvas(emulatore,
yscrollcommand=scrollbar1.set,
xscrollcommand=scrollbar2.set)
finestra.grid(row=0, column=0, sticky=N + S + E + W)
scrollbar1.config(command=finestra.yview)
scrollbar2.config(command=finestra.xview)
emulatore.grid_rowconfigure(0, weight=1)
emulatore.grid_columnconfigure(0, weight=1)
emul = Emulatore(finestra, edit, CD, emulatore)
finestra.create_window(0, 0, anchor=NW, window=emul.master)
emul.master.update_idletasks()
finestra.config(scrollregion=finestra.bbox("all"))
principale.protocol("WM_DELETE_WINDOW", edit.exit)
emulatore.protocol("WM_DELETE_WINDOW", emul.exit)
principale.mainloop()
emulatore.mainloop()
示例8: startSession
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
def startSession(self):
assert TkinterIsInstalled, '''
Tkinter is not installed.
If you have Linux you could try using
"apt-get install python-tk"'''
try:
import nlopt
except ImportError:
s = '''
To use OpenOpt multifactor analysis tool
you should have nlopt with its Python API installed,
see http://openopt.org/nlopt'''
print(s)
showerror('OpenOpt', s)
raw_input()
return
import os
hd = os.getenv("HOME")
self.hd = hd
root = Tk()
self.root = root
from openopt import __version__ as oover
root.wm_title(' OpenOpt %s Multifactor analysis tool for experiment planning ' % oover)
SessionSelectFrame = Frame(root)
SessionSelectFrame.pack(side='top', padx=230, ipadx = 40, fill='x', expand=True)
var = StringVar()
var.set('asdf')
Radiobutton(SessionSelectFrame, variable = var, text = 'New', indicatoron=0, \
command=lambda: (SessionSelectFrame.destroy(), self.create())).pack(side = 'top', fill='x', pady=5)
Radiobutton(SessionSelectFrame, variable = var, text = 'Load', indicatoron=0, \
command=lambda:self.load(SessionSelectFrame)).pack(side = 'top', fill='x', pady=5)
root.protocol("WM_DELETE_WINDOW", self.exit)
root.mainloop()
self.exit()
示例9: ConfigFileError
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
vd_config_fname = 'vd.cfg'
DebugLog.debug_print_level2("The config_file is " + vd_config_fname)
if vd_config and os.path.exists(vd_config_fname):
vd_config.read(vd_config_fname)
else:
raise ConfigFileError('%s not found' % (vd_config_fname))
vdCommCenterThrd = Thread(target=vdCommCenter_inst.start)
vdCommCenterThrd.start()
server_data_entity = DataEntity(vd_config)
vd_contr = SvrController(vd_config, vdCommCenter_inst, server_data_entity)
root = Tk()
root.title("VIOS Deploy Tool")
DebugLog.info_print("Create Vd App")
appl = VdApp(root, vd_contr, vd_config)
#root.maxsize(1112, 676)
root.protocol('WM_DELETE_WINDOW',None)
root.mainloop()
vdCommCenter_inst.stop()
root.quit()
except :
DebugLog.exception_print("Catch exception")
示例10: InputDevice
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
class InputDevice(object):
def __init__(self):
# root is the Tkinter root widget
self.root = Tk()
self.root.title("Input Device Utility")
# self.root.configure(background='grey')
self.root.resizable(False,False)
# define response to main window closing
self.root.protocol ("WM_DELETE_WINDOW", self.app_exit)
self.my_device =''
self.my_device_display = StringVar()
self.device_list=[]
self.matches=0
# overall display
root_frame=Frame(self.root)
root_frame.pack(side=LEFT)
devices_frame=Frame(root_frame,padx=5,pady=10)
devices_frame.pack(side=LEFT)
devices_label = Label(devices_frame, text="Devices in dev/input")
devices_label.pack(side=TOP)
devices_list_frame=Frame(devices_frame,padx=5,pady=10)
devices_list_frame.pack(side=TOP)
selected_device_title=Label(devices_frame,text='Selected device')
selected_device_title.pack(side=TOP)
self.selected_device_var=StringVar()
selected_device=Label(devices_frame,textvariable=self.selected_device_var,fg="red")
selected_device.pack(side=TOP)
events_frame=Frame(root_frame,padx=5,pady=10)
events_frame.pack(side=LEFT)
events_title=Label(events_frame,text='Received Events')
events_title.pack(side=TOP)
events_list_frame=Frame(events_frame,padx=5,pady=10)
events_list_frame.pack(side=TOP)
# list of devices
scrollbar = Scrollbar(devices_list_frame, orient=VERTICAL)
self.devices_display = Listbox(devices_list_frame, selectmode=SINGLE, height=20,
width = 60, bg="white",activestyle=NONE,
fg="black", yscrollcommand=scrollbar.set)
scrollbar.config(command=self.devices_display.yview)
scrollbar.pack(side=RIGHT, fill=Y)
self.devices_display.pack(side=LEFT, fill=BOTH, expand=1)
self.devices_display.bind("<ButtonRelease-1>", self.e_select_device)
# events display
scrollbar = Scrollbar(events_list_frame, orient=VERTICAL)
self.events_display = Text(events_list_frame,width=40,height=20, wrap='word', font="arial 11",padx=5,yscrollcommand=scrollbar.set)
scrollbar.config(command=self.events_display.yview)
scrollbar.pack(side=RIGHT, fill=Y)
self.events_display.pack(side=LEFT, fill=BOTH, expand=1)
self.events_display.config(state=NORMAL)
self.events_display.delete(1.0, END)
self.events_display.config(state=DISABLED)
self.selected_device_index=-1
self.matches=0
self.get_all_devices()
self.refresh_devices_display()
self.root.after(10,self.event_loop)
# and enter Tkinter event loop
self.root.mainloop()
# ***************************************
# INIT AND EXIT
# ***************************************
def app_exit(self):
self.root.destroy()
exit()
def event_loop(self):
if self.matches>0:
self.get_events()
self.root.after(10,self.event_loop)
def refresh_devices_display(self):
self.devices_display.delete(0,self.devices_display.size())
for device in self.all_devices:
self.devices_display.insert(END, device[0]+ ' ' +device[1])
if self.selected_device_index >= 0:
self.devices_display.itemconfig(self.selected_device_index,fg='red')
#.........这里部分代码省略.........
示例11: Visualiser
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
class Visualiser(threading.Thread):
STEPS_PER_FRAME = 1
# It can work with given scale or given sizes
SCALE = 0.5
DYNAMIC_SCALE = True
SIZE_X = 700
SIZE_Y = 700
# Vessel size
VESSEL_X = 16
VESSEL_Y = 16
# For displaying angle
ANGLE_SIZE = 15
def __init__(self, area):
super(Visualiser, self).__init__()
self.area = area
# Steps
self.steps = 0
# Synchronization
self.lock = threading.Lock()
self.lock.acquire()
# List of subs projected map
self.objects = []
self.master = Tk()
self.w = Canvas(self.master, width=sx(Area.SIZE_X), height=sy(Area.SIZE_Y))
self.master.protocol("WM_DELETE_WINDOW", self.callback)
self.w.config(borderwidth=sx(10))
self.w.pack()
self.__draw_warning_areas()
# Now we can start
self.start()
def callback(self):
self.master.quit()
def run(self):
self.master.mainloop()
def step(self):
if self.steps >= Visualiser.STEPS_PER_FRAME:
self.draw()
self.steps = 0
else:
self.steps += 1
def draw(self):
# Code to check steps
self.__draw_one_frame()
self.master.update()
def __draw_one_frame(self):
# Lock
# ------ SECTION START
self.__clear_objects()
s = Sub(self.area)
self.__draw_ships()
# ------ SECTION END
def __draw_ships(self):
for s in self.area.vessels:
self.__draw_ship(s)
def __draw_ship(self, target):
# Just for dimensions
ship_start = scale_ship_start(target.x, target.y)
ship_end = scale_ship_end(target.x, target.y)
ship = self.w.create_oval(ship_start[0], ship_start[1], ship_end[0], ship_end[1])
self.objects.append(ship)
# TODO: Done quickly, not perfect, new function needed
text = self.w.create_text(ship_start[0],ship_start[1],text=target.name)
self.objects.append(text)
# TODO: Done quickly, not perfect, new function needed
ship_middle = (sx(target.x),sy(target.y))
line_end = (sx(target.x+np.cos(target.angle)*self.ANGLE_SIZE),sy(target.y+np.sin(target.angle)*self.ANGLE_SIZE))
line = self.w.create_line(ship_middle[0], ship_middle[1], line_end[0], line_end[1])
self.objects.append(line)
def __clear_objects(self):
for s in self.objects:
self.w.delete(s)
def __draw_warning_areas(self):
self.__draw_warning_area(0, 0, Area.WARN_X0, Area.SIZE_Y)
self.__draw_warning_area(0, 0, Area.SIZE_Y, Area.WARN_Y0)
self.__draw_warning_area(Area.WARN_X1, 0, Area.SIZE_X, Area.SIZE_Y)
self.__draw_warning_area(0, Area.WARN_Y1, Area.SIZE_X, Area.SIZE_Y)
def __draw_warning_area(self, start_x, start_y, end_x, end_y):
#.........这里部分代码省略.........
示例12: Tk
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
if (data[0:6]=='mclear' and peer_id==my_ip):
print "clear?"
clear_request_received_time = time.time()
#layout initialization, start receiving thread
if __name__ == "__main__":
root = Tk()
root.title('Shared whiteboard')
root.config(bg='#ddd')
root.columnconfigure(2, weight=1)
root.rowconfigure(1, weight=1)
root.protocol("WM_DELETE_WINDOW", callback)
root.minsize(width=600, height=340)
root.bind('<<openIt!>>', myDialog)
root.bind('<<sorry>>', sorryDialog)
root.bind('<<new>>', refreshMessage)
canvas = Canvas(root, width=canvasWidth, height=canvasHeight, bg='#fff')
canvas.grid(column=0, row=1, sticky=(N, W, E, S), columnspan=7)
clearButton = Button(root, text="Clear everyone's canvas",
width = 20, command=clearCanvas)
clearButton.grid(column=0, row=0, padx=5, pady=5)
clearMyCanvas = Button(root, text="Clear my canvas", command=clearMyPressed,
width = 14)
示例13: OSCMonitor
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
#.........这里部分代码省略.........
return text
# ***************************************
# INIT EXIT MISC
# ***************************************
def e_edit_osc(self):
self.disconnect_client()
self.close_server()
self.edit_osc()
self.init()
self.add_status('\n\n\nRESTART')
self.run_app()
def app_exit(self):
self.disconnect_client()
self.close_server()
if self.root is not None:
self.root.destroy()
self.mon.finish()
sys.exit()
def show_help (self):
tkMessageBox.showinfo("Help","Read 'manual.pdf'")
def about (self):
tkMessageBox.showinfo("About","Simple Remote Monitor for Pi Presents\n"
+"Author: Ken Thompson"
+"\nWebsite: http://pipresents.wordpress.com/")
def setup_gui(self):
# set up the gui
# root is the Tkinter root widget
self.root = Tk()
self.root.title("Remote Monitor for Pi Presents")
# self.root.configure(background='grey')
self.root.resizable(False,False)
# define response to main window closing
self.root.protocol ("WM_DELETE_WINDOW", self.app_exit)
# bind some display fields
self.filename = StringVar()
self.display_show = StringVar()
self.results = StringVar()
self.status = StringVar()
# define menu
menubar = Menu(self.root)
toolsmenu = Menu(menubar, tearoff=0, bg="grey", fg="black")
menubar.add_cascade(label='Tools', menu = toolsmenu)
osc_configmenu = Menu(menubar, tearoff=0, bg="grey", fg="black")
menubar.add_cascade(label='Options', menu = osc_configmenu)
osc_configmenu.add_command(label='Edit', command = self.e_edit_osc)
helpmenu = Menu(menubar, tearoff=0, bg="grey", fg="black")
menubar.add_cascade(label='Help', menu = helpmenu)
helpmenu.add_command(label='Help', command = self.show_help)
helpmenu.add_command(label='About', command = self.about)
self.root.config(menu=menubar)
# status_frame
status_frame=Frame(self.root,padx=5,pady=5)
status_frame.pack(side=TOP, fill=BOTH, expand=1)
status_label = Label(status_frame, text="Status",font="arial 12 bold")
status_label.pack(side=LEFT)
scrollbar = Scrollbar(status_frame, orient=VERTICAL)
self.status_display=Text(status_frame,height=10, yscrollcommand=scrollbar.set)
scrollbar.config(command=self.status_display.yview)
scrollbar.pack(side=RIGHT, fill=Y)
self.status_display.pack(side=LEFT,fill=BOTH, expand=1)
# ***************************************
# OSC CONFIGURATION
# ***************************************
def read_create_osc(self):
if self.osc_config.read(self.osc_config_file) is False:
self.osc_config.create(self.osc_config_file)
eosc = OSCEditor(self.root, self.osc_config_file,'slave','Create OSC Monitor Configuration')
self.osc_config.read(self.osc_config_file)
def edit_osc(self):
if self.osc_config.read(self.osc_config_file) is False:
self.osc_config.create(self.osc_config_file)
eosc = OSCEditor(self.root, self.osc_config_file,'slave','Edit OSC Monitor Configuration')
示例14: EngineGui
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
#.........这里部分代码省略.........
self.buttonSpeedDown = Button(frame, text="Speed down", command=self.communicationProtocal.handleSpeedDown)
self.buttonSpeedDown.grid(row = 10, column=1, padx=3, sticky=E)
self.speedValue = 0
self.intVarSpeed = IntVar()
vcmd = (self.tkRoot.register(self.OnValidateEntrySpeakSpeed), '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')
self.entrySpeakSpeed = Entry(frame, textvariable=self.intVarSpeed, validate="key", validatecommand=vcmd, width=5)
self.entrySpeakSpeed.grid(row=10,column=2)
self.entrySpeakSpeed.bind('<Return>', self.CallBackSetSpeed)
self.buttonSpeedUp = Button(frame, text="Speed up", command=self.communicationProtocal.handleSpeedUp)
self.buttonSpeedUp.grid(row = 10, column=3)
Label(frame, text="voice:").grid(row = 11, column=0, padx=3, sticky=W)
self.buttonPrevVoice = Button(frame, text="Prev voice", command=self.communicationProtocal.handlePrevVoice)
self.buttonPrevVoice.grid(row = 12, column=0, padx=3, sticky=W)
self.buttonNextVoice = Button(frame, text="Next voice", command=self.communicationProtocal.handleNextVoice)
self.buttonNextVoice.grid(row = 12, column=3)
self.currentVoice = StringVar(self.tkRoot)
self.currentVoice.set(self.communicationProtocal.CurrentVoiceName)
engine = pyttsx.init()
voices = engine.getProperty("voices")
voiceNames = list()
for x in xrange(0, len(voices)):
voiceNames.append(voices[x].name)
self.optionMenuVoices = OptionMenu(frame, self.currentVoice, *tuple(voiceNames), command=self.CallBackOptionMenuVoices)
self.optionMenuVoices.config(width=500)
self.optionMenuVoices.grid(sticky=W, row = 12, column = 1)
#hide if close button is clicked
self.tkRoot.protocol("WM_DELETE_WINDOW", self.HideGui)
self.tkRoot.after(1000/32, self.Update)
self.tkRoot.mainloop()
def Update(self):
wordLocation = self.communicationProtocal.OnWordStartLocation
wordLength = self.communicationProtocal.OnWordLength
wordTotal = self.communicationProtocal.OnWordTotal
if wordLocation:
self.labelStart.configure(text=wordLocation)
else:
self.labelStart.configure(text="0")
self.labelLength.configure(text=wordLength)
if wordLength != 0 and wordTotal == 0:
self.labelTotal.configure(text="Introduce")
else:
self.labelTotal.configure(text=wordTotal)
if len(self.communicationProtocal.SpeakQueue) != 0:
if (wordLocation < 25):
self.labelSentenceLeft.configure(text=str(self.communicationProtocal.SpeakQueue[0])[0:wordLocation])
else:
self.labelSentenceLeft.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation-25:wordLocation])
self.labelSentenceSpoken.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation:wordLocation+wordLength])
if (wordTotal - wordLocation - wordLength < 25):
self.labelSentenceRight.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation+wordLength:wordTotal])
else:
self.labelSentenceRight.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation+wordLength:wordLocation+wordLength+25])
else:
self.labelSentenceLeft.configure(text="...")
self.labelSentenceSpoken.configure(text="...")
self.labelSentenceRight.configure(text="...")
示例15: show_screen
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import protocol [as 别名]
def show_screen(self):
window = Tk()
def shutdown():
sys.exit()
# overrides
window.protocol('WM_DELETE_WINDOW', shutdown)
# set window properties
window.title(Login.window_title)
window.geometry(Login.window_size)
window.configure(bg=Login.window_color)
title_bar = Label(window, text=Login.title_text, bg=Login.window_color)
user_label = Label(window, text=Login.user_label, bg=Login.window_color)
pass_label = Label(window, text=Login.pass_label, bg=Login.window_color)
message = Label(window, bg=Login.window_color)
def authenticate():
try:
db = open('db/user_db.csv', "r")
line = db.readlines()
username = usr_box.get()
password = pswd_box.get()
# print username.get()
# print line[1].strip()
# print password.get()
#print line[2].strip()
#print line[0].strip()
usr = line[1].strip()
pswd = line[2].strip()
#print usr, ' ', pswd
while username == usr and password == pswd:
# message.configure(text=Login.message_success)
db.close()
window.destroy()
else:
#print usr
self.tries -= 1
message.configure(text=Login.message_failed)
if self.tries < 1:
db.close()
message.configure(text=Login.message_failed_attempts)
# python code to wait for say... 3 seconds before shutting down.
sys.exit()
except IOError:
print "Error: Could not find specified file"
except TclError:
print "Login window closing"
usr_box = Entry(window)
pswd_box = Entry(window, show='*')
login_btn = Button(window, text=Login.login_btn, command=authenticate, bg=Login.login_btn_color)
title_bar.pack()
user_label.pack()
usr_box.pack()
pass_label.pack()
pswd_box.pack()
login_btn.pack()
message.pack()
return window