def __init__(self, master, version, canvas_width, canvas_height, main_menu=None): """ -------- Constructor -------- """ self.version = version self.canvas_width = canvas_width self.canvas_height = canvas_height self.master = master self.main_menu = main_menu self.direc = "" self.editor = None self.date_picker = None def clear_entries(): """ Clear all entry in the form. """ self.form_file_name.delete(0, END) self.direc = "" dir_txt.config(text="None", justify=CENTER) self.grade.delete(0, END) self.room.delete(0, END) self.affiliate.current(0) self.semester.delete(0, END) self.total_hour.delete(0, END) self.subject.delete(0, END) self.teacher_name.delete(0, END) def cancel_entry(): """ Cancel "New File" action and return to main menu. """ clear_entries() self.hide() self.main_menu.show() def choose_dir(): """ Event: Select a directory and returns it""" self.direc = tk.filedialog.askdirectory() dir_txt.config(text=self.direc, justify=LEFT) # ====================== ====================== ========= ====================== ====================== # ====================== ====================== START GUI ====================== ====================== # ====================== ====================== ========= ====================== ====================== self.canvas = tk.Canvas(master, highlightthickness=0, width=self.canvas_width, height=self.canvas_height) self.canvas.pack() # ====================== ====================== ====== ====================== ====================== # ====================== ====================== HEADER ====================== ====================== # ====================== ====================== ====== ====================== ====================== header = tk.Frame(self.canvas) header.place(relwidth=0.8, relx=0.1, rely=0.05) tk.Label(header, text="สร้างไฟล์ใหม่", font=self.h1_font).pack() tk.Label(header, text="โปรดกรอกข้อมูลต่อไปนี้ให้ครบถ้วนและถูกต้อง", font=self.h2_font).pack() # ====================== ====================== ==== ====================== ====================== # ====================== ====================== FORM ====================== ====================== # ====================== ====================== ==== ====================== ====================== form = tk.LabelFrame(self.canvas, text="รายละเอียดของไฟล์") form.place(relwidth=0.8, relx=0.1, relheight=0.7, rely=0.25) # ================= ================= FILE NAME ================= ================= form_name = tk.Frame(form) tk.Label(form_name, text="ชื่อไฟล์: ", font=self.easy_read).pack(side=LEFT, padx=10) self.form_file_name = tk.Entry(form_name, font=self.input_font) self.form_file_name.pack(side=LEFT, padx=6, expand=True, fill='x') tk.Label(form_name, text=".xlsx", font=self.easy_read).pack(side=LEFT) # ================= ================= DIRECTORY ================= ================= form_dir = tk.Frame(form) tk.Label(form_dir, text="ที่อยู่ของไฟล์: ", font=self.easy_read).pack(side=LEFT, padx=10) dir_txt = tk.Label(form_dir, text="ไม่มี", font=self.input_font) directory = ttk.Button(form_dir, text="เลือกที่อยู่", command=choose_dir, width=15) dir_txt.config(relief=SUNKEN) dir_txt.pack(side=LEFT, expand=True, fill='x', padx=10) directory.pack(side=LEFT) # ================= ================= SEMESTER ================= ================= form_semester = tk.Frame(form) tk.Label(form_semester, text="ภาคเรียนที่: ", font=self.easy_read).pack(side=LEFT, padx=10) self.term = ttk.Spinbox(form_semester, from_=1, to=100, font=self.input_font, width=8) self.term.pack(side=LEFT, padx=15) tk.Label(form_semester, text="ปีการศึกษา (พ.ศ.): ", font=self.easy_read).pack(side=LEFT, padx=10) self.semester = ttk.Spinbox(form_semester, from_=2000, to=9999, font=self.input_font, width=8) self.semester.pack(side=LEFT, padx=15) # ================= ================= CLASS ================= ================= form_class = tk.Frame(form) tk.Label(form_class, text="ชั้น ", font=self.easy_read).pack(side=LEFT, padx=10) self.grade = tk.Entry(form_class, width=4, font=self.input_font, justify=CENTER) self.grade.pack(side=LEFT, expand=True) tk.Label(form_class, text="/", font=self.easy_read).pack(side=LEFT, expand=True) self.room = ttk.Entry(form_class, width=4, font=self.input_font, justify=CENTER) self.room.pack(side=LEFT, expand=True) self.affiliate = ttk.Combobox(form_class, value=("ระดับชั้น", "ประถมศึกษา", "มัฐยมศึกษา"), font=self.input_font) self.affiliate.current(0) self.affiliate.pack(side=LEFT, padx=50) # ================= ================= SUBJECT & SU ================= ================= form_subject = tk.Frame(form) # Subject tk.Label(form_subject, text="วิชา: ", font=self.easy_read).pack(side=LEFT, padx=10) self.subject = ttk.Entry(form_subject, font=self.input_font, width=20) self.subject.pack(side=LEFT, padx=5) # Score Unit (SU) tk.Label(form_subject, text="จำนวน: ", font=self.easy_read).pack(side=LEFT, padx=10) self.s_unit = ttk.Spinbox(form_subject, font=self.input_font, width=10) self.s_unit.pack(side=LEFT, padx=5) tk.Label(form_subject, text="หน่วยกิต", font=self.easy_read).pack(side=LEFT, padx=10) # ================= ================= TOTAL HOURS ================= ================= form_hour = tk.Frame(form) tk.Label(form_hour, text="จำนวนชั่วโมง: ", font=self.easy_read).pack(side=LEFT, padx=10) self.total_hour = ttk.Spinbox(form_hour, from_=1, to=999, font=self.input_font, width=10) self.total_hour.pack(side=LEFT, padx=60, expand=True, fill='x') # ================= ================= TEACHER'S NAME ================= ================= form_teacher = tk.Frame(form) tk.Label(form_teacher, text="ชื่อครูผู้สอน: ", font=self.easy_read).pack(side=LEFT, padx=10) self.teacher_name = tk.Entry(form_teacher, font=self.input_font) self.teacher_name.pack(side=LEFT, expand=True, fill='x', padx=25) # ================= ================= BUTTONS ================= ================= form_btns = tk.Frame(form) ttk.Button(form_btns, text="ยืนยัน", command=self.confirm_entry) \ .pack(side=LEFT, padx=20, expand=True, fill='x') ttk.Button(form_btns, text="ล้างการกรอก", command=clear_entries) \ .pack(side=LEFT, padx=20, expand=True, fill='x') ttk.Button(form_btns, text="ยกเลิก", command=cancel_entry) \ .pack(side=LEFT, padx=20, expand=True, fill='x') # ================= ================= FORM : FINALIZE ================= ================= form_name.pack(padx=50, pady=5, fill='x') form_dir.pack(padx=50, pady=5, fill='x') form_semester.pack(padx=50, pady=5, fill='x') form_class.pack(padx=50, pady=5, fill='x') form_subject.pack(padx=50, pady=5, fill='x') form_hour.pack(padx=50, pady=5, fill='x') form_teacher.pack(padx=50, pady=5, fill='x') form_btns.pack(padx=20, pady=10, fill='x')
startingIndex_options = [0, 1] default_startingIndex = StringVar() default_startingIndex.set(startingIndex_options[0]) imagetype_options = [".png", ".jpg"] default_imagetype = StringVar() default_imagetype.set(imagetype_options[0]) mainframe = ttk.Frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) ## Row 1 ttk.Label(mainframe, text="Folder Location:").grid(column=1, row=1, sticky=E) location_entry = ttk.Entry(mainframe, width=30, textvariable=folder_path) location_entry.grid(column=2, row=1, sticky=(W, E)) ttk.Button(mainframe, text="Browse", command=lambda: browse_button()).grid(column=3, row=1, sticky=E) ## Row 2 ttk.Label(mainframe, text="Change File Names to:").grid(column=1, row=2, sticky=E) fileName_entry = ttk.Entry(mainframe, width=30, textvariable=fileName) fileName_entry.grid(column=2, row=2, sticky=(W, E), columnspan=2) ## Row 3 ttk.Label(mainframe, text="Separator:").grid(column=1, row=3, sticky=E) separator = OptionMenu(mainframe, default_separator, *separator_options)
win1.resizable(0, 0) win1.configure(background="grey") labelfont = ('times', 20, 'bold') labelfont1 = ('times', 15, 'bold') labelfont2 = ('times', 18, 'bold') head = ttk.Label(win1, text="\n\tSCHOOL MANAGEMENT SYSTEM\t\n") head.pack() head.configure(background="blue", width="200") head.config(font=labelfont2) myFont = font.Font(size=15) lab1 = ttk.Label(win1, text="Old Password:"******"grey") lab1.config(font=labelfont2) old_var = tk.StringVar() corus_ent = ttk.Entry(win1, width=30, show="*", textvariable=old_var) corus_ent.pack() corus_ent.config(font=labelfont1) lab2 = ttk.Label(win1, text="New Password") lab2.pack() lab2.configure(background="grey") lab2.config(font=labelfont2) new_var = tk.StringVar() name_ent = ttk.Entry(win1, width=30, show="*", textvariable=new_var) name_ent.pack() name_ent.config(font=labelfont1) sub_butt = Button(win1, text="\nChange Password", command=ChangePass) sub_butt['font'] = myFont sub_butt.pack(pady=10) sub_butt.configure(width="15") win1.mainloop()
import tkinter from tkinter import ttk window = tkinter.Tk() name = tkinter.StringVar() ttk.Label(window, width=12, text="Sample entry").grid(column=1, row=0) ttk.Entry(window, width=12, textvariable=name) window.mainloop()
GUI.geometry('500x500') GUI.title('Shopping Cart By Peter') #------------------------------ product = StringVar() price = StringVar() quantity = StringVar() Logo = PhotoImage(file='drink.jpg') GUILogo = Label(GUI, image=Logo) #------- Label and Entry of Product --------------------------------- LProduct = Label(GUI, text='Product', font=('Aagsana New',16)) LProduct.pack(padx=5,pady=5) EProduct = ttk.Entry(GUI, textvariable=product,font=('Aagsana New',16)) EProduct.pack(padx=5,pady=5) #------- Label and Entry of Price --------------------------------- LPrice = Label(GUI, text='Price', font=('Aagsana New',16)) LPrice.pack(padx=5,pady=5) EPrice = ttk.Entry(GUI, textvariable=price,font=('Aagsana New',16)) EPrice.pack(padx=5,pady=5) #------- Label and Entry of Quantity --------------------------------- LQuantity = Label(GUI, text='Quantity', font=('Aagsana New',16)) LQuantity.pack(padx=5,pady=5) EQuantity = ttk.Entry(GUI, textvariable=quantity,font=('Aagsana New',16)) EQuantity.pack(padx=5,pady=5)
def openUpdateFrame(): if (viewFrame): viewFrame.grid_forget() if (insertFrame): insertFrame.grid_forget() if (deleteFrame): deleteFrame.grid_forget() if (updateFrame2): updateFrame2.grid_forget() classNameUpdateLabel = ttk.Label(updateFrame, text='Class') classNameUpdateLabel.grid(row='2', column='0') classNameUpdateEntry = ttk.Entry(updateFrame) classNameUpdateEntry.grid(row='2', column='1') rollNumberUpdateLabel = ttk.Label(updateFrame, text='Roll No') rollNumberUpdateLabel.grid(row='3', column='0') rollNumberUpdateEntry = ttk.Entry(updateFrame) rollNumberUpdateEntry.grid(row='3', column='1') classNameUpdateFrameValue = classNameUpdateEntry.get().lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() def openUpdateFrame3(): if (classNameUpdateEntry.get() != '' and rollNumberUpdateEntry.get() != ''): if (updateFrame): updateFrame.grid_forget() def openFnameUpdateWindow(): fnameUpdateWindow = Tk() fnameUpdateWindow.title('Update First Name') # fnameUpdateWindow.geometry('400x100') fnameUpdateLabel = ttk.Label(fnameUpdateWindow, text='First Name') fnameUpdateLabel.grid() fnameUpdateEntry = ttk.Entry(fnameUpdateWindow) fnameUpdateEntry.grid() def fnameUpdate(): classNameUpdateFrameValue = classNameUpdateEntry.get( ).lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() fnameUpdateValue = fnameUpdateEntry.get().lower() if (fnameUpdateEntry.get() != ''): cursor.execute( """UPDATE ORIGIN SET FNAME=%s WHERE CLASS=%s AND ROLLNO=%s; """, (fnameUpdateValue, classNameUpdateFrameValue, rollNumberUpdateFrameValue)) connection.commit() fnameUpdateEntry.delete(0, 'end') fnameUpdateWindow.destroy() fnameUpdateButton = ttk.Button(fnameUpdateWindow, text='Update', command=fnameUpdate) fnameUpdateButton.grid() fnameUpdateWindow.mainloop() def openLnameUpdateWindow(): lnameUpdateWindow = Tk() lnameUpdateWindow.title('Update Last Name') lnameUpdateLabel = ttk.Label(lnameUpdateWindow, text='Last Name') lnameUpdateLabel.grid() lnameUpdateEntry = ttk.Entry(lnameUpdateWindow) lnameUpdateEntry.grid() def lnameUpdate(): classNameUpdateFrameValue = classNameUpdateEntry.get( ).lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() lnameUpdateValue = lnameUpdateEntry.get().lower() if (lnameUpdateEntry.get() != ''): cursor.execute( """UPDATE ORIGIN SET LNAME=%s WHERE CLASS=%s AND ROLLNO=%s; """, (lnameUpdateValue, classNameUpdateFrameValue, rollNumberUpdateFrameValue)) connection.commit() lnameUpdateEntry.delete(0, 'end') lnameUpdateWindow.destroy() lnameUpdateButton = ttk.Button(lnameUpdateWindow, text='Update', command=lnameUpdate) lnameUpdateButton.grid() lnameUpdateWindow.mainloop() def openClassNameUpdateWindow(): classNameUpdateWindow = Tk() classNameUpdateWindow.title('Update Class Name') classNameUpdateLabel = ttk.Label(classNameUpdateWindow, text='Class Name') classNameUpdateLabel.grid() classNameUpdateEntry = ttk.Entry(classNameUpdateWindow) classNameUpdateEntry.grid() def classNameUpdate(): classNameUpdateFrameValue = classNameUpdateEntry.get( ).lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() classNameUpdateValue = classNameUpdateEntry.get().lower() if (classNameUpdateEntry.get() != ''): cursor.execute( """UPDATE ORIGIN SET CLASS=%s WHERE CLASS=%s AND ROLLNO=%s; """, (classNameUpdateValue, classNameUpdateFrameValue, rollNumberUpdateFrameValue)) connection.commit() classNameUpdateEntry.delete(0, 'end') classNameUpdateWindow.destroy() classNameUpdateButton = ttk.Button(classNameUpdateWindow, text='Update', command=classNameUpdate) classNameUpdateButton.grid() classNameUpdateWindow.mainloop() def openRollNumberUpdateWindow(): rollNumberUpdateWindow = Tk() rollNumberUpdateWindow.title('Update RDll Number') rollNumberUpdateLabel = ttk.Label(rollNumberUpdateWindow, text='Roll Number Name') rollNumberUpdateLabel.grid() rollNumberUpdateEntry = ttk.Entry(rollNumberUpdateWindow) rollNumberUpdateEntry.grid() def rollNumberUpdate(): classNameUpdateFrameValue = classNameUpdateEntry.get( ).lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() rollNumberUpdateValue = rollNumberUpdateEntry.get().lower() if (rollNumberUpdateEntry.get() != ''): cursor.execute( """UPDATE ORIGIN SET ROLLNO=%s WHERE CLASS=%s AND ROLLNO=%s; """, (rollNumberUpdateValue, classNameUpdateFrameValue, rollNumberUpdateFrameValue)) connection.commit() rollNumberUpdateEntry.delete(0, 'end') rollNumberUpdateWindow.destroy() rollNumberUpdateButton = ttk.Button(rollNumberUpdateWindow, text='Update', command=rollNumberUpdate) rollNumberUpdateButton.grid() rollNumberUpdateWindow.mainloop() def openProjectNameUpdateWindow(): projectNameUpdateWindow = Tk() projectNameUpdateWindow.title('Update Project Name') projectNameUpdateLabel = ttk.Label(projectNameUpdateWindow, text='Project Name') projectNameUpdateLabel.grid() projectNameUpdateEntry = ttk.Entry(projectNameUpdateWindow) projectNameUpdateEntry.grid() def projectNameUpdate(): classNameUpdateFrameValue = classNameUpdateEntry.get( ).lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() projectNameUpdateValue = projectNameUpdateEntry.get( ).lower() if (projectNameUpdateEntry.get() != ''): cursor.execute( """UPDATE ORIGIN SET PROJECTNAME=%s WHERE CLASS=%s AND ROLLNO=%s; """, (projectNameUpdateValue, classNameUpdateFrameValue, rollNumberUpdateFrameValue)) connection.commit() projectNameUpdateEntry.delete(0, 'end') projectNameUpdateWindow.destroy() projectNameUpdateButton = ttk.Button(projectNameUpdateWindow, text='Update', command=projectNameUpdate) projectNameUpdateButton.grid() projectNameUpdateWindow.mainloop() def openContactNumberUpdateWindow(): contactNumberUpdateWindow = Tk() contactNumberUpdateWindow.title('Update Contact Number') contactNumberUpdateLabel = ttk.Label(contactNumberUpdateWindow, text='Contact Number') contactNumberUpdateLabel.grid() contactNumberUpdateEntry = ttk.Entry(contactNumberUpdateWindow) contactNumberUpdateEntry.grid() def contactNumberUpdate(): classNameUpdateFrameValue = classNameUpdateEntry.get( ).lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() contactNumberUpdateValue = contactNumberUpdateEntry.get( ).lower() if (contactNumberUpdateEntry.get() != ''): cursor.execute( """UPDATE ORIGIN SET MOBILENUMBER=%s WHERE CLASS=%s AND ROLLNO=%s; """, (contactNumberUpdateValue, classNameUpdateFrameValue, rollNumberUpdateFrameValue)) connection.commit() contactNumberUpdateEntry.delete(0, 'end') contactNumberUpdateWindow.destroy() contactNumberUpdateButton = ttk.Button( contactNumberUpdateWindow, text='Update', command=contactNumberUpdate) contactNumberUpdateButton.grid() contactNumberUpdateWindow.mainloop() def openEmailIdUpdateWindow(): emailIdUpdateWindow = Tk() emailIdUpdateWindow.title('Update Email ID') emailIdUpdateLabel = ttk.Label(emailIdUpdateWindow, text='Email ID') emailIdUpdateLabel.grid() emailIdUpdateEntry = ttk.Entry(emailIdUpdateWindow) emailIdUpdateEntry.grid() def emailIdUpdate(): classNameUpdateFrameValue = classNameUpdateEntry.get( ).lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() emailIdUpdateValue = emailIdUpdateEntry.get().lower() if (emailIdUpdateEntry.get() != ''): cursor.execute( """UPDATE ORIGIN SET EMAILID=%s WHERE CLASS=%s AND ROLLNO=%s; """, (emailIdUpdateValue, classNameUpdateFrameValue, rollNumberUpdateFrameValue)) connection.commit() emailIdUpdateEntry.delete(0, 'end') emailIdUpdateWindow.destroy() emailIdUpdateButton = ttk.Button(emailIdUpdateWindow, text='Update', command=emailIdUpdate) emailIdUpdateButton.grid() emailIdUpdateWindow.mainloop() fnameUpdate2Button = ttk.Button(updateFrame2, text='First Name', command=openFnameUpdateWindow) fnameUpdate2Button.grid() lnameUpdate2Button = ttk.Button(updateFrame2, text='Last Name', command=openLnameUpdateWindow) lnameUpdate2Button.grid() classNameUpdate2Button = ttk.Button( updateFrame2, text='Class Name', command=openClassNameUpdateWindow) classNameUpdate2Button.grid() rollNumberUpdate2Button = ttk.Button( updateFrame2, text='Roll no.', command=openRollNumberUpdateWindow) rollNumberUpdate2Button.grid() projectNameUpdate2Button = ttk.Button( updateFrame2, text='Project Name', command=openProjectNameUpdateWindow) projectNameUpdate2Button.grid() contactNumberUpdate2Button = ttk.Button( updateFrame2, text='Contact no.', command=openContactNumberUpdateWindow) contactNumberUpdate2Button.grid() emailIdUpdate2Button = ttk.Button(updateFrame2, text='Email ID', command=openEmailIdUpdateWindow) emailIdUpdate2Button.grid() updateFrame2.grid() def openUpdateFrame2(): if (classNameUpdateEntry.get() != '' and rollNumberUpdateEntry.get() != ''): if (updateFrame): updateFrame.grid_forget() def openFnameUpdateWindow(): fnameUpdateWindow = Tk() fnameUpdateWindow.title('Update First Name') # fnameUpdateWindow.geometry('400x100') fnameUpdateLabel = ttk.Label(fnameUpdateWindow, text='First Name') fnameUpdateLabel.grid() fnameUpdateEntry = ttk.Entry(fnameUpdateWindow) fnameUpdateEntry.grid() def fnameUpdate(): classNameUpdateFrameValue = classNameUpdateEntry.get( ).lower() rollNumberUpdateFrameValue = rollNumberUpdateEntry.get() fnameUpdateValue = fnameUpdateEntry.get().lower() fnameUpdateButton = ttk.Button(fnameUpdateWindow, text='Update') fnameUpdateButton.grid() fnameUpdateWindow.mainloop() def openLnameUpdateWindow(): lnameUpdateWindow = Tk() lnameUpdateWindow.title('Update Last Name') lnameUpdateLabel = ttk.Label(lnameUpdateWindow, text='Last Name') lnameUpdateLabel.grid() lnameUpdateEntry = ttk.Entry(lnameUpdateWindow) lnameUpdateEntry.grid() lnameUpdateButton = ttk.Button(lnameUpdateWindow, text='Update') lnameUpdateButton.grid() lnameUpdateWindow.mainloop() def openClassNameUpdateWindow(): classNameUpdateWindow = Tk() classNameUpdateWindow.title('Update Class Name') classNameameUpdateLabel = ttk.Label(classNameUpdateWindow, text='Class Name') classNameameUpdateLabel.grid() classNameameUpdateEntry = ttk.Entry(classNameUpdateWindow) classNameameUpdateEntry.grid() classNameameUpdateButton = ttk.Button(classNameUpdateWindow, text='Update') classNameameUpdateButton.grid() classNameUpdateWindow.mainloop() def openRollNumberUpdateWindow(): rollNumberUpdateWindow = Tk() rollNumberUpdateWindow.title('Update RDll Number') rollNumberUpdateLabel = ttk.Label(rollNumberUpdateWindow, text='Roll Number Name') rollNumberUpdateLabel.grid() rollNumberUpdateEntry = ttk.Entry(rollNumberUpdateWindow) rollNumberUpdateEntry.grid() rollNumberUpdateButton = ttk.Button(rollNumberUpdateWindow, text='Update') rollNumberUpdateButton.grid() rollNumberUpdateWindow.mainloop() def openProjectNameUpdateWindow(): projectNameUpdateWindow = Tk() projectNameUpdateWindow.title('Update Project Name') projectNameUpdateLabel = ttk.Label(projectNameUpdateWindow, text='Project Name') projectNameUpdateLabel.grid() projectNameUpdateEntry = ttk.Entry(projectNameUpdateWindow) projectNameUpdateEntry.grid() projectNameUpdateButton = ttk.Button(projectNameUpdateWindow, text='Update') projectNameUpdateButton.grid() projectNameUpdateWindow.mainloop() def openContactNumberUpdateWindow(): contactNumberUpdateWindow = Tk() contactNumberUpdateWindow.title('Update Contact Number') contactNumberUpdateLabel = ttk.Label(contactNumberUpdateWindow, text='Contact Number') contactNumberUpdateLabel.grid() contactNumberUpdateEntry = ttk.Entry(contactNumberUpdateWindow) contactNumberUpdateEntry.grid() contactNumberUpdateButton = ttk.Button( contactNumberUpdateWindow, text='Update') contactNumberUpdateButton.grid() contactNumberUpdateWindow.mainloop() def openEmailIdUpdateWindow(): emailIdUpdateWindow = Tk() emailIdUpdateWindow.title('Update Email ID') emailIdUpdateLabel = ttk.Label(emailIdUpdateWindow, text='Email ID') emailIdUpdateLabel.grid() emailIdUpdateEntry = ttk.Entry(emailIdUpdateWindow) emailIdUpdateEntry.grid() emailIdUpdateButton = ttk.Button(emailIdUpdateWindow, text='Update') emailIdUpdateButton.grid() emailIdUpdateWindow.mainloop() fnameUpdate2Button = ttk.Button(updateFrame2, text='First Name', command=openFnameUpdateWindow) fnameUpdate2Button.grid() lnameUpdate2Button = ttk.Button(updateFrame2, text='Last Name', command=openLnameUpdateWindow) lnameUpdate2Button.grid() classNameUpdate2Button = ttk.Button( updateFrame2, text='Class Name', command=openClassNameUpdateWindow) classNameUpdate2Button.grid() rollNumberUpdate2Button = ttk.Button( updateFrame2, text='Roll no.', command=openRollNumberUpdateWindow) rollNumberUpdate2Button.grid() projectNameUpdate2Button = ttk.Button( updateFrame2, text='Project Name', command=openProjectNameUpdateWindow) projectNameUpdate2Button.grid() contactNumberUpdate2Button = ttk.Button( updateFrame2, text='Contact no.', command=openContactNumberUpdateWindow) contactNumberUpdate2Button.grid() emailIdUpdate2Button = ttk.Button(updateFrame2, text='Email ID', command=openEmailIdUpdateWindow) emailIdUpdate2Button.grid() updateFrame2.grid() okkkkkUpdateButton = ttk.Button(updateFrame, text='Okkkkk', command=openUpdateFrame3) okkkkkUpdateButton.grid(row='7', columnspan='2') updateFrame.grid()
import tkinter as obj from tkinter import ttk from csv import DictWriter import os win = obj.Tk() #----addTitle win.title('GUI TEsting') #-----addLable ttk.Label(win, text='Enter You name').grid( row=0, column=0, sticky=obj.W) #pack() #grid(row=0,colonm=2) #-------takingInput and store to a variable name_input = obj.StringVar() ttk.Entry(win, width=16, textvariable=name_input).grid(row=0, column=1, sticky=obj.W) #----addLable ttk.Label(win, text='What Is Your Age').grid( row=1, column=0, sticky=obj.W) #both lable are not in same line so vo use sticky age_input = obj.StringVar() ttk.Entry(win, width=16, textvariable=age_input).grid(row=1, column=1, sticky=obj.W) ttk.Label(win, text='Enter You E-Mail').grid(row=2, column=0, sticky=obj.W) email_input = obj.StringVar() ttk.Entry(win, width=16, textvariable=email_input).grid(row=2, column=1)
def newGst(username, switches, onosUrl, onosUsr, onosPwd): gstForm = tk.Toplevel() gstForm.geometry("400x450") tk.Tk.resizable(gstForm, width=False, height=False) pageTitle = tk.Label(gstForm, text=" New network slice", font=LARGE_FONT, height=2) pageTitle.grid(row=0, column=1, columnspan=6) # Slice Name tk.Label(gstForm, text=" Network slice name: ").grid(row=1, column=2, sticky="w") entrySliceName = ttk.Entry(gstForm, width=20) entrySliceName.grid(row=1, column=3, sticky="w", columnspan=5) # Slice Industry industryList = [ "None", "None", "Virtual Reality", "Automotive", "Energy", "Healthcare", "Industry 4.0", "IoT", "Public safety", ] tk.Label(gstForm, text=" Slice industry: ").grid(row=2, column=2, sticky="w") clickIndustry = tk.StringVar() clickIndustry.set(industryList[0]) dropIndustryList = ttk.OptionMenu(gstForm, clickIndustry, *industryList) dropIndustryList.grid(row=2, column=3, sticky="w", columnspan=4) # Rate limit slice tk.Label(gstForm, text=" Rate limit (empty if none): ").grid(row=4, column=2, sticky="w") rateLimitSlice = ttk.Entry(gstForm, width=12) rateLimitSlice.grid(row=4, column=3, sticky="w") tk.Label(gstForm, text="kbps").grid(row=4, column=4, sticky="w") # Rate limit hosts tk.Label(gstForm, text=" Hosts (IPs split by commas): ").grid(row=5, column=2, sticky="w") rateLimitHosts = ttk.Entry(gstForm, width=25) rateLimitHosts.grid(row=5, column=3, columnspan=15) # Slice User data access userDataList = [ "0 - Internet (default)", "0 - Internet (default)", "1 - Private network", "2 - No traffic", ] tk.Label(gstForm, text=" User data access: ").grid(row=7, column=2, sticky="w") userDataslice = tk.StringVar() userDataslice.set(userDataList[0]) dropList = ttk.OptionMenu(gstForm, userDataslice, *userDataList) dropList.grid(row=7, column=3, sticky="w", columnspan=3) # Input host IPs tk.Label(gstForm, text=" Hosts (IPs split by commas): ").grid(row=8, column=2, sticky="w") userDataHosts = ttk.Entry(gstForm, width=25) userDataHosts.grid(row=8, column=3, columnspan=15) # Export GST exportGST = tk.IntVar() exportCheck = tk.Checkbutton(gstForm, text="Export GST", variable=exportGST) exportCheck.grid(row=10, column=3, columnspan=4, sticky="w") # Create Network slice createNetSlice = tk.IntVar() netSliceCheck = tk.Checkbutton(gstForm, text="Create Network Slice", variable=createNetSlice) netSliceCheck.grid(row=11, column=3, columnspan=4, sticky="w") # Action buttons buttonExit = ttk.Button(gstForm, text="Cancel", command=gstForm.destroy) buttonExit.grid(row=14, column=3, sticky="e") buttonCreate = ttk.Button(gstForm, text="Create", command=lambda: confirmGst(username, entrySliceName.get(), clickIndustry.get(), rateLimitSlice.get(), \ rateLimitHosts.get(), userDataslice.get(), userDataHosts.get(), exportGST.get(), createNetSlice.get(), switches, onosUrl, onosUsr, onosPwd)) buttonCreate.grid(row=14, column=4, sticky="e") def confirmGst(username, sliceName, industry, rateLimit, rateLimitHosts, userDataAccess, userDataHosts, exportGST, createNetSlice, switches, onosUrl, onosUsr, onosPwd): warningLabel = tk.Label(gstForm, text="") errorLabel = createGst(username, sliceName, industry, rateLimit, rateLimitHosts, userDataAccess, userDataHosts, exportGST, createNetSlice, switches, onosUrl, onosUsr, onosPwd) warningLabel = tk.Label(gstForm, text=errorLabel) warningLabel.grid(row=13, column=1, columnspan=7, sticky='w') if errorLabel == "Success! ": gstForm.destroy() # GUI formatting gstForm.grid_rowconfigure(0, minsize=60) gstForm.grid_rowconfigure(1, minsize=30) gstForm.grid_rowconfigure(2, minsize=30) gstForm.grid_rowconfigure(3, minsize=30) gstForm.grid_rowconfigure(4, minsize=30) gstForm.grid_rowconfigure(5, minsize=30) gstForm.grid_rowconfigure(6, minsize=30) gstForm.grid_rowconfigure(7, minsize=30) gstForm.grid_rowconfigure(8, minsize=30) gstForm.grid_rowconfigure(9, minsize=30) gstForm.grid_rowconfigure(10, minsize=20) gstForm.grid_rowconfigure(11, minsize=20) gstForm.grid_rowconfigure(12, minsize=20) gstForm.grid_rowconfigure(13, minsize=20) gstForm.grid_rowconfigure(14, minsize=20)
def SizeMonteCarloFrame(self, f): startRow = 3 for w in f.grid_slaves(): if int(w.grid_info()['row']) > 2: w.grid_forget() col1 = f.children['cb1'].get() col2 = f.children['cb2'].get() col3 = f.children['cb3'].get() use1 = col1 != 'None' use2 = col2 != 'None' use3 = col3 != 'None' band1 = 'Mid' in col1 band2 = 'Mid' in col2 band3 = 'Mid' in col3 lab = ttk.Label(f, text='Case #', relief=tk.RIDGE) lab.grid(row=startRow + 1, column=0, sticky=tk.NSEW) lab = ttk.Label(f, text=col1, relief=tk.RIDGE) lab.grid(row=startRow - 1, column=1, sticky=tk.NSEW) lab = ttk.Label(f, text=col2, relief=tk.RIDGE) lab.grid(row=startRow - 1, column=2, sticky=tk.NSEW) lab = ttk.Label(f, text=col3, relief=tk.RIDGE) lab.grid(row=startRow - 1, column=3, sticky=tk.NSEW) lab = ttk.Label(f, text='Band', relief=tk.RIDGE) lab.grid(row=startRow, column=0, sticky=tk.NSEW) if band1: w1 = ttk.Entry(f) w1.insert(0, config['MonteCarloCase']['Band1']) else: w1 = ttk.Label(f, text='n/a', relief=tk.RIDGE) if band2: w2 = ttk.Entry(f) w2.insert(0, config['MonteCarloCase']['Band2']) else: w2 = ttk.Label(f, text='n/a', relief=tk.RIDGE) if band3: w3 = ttk.Entry(f) w3.insert(0, config['MonteCarloCase']['Band3']) else: w3 = ttk.Label(f, text='n/a', relief=tk.RIDGE) w1.grid(row=startRow, column=1, sticky=tk.NSEW) w2.grid(row=startRow, column=2, sticky=tk.NSEW) w3.grid(row=startRow, column=3, sticky=tk.NSEW) n = int(config['MonteCarloCase']['NumCases']) for i in range(n): lab = ttk.Label(f, text=str(i + 1), relief=tk.RIDGE) lab.grid(row=i + 2 + startRow, column=0, sticky=tk.NSEW) if use1: w1 = ttk.Entry(f) w1.insert(0, config['MonteCarloCase']['Samples1'][i]) else: w1 = ttk.Label(f, text='n/a', relief=tk.RIDGE) if use2: w2 = ttk.Entry(f) w2.insert(0, config['MonteCarloCase']['Samples2'][i]) else: w2 = ttk.Label(f, text='n/a', relief=tk.RIDGE) if use3: w3 = ttk.Entry(f) w3.insert(0, config['MonteCarloCase']['Samples3'][i]) else: w3 = ttk.Label(f, text='n/a', relief=tk.RIDGE) w1.grid(row=i + 2 + startRow, column=1, sticky=tk.NSEW) w2.grid(row=i + 2 + startRow, column=2, sticky=tk.NSEW) w3.grid(row=i + 2 + startRow, column=3, sticky=tk.NSEW)
heart = True win = tk.Tk() win.title("youtube music downloader for android") label_001 = ttk.Label(win, text="enter full URLs or youtube playlists for audio download below:") label_001.grid(column=1, row=0) label_002 = ttk.Label(win, text="Status: ") label_002.grid(column=0, row=3) label_005 = ttk.Label(win, text="audio downloader v 0.1") label_005.grid(column=0, row=7) name_os = tk.StringVar() name_field_os = ttk.Entry(win, width=80, textvariable=name_os) name_field_os.grid(column=0, row=12) def clickMe(): global heart if len(name_os.get()) > 4: os.chdir(rf'{name_os.get()}') else: os.chdir(r'C:\youtube-dl') button_002.configure(text=f"clicked!") label_001.configure(foreground='red', text='downloading now...') label_004.configure(foreground='blue', text='Currently downloading, please wait...')
current_rows += 1 ttk.Label(window, text='').grid(row=current_rows, columnspan=3, sticky=tk.W) current_rows += 1 label = ttk.Label( window, text=record_question, # 标签的文字 width=80, # 标签长宽 ) label.grid(row=current_rows, columnspan=3) # 固定窗口位置 current_rows += 1 ttk.Label(window, text='局点信息:').grid(row=current_rows, column=0, padx=5, pady=2, sticky=tk.E) ttk.Entry(window, textvariable=view_string_site, width=27).grid(row=current_rows, column=1, sticky=tk.W) current_rows += 1 ttk.Label(window, text='icare单号:').grid(row=current_rows, column=0, padx=5, pady=2, sticky=tk.E) ttk.Entry(window, textvariable=view_string_icare, width=27).grid(row=current_rows, column=1, sticky=tk.W) current_rows += 1 ttk.Label(window, text='问题描述:').grid(row=current_rows, column=0, padx=5, pady=2, sticky=tk.E) ttk.Entry(window, textvariable=view_string_question,
age_label = ttk.Label(win, text="ENTER THE AGE : ") age_label.grid(row=4, column=0, sticky=tk.W) address_label = ttk.Label(win, text="ENTER THE ADDRESS : ") address_label.grid(row=5, column=0, sticky=tk.W) Parents_name_label = ttk.Label(win, text="ENTER THE FATHER'S NAME : ") Parents_name_label.grid(row=6, column=0, sticky=tk.W) gender_label = ttk.Label(win, text="SELECT THE GENDER : ") gender_label.grid(row=7, column=0, sticky=tk.W) # 2. create entry box . id_var = tk.IntVar() id_entrybox = ttk.Entry(win, width=20, text=id_var) id_entrybox.grid(row=1, column=2) id_entrybox.focus() name_var = tk.StringVar() name_entrybox = ttk.Entry(win, width=20, textvariable=name_var) name_entrybox.grid(row=2, column=2) email_var = tk.StringVar() email_entrybox = ttk.Entry(win, width=20, textvariable=email_var) email_entrybox.grid(row=3, column=2) age_var = tk.IntVar() age_entrybox = ttk.Entry(win, width=20, text=age_var) age_entrybox.grid(row=4, column=2)
def __init__(self, root): self.root = root self.root.title("Opencv 控制台") self.root.geometry('870x500') # 左侧文本框 self.scltxt = scrolledtext.ScrolledText(root, width=60, height=38, wrap=WORD) self.scltxt.place(x=0, y=0) # 初始化 ttk.Button(root, text="初始化", command=self.init).place(x=450, y=30) ttk.Button(root, text="打开监视器", command=self.monitor).place(x=630, y=30) ttk.Button(root, text="心电开", command=self.ECG).place(x=760, y=30) ttk.Label(root, text="手动设置", font=('16')).place(x=450, y=70) # 输入旋转 ttk.Label(root, text="转角:(顺时针为正)").place(x=450, y=100) self.angle = ttk.Entry(root, width=12) self.angle.place(x=630, y=100) # 输入放缩量 ttk.Label(root, text="左右放缩:").place(x=450, y=125) self.scal_x = ttk.Entry(root, width=12) self.scal_x.place(x=630, y=125) ttk.Label(root, text="前后放缩:").place(x=450, y=150) self.scal_y = ttk.Entry(root, width=12) self.scal_y.place(x=630, y=150) # 输入模糊量 ttk.Label(root, text="模糊度:(1最清晰,<60)").place(x=450, y=175) self.dim = ttk.Entry(root, width=12) self.dim.place(x=630, y=175) # 输入前后平移量 ttk.Label(root, text="平移:(前正后负)").place(x=450, y=200) self.deepth = ttk.Entry(root, width=12) self.deepth.place(x=630, y=200) # 输入左右平移量 ttk.Label(root, text="平移:(右正左负)").place(x=450, y=225) self.lateral = ttk.Entry(root, width=12) self.lateral.place(x=630, y=225) # 选择手or木头 self.hand = IntVar() self.hand.set(0) # 默认是手 ttk.Label(root, text="显示:").place(x=450, y=275) self.hand_slt = Radiobutton(root, text='手', variable=self.hand, value=0) # , command=handset) self.hand_slt.place(x=560, y=274) self.wood_slt = Radiobutton(root, text='木头', variable=self.hand, value=1) # , command=handset) self.wood_slt.place(x=609, y=274) self.wood_slt = Radiobutton(root, text='空白', variable=self.hand, value=2) # , command=handset) self.wood_slt.place(x=670, y=274) # 设置延时时间 ttk.Label(root, text="延时:(毫秒)").place(x=450, y=250) self.delay = ttk.Entry(root, width=12) self.delay.place(x=630, y=250) # 确认,把修改值传递到cvImg set = ttk.Button(master=root, text="确认", width=10, command=self.setting) set.place(x=760, y=99, relheight=0.39, relwidth=0.1) # 猴子设定 ttk.Label(root, text="被试特征", font='16').place(x=450, y=325) # 默认80,数字本身无物理意义,越小越慢,越大越快 ttk.Label(root, text="行动速度:").place(x=450, y=350) self.speed = ttk.Entry(root, width=12) self.speed.place(x=630, y=350) # 默认40,代表毛发灰度值,越小颜色越浅,越大颜色越深 ttk.Label(root, text="表面颜色:").place(x=450, y=375) self.color = ttk.Entry(root, width=12) self.color.place(x=630, y=375) set = ttk.Button(master=root, text="确认", width=10, command=self.character) set.place(x=760, y=349, relheight=0.1, relwidth=0.1) # MATLAB监听 ttk.Label(root, text="用MATLAB控制", font='16').place(x=450, y=425) ttk.Button(root, text="开始监听", command=self.listen).place(x=450, y=455) ttk.Button(root, text="清屏", command=self.clear).place(x=630, y=455) ttk.Button(master=root, text='退出', command=self._quit).place(x=760, y=455)
frm=tkinter.Tk() frm.title("Test Framework") w=700 h=500 sw=frm.winfo_screenwidth() sh=frm.winfo_screenheight() x=(sw-w)/2 y=(sh-h)/2 frm.geometry('%dx%d+%d+%d' % (w,h,x,y)) frm.config(background='#424242') load=Image.open('pic1.jpg') load=load.resize((700,500),Image.ANTIALIAS) render=ImageTk.PhotoImage(load) img=ttk.Label(frm,image=render) img.place(x=0,y=0) lbl1=ttk.Label(frm,text='Automation Framework') lbl1.grid(row=2,column=2) lbl1.config(background='#B0BEC5',font=('impact',20)) lbl2=ttk.Label(frm,text='ChromePath') lbl2.grid(row=4,column=0) txt1=ttk.Entry(frm) txt1.grid(row=4,column=1) lbl3=ttk.Label(frm,text='Folderpath') lbl3.grid(row=5,column=0) txt2=ttk.Entry(frm) txt2.grid(row=5,column=1) btn=ttk.Button(frm,text='Start',command=text) btn.place(x=200,y=200) frm.mainloop()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) fuente = font.Font(weight='bold') self.motor = MotorLogico("basepruebas.tsv", [], []) self.motor.load_db() self.etiq1 = ttk.Label(self, text='Palabra 1:', font=fuente) self.etiq2 = ttk.Label(self, text='Palabra 2:', font=fuente) self.etiq3 = ttk.Label(self, text='Operaciones:', font=fuente) self.etiq4 = ttk.Label(self, text='Relaciones:', font=fuente) self.radio = StringVar() self.radio_etymological_origin_of_txt = StringVar() self.radio_has_derived_from_txt = StringVar() self.radio_is_derived_from_txt = StringVar() self.radio_etymology_txt = StringVar() self.radio_etymologically_related_txt = StringVar() self.radio_variant_orthography_txt = StringVar() self.radio_derived_txt = StringVar() self.radio_etymologically_txt = StringVar() self.radio_etymological_origin_of_txt.set("n") self.radio_has_derived_from_txt.set("n") self.radio_is_derived_from_txt.set("n") self.radio_etymology_txt.set("n") self.radio_etymologically_related_txt.set("n") self.radio_variant_orthography_txt.set("n") self.radio_derived_txt.set("n") self.radio_etymologically_txt.set("n") self.salida_operacion = Text(self, width=50, height=15) self.salida_operacion.place(relx=0.06, rely=0.3) self.radio_hermanos = ttk.Checkbutton(self, text="¿Son hermanos?", variable=self.radio, onvalue="Hermanos", offvalue="") self.radio_primos = ttk.Checkbutton(self, text="¿Son primos?", variable=self.radio, onvalue="Primos", offvalue="") self.radio_hijos = ttk.Checkbutton( self, text="¿Palabra2 es hija de Palabra1?", variable=self.radio, onvalue="Hija", offvalue="") self.radio_tio = ttk.Checkbutton(self, text="¿Palabra1 es tía de Palabra2?", variable=self.radio, onvalue="Tio", offvalue="") self.radio_primos_grado = ttk.Checkbutton( self, text="¿Son primos, en qué grado?", variable=self.radio, onvalue="PrimosGrado", offvalue="") self.radio_etymological_origin_of = ttk.Checkbutton( self, text="rel:etymological_origin_of", variable=self.radio_etymological_origin_of_txt, onvalue="rel:etymological_origin_of", offvalue="n") self.radio_has_derived_from = ttk.Checkbutton( self, text="rel:has_derived_form", variable=self.radio_has_derived_from_txt, onvalue="rel:has_derived_form", offvalue="n") self.radio_is_derived_from = ttk.Checkbutton( self, text="rel:is_derived_from", variable=self.radio_is_derived_from_txt, onvalue="rel:is_derived_from", offvalue="n") self.radio_etymology = ttk.Checkbutton( self, text="rel:etymology", variable=self.radio_etymology_txt, onvalue="rel:etymology", offvalue="n") self.radio_etymologically_related = ttk.Checkbutton( self, text="rel:etymologically_related", variable=self.radio_etymologically_related_txt, onvalue="rel:etymologically_related", offvalue="n") self.radio_variant_orthography = ttk.Checkbutton( self, text="rel:variant:orthography", variable=self.radio_variant_orthography_txt, onvalue="rel:variant:orthography", offvalue="n") self.radio_derived = ttk.Checkbutton(self, text="rel:derived", variable=self.radio_derived_txt, onvalue="rel:derived", offvalue="n") self.radio_etymologically = ttk.Checkbutton( self, text="rel:etymologically", variable=self.radio_etymologically_txt, onvalue="rel:etymologically", offvalue="n") self.radio_hermanos.place(relx=0.7, rely=0.1) self.radio_primos.place(relx=0.7, rely=0.15) self.radio_hijos.place(relx=0.7, rely=0.2) self.radio_tio.place(relx=0.7, rely=0.25) self.radio_primos_grado.place(relx=0.7, rely=0.3) self.radio_etymological_origin_of.place(relx=0.7, rely=0.5) self.radio_has_derived_from.place(relx=0.7, rely=0.55) self.radio_is_derived_from.place(relx=0.7, rely=0.6) self.radio_etymology.place(relx=0.7, rely=0.65) self.radio_etymologically_related.place(relx=0.7, rely=0.7) self.radio_variant_orthography.place(relx=0.7, rely=0.75) self.radio_derived.place(relx=0.7, rely=0.8) self.radio_etymologically.place(relx=0.7, rely=0.85) self.palabra1 = StringVar() self.palabra2 = StringVar() self.entrada_palabra1 = ttk.Entry(self, textvariable=self.palabra1, width=30) self.entrada_palabra2 = ttk.Entry(self, textvariable=self.palabra2, width=30) self.separ = ttk.Separator(self, orient=HORIZONTAL) self.boton1 = ttk.Button(self, text="Realizar operación", command=self.operar) self.boton2 = ttk.Button(self, text="Cancelar", command=quit) self.boton_abrir_archivo = ttk.Button(self, text="Abrir base", command=self.abrir_archivo) self.boton_abrir_archivo.place(relx=0.06, rely=0.23) self.entrada_palabra1.place(relx=0.1, rely=0.1) self.entrada_palabra2.place(relx=0.4, rely=0.1) self.boton1.place(relx=0.30, rely=0.2) self.etiq1.place(relx=0.1, rely=0.03) self.etiq2.place(relx=0.4, rely=0.03) self.etiq3.place(relx=0.7, rely=0.05) self.etiq4.place(relx=0.7, rely=0.45)
curr1 = StringVar() curr2 = StringVar() amount = IntVar() label = ttk.Label(root, text="Welcome To Currency") label.grid(row=0, column=0, columnspan=2, padx=5, pady=10) label_currency1 = ttk.Label(root, text="Enter The Currency Code:") label_currency2 = ttk.Label(root, text="Enter The Currency Code:") label_amount = ttk.Label(root, text="Enter The Amount To Convert:") label_currency1.grid(row=1, column=0, padx=5, pady=10) label_currency2.grid(row=2, column=0, padx=5, pady=10) label_amount.grid(row=3, column=0, padx=5, pady=10) entry_currency1 = ttk.Entry(root, textvariable=curr1) entry_currency2 = ttk.Entry(root, textvariable=curr2) entry_amount = ttk.Entry(root, textvariable=amount) entry_currency1.grid(row=1, column=1, padx=5, pady=10) entry_currency2.grid(row=2, column=1, padx=5, pady=10) entry_amount.grid(row=3, column=1, padx=5, pady=10) button_convert = ttk.Button(root, text="Convert", command=convert) button_convert.grid(row=4, column=0, columnspan=2, padx=5, pady=10) root['background'] = "#f5f6f7" root.resizable(0, 0) root.mainloop()
def openInsertFrame(): if (viewFrame): viewFrame.grid_forget() if (updateFrame): updateFrame.grid_forget() if (updateFrame2): updateFrame2.grid_forget() if (deleteFrame): deleteFrame.grid_forget() # insertFrame = Frame(mainWindow) fnameInsertLabel = ttk.Label(insertFrame, text='First Name') fnameInsertLabel.grid(row='0', column='0') fnameInsertEntry = ttk.Entry(insertFrame) fnameInsertEntry.grid(row='0', column='1') lnameInsertLabel = ttk.Label(insertFrame, text='Last Name') lnameInsertLabel.grid(row='1', column='0') lnameInsertEntry = ttk.Entry(insertFrame) lnameInsertEntry.grid(row='1', column='1') classNameInsertLabel = ttk.Label(insertFrame, text='Class') classNameInsertLabel.grid(row='2', column='0') classNameInsertEntry = ttk.Entry(insertFrame) classNameInsertEntry.grid(row='2', column='1') rollNumberInsertLabel = ttk.Label(insertFrame, text='Roll No') rollNumberInsertLabel.grid(row='3', column='0') rollNumberInsertEntry = ttk.Entry(insertFrame) rollNumberInsertEntry.grid(row='3', column='1') projectNameInsertLabel = ttk.Label(insertFrame, text='Project Name') projectNameInsertLabel.grid(row='4', column='0') projectNameInsertEntry = ttk.Entry(insertFrame) projectNameInsertEntry.grid(row='4', column='1') contactNumberInsertLabel = ttk.Label(insertFrame, text='Contact No') contactNumberInsertLabel.grid(row='5', column='0') contactNumberInsertEntry = ttk.Entry(insertFrame) contactNumberInsertEntry.grid(row='5', column='1') emailIdInsertLabel = ttk.Label(insertFrame, text='Email ID') emailIdInsertLabel.grid(row='6', column='0') emailIdInsertEntry = ttk.Entry(insertFrame) emailIdInsertEntry.grid(row='6', column='1') def insertIntoDB(): fnameInsertFrameValue = fnameInsertEntry.get().lower() lnameInsertFrameValue = lnameInsertEntry.get().lower() classNameInsertFrameValue = classNameInsertEntry.get().lower() rollNumberInsertFrameValue = rollNumberInsertEntry.get() projectNameInsertFrameValue = projectNameInsertEntry.get().lower() contactNumberInsertFrameValue = contactNumberInsertEntry.get() emailIdInsertFrameValue = emailIdInsertEntry.get().lower() if (fnameInsertFrameValue != '' and lnameInsertFrameValue != '' and classNameInsertFrameValue != '' and rollNumberInsertFrameValue != '' and projectNameInsertFrameValue != '' and contactNumberInsertFrameValue != '' and emailIdInsertFrameValue != ''): cursor.execute( 'INSERT INTO ORIGIN (FNAME, LNAME, CLASS, ROLLNO, PROJECTNAME, MOBILENUMBER, EMAILID) VALUES (%s,%s,%s,%s,%s,%s,%s)', (fnameInsertFrameValue, lnameInsertFrameValue, classNameInsertFrameValue, rollNumberInsertFrameValue, projectNameInsertFrameValue, contactNumberInsertFrameValue, emailIdInsertFrameValue)) connection.commit() fnameInsertEntry.delete(0, 'end') lnameInsertEntry.delete(0, 'end') classNameInsertEntry.delete(0, 'end') rollNumberInsertEntry.delete(0, 'end') projectNameInsertEntry.delete(0, 'end') contactNumberInsertEntry.delete(0, 'end') emailIdInsertEntry.delete(0, 'end') else: connection.rollback() insertInsertButton = ttk.Button(insertFrame, text='Insert', command=insertIntoDB) insertInsertButton.grid(row='7', columnspan='2') insertFrame.grid()
weather_conditions_frame = ttk.LabelFrame(tab1, text=' Current Weather Conditions ') weather_conditions_frame.grid(column=0, row=1, padx=8, pady=4) #================ ENTRY_WIDTH = 25 #================ # Adding Label & Textbox Entry widgets #--------------------------------------------- ttk.Label(weather_conditions_frame, text="Last Updated:").grid(column=0, row=1, sticky='E') # <== right-align updated = tk.StringVar() updatedEntry = ttk.Entry(weather_conditions_frame, width=ENTRY_WIDTH, textvariable=updated, state='readonly') updatedEntry.grid(column=1, row=1, sticky='W') #--------------------------------------------- ttk.Label(weather_conditions_frame, text="Weather:").grid(column=0, row=2, sticky='E') # <== increment row for each weather = tk.StringVar() weatherEntry = ttk.Entry(weather_conditions_frame, width=ENTRY_WIDTH, textvariable=weather, state='readonly') weatherEntry.grid(column=1, row=2, sticky='W') # <== increment row for each #--------------------------------------------- ttk.Label(weather_conditions_frame, text="Temperature:").grid(column=0, row=3,
def openViewFrame(): if (insertFrame): insertFrame.grid_forget() if (updateFrame): updateFrame.grid_forget() if (deleteFrame): deleteFrame.grid_forget() if (updateFrame2): updateFrame2.grid_forget() classNameViewLabel = ttk.Label(viewFrame, text='Class') classNameViewLabel.grid(row='2', column='0') classNameViewEntry = ttk.Entry(viewFrame) classNameViewEntry.grid(row='2', column='1') rollNumberViewLabel = ttk.Label(viewFrame, text='Roll No') rollNumberViewLabel.grid(row='3', column='0') rollNumberViewEntry = ttk.Entry(viewFrame) rollNumberViewEntry.grid(row='3', column='1') def viewing(): if (classNameViewEntry.get() != '' and rollNumberViewEntry.get() != ''): classNameViewFrameValue = classNameViewEntry.get().lower() rollNumberViewFrameValue = rollNumberViewEntry.get() cursor.execute( """SELECT * FROM ORIGIN WHERE CLASS=%s AND ROLLNO=%s;""", (classNameViewFrameValue, rollNumberViewFrameValue)) data = cursor.fetchone() # for i in data: # print(i) viewWindow = Tk() fnameViewWindowLabel = ttk.Label(viewWindow, text='First Name') fnameViewWindowLabel.grid(row='0', column='0') fnameViewWindowLabel = ttk.Label(viewWindow, text=data[1]) fnameViewWindowLabel.grid(row='0', column='1') lnameViewWindowLabel = ttk.Label(viewWindow, text='Last Name') lnameViewWindowLabel.grid(row='1', column='0') lnameViewWindowLabel = ttk.Label(viewWindow, text=data[2]) lnameViewWindowLabel.grid(row='1', column='1') classNameViewWindowLabel = ttk.Label(viewWindow, text='Class Name') classNameViewWindowLabel.grid(row='2', column='0') classNameViewWindowLabel = ttk.Label(viewWindow, text=data[3]) classNameViewWindowLabel.grid(row='2', column='1') rollNumberViewWindowLabel = ttk.Label(viewWindow, text='Roll No.') rollNumberViewWindowLabel.grid(row='3', column='0') rollNumberViewWindowLabel = ttk.Label(viewWindow, text=data[4]) rollNumberViewWindowLabel.grid(row='3', column='1') projectNameViewWindowLabel = ttk.Label(viewWindow, text='Project Name') projectNameViewWindowLabel.grid(row='4', column='0') projectNameViewWindowLabel = ttk.Label(viewWindow, text=data[5]) projectNameViewWindowLabel.grid(row='4', column='1') contactNumberViewWindowLabel = ttk.Label(viewWindow, text='Contact No.') contactNumberViewWindowLabel.grid(row='5', column='0') contactNumberViewWindowLabel = ttk.Label(viewWindow, text=data[6]) contactNumberViewWindowLabel.grid(row='5', column='1') emailIdViewWindowLabel = ttk.Label(viewWindow, text='Email ID') emailIdViewWindowLabel.grid(row='6', column='0') emailIdViewWindowLabel = ttk.Label(viewWindow, text=data[7]) emailIdViewWindowLabel.grid(row='6', column='1') viewWindow.mainloop() if (mainWindow.destroy()): viewWindow.destroy() viewViewButton = ttk.Button(viewFrame, text='View', command=viewing) viewViewButton.grid(row='7', columnspan='2') viewFrame.grid()
import tkinter as tk from tkinter import ttk from tkinter import * import webbrowser app = tk.Tk() app.title("Поиск") app.configure(background='#ececec') app_name = ttk.Label(app, text='Поисковое приложение', font='Arial 24 bold') app_name.grid(row=0, column=1) search_label = ttk.Label(app, text='Поиск') search_label.grid(row=1, column=0) text_field = ttk.Entry(app, width=50) text_field.grid(row=1, column=1) search_engine = StringVar() search_engine.set("bing") def search(): if text_field.get().strip() != "": if search_engine.get() == 'google': webbrowser.open('https://www.google.com/search?q=' + text_field.get()) elif search_engine.get() == 'bing': webbrowser.open('https://www.bing.com/search?q=' + text_field.get())
def create_widgets(self, tab_book): tab_fr = ttk.Frame(tab_book, padding=5) tab_book.add(tab_fr, text="Report Entries") entries_fr = ttk.Labelframe(tab_fr, text="Entries", padding=5) entries_fr.grid(row=0, column=0, sticky=(tk.N, tk.S, tk.E, tk.W)) # Entry list and scrollbar entry_list_scroll = ttk.Scrollbar(entries_fr) entry_list_scroll.pack(side=tk.RIGHT, fill=tk.Y) self.entry_list = tk.Listbox(entries_fr, highlightthickness=0, activestyle="none", exportselection=False, selectmode="single") self.entry_list.bind('<<ListboxSelect>>', self.ev_entry_list_select) self.entry_list.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True) self.entry_list.configure(yscrollcommand=entry_list_scroll.set) entry_list_scroll.configure(command=self.entry_list.yview) # Entry List side buttons ent_but_fr = ttk.Frame(entries_fr, padding=5) ent_but_fr.pack(side=tk.LEFT, fill=tk.Y, expand=True) x = ttk.Button(ent_but_fr, text="Add", command=self.pb_new_entry) x.pack(side=tk.TOP) x = ttk.Button(ent_but_fr, text="Delete", command=self.pb_delete_entry) x.pack(side=tk.TOP) x = ttk.Button(ent_but_fr, text="Down", command=self.pb_move_entry_down) x.pack(side=tk.BOTTOM) x = ttk.Button(ent_but_fr, text="Up", command=self.pb_move_entry_up) x.pack(side=tk.BOTTOM) # ------------- Entry Settings Section ------------- self.entry_settings_frame = ttk.Labelframe(tab_fr, text="Entry Settings", padding=5) self.entry_settings_frame.grid(row=0, column=1, sticky=(tk.N, tk.S, tk.E, tk.W)) # Common Settings ent_common_settings_fr = ttk.Frame(self.entry_settings_frame) ent_common_settings_fr.pack(side=tk.TOP, fill=tk.X) x = ttk.Label(ent_common_settings_fr, text="Entry Type") x.grid(row=0, column=0, sticky=(tk.N, tk.E)) self.cmb_ent_type = ttk.Combobox( ent_common_settings_fr, state='readonly', values=report_entries.get_type_names()) self.cmb_ent_type.grid(row=0, column=1, sticky=(tk.N, tk.W, tk.E)) self.cmb_ent_type.bind("<<ComboboxSelected>>", self.cmb_ent_type_Changed) x = ttk.Label(ent_common_settings_fr, text="Entry Name") x.grid(row=1, column=0, sticky=(tk.N, tk.E)) self.txt_ent_name = ttk.Entry( ent_common_settings_fr, validatecommand=self.txt_ent_name_Changed, validate='focusout') self.txt_ent_name.grid(row=1, column=1, sticky=(tk.N, tk.W, tk.E)) ent_common_settings_fr.columnconfigure(1, weight=1) ent_common_settings_fr.columnconfigure(tk.ALL, pad=5) ent_common_settings_fr.rowconfigure(tk.ALL, pad=5) x = ttk.Separator(self.entry_settings_frame) x.pack(side=tk.TOP, fill=tk.X) # Type-Specific Settings self.entry_type_settings_frame = ttk.Frame(self.entry_settings_frame) self.entry_type_settings_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True) tab_fr.columnconfigure(1, weight=1) tab_fr.rowconfigure(tk.ALL, weight=1) # Hide settings by default (until something is selected) self.entry_settings_frame.grid_remove()
root, padding="3 3 12 12") # tied to root because it is the top-level UI # padding is interesting and provides room between # the grid-placed widgets and the frame they # reside within (R T L B) mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) # anchors to the root at the default position root.columnconfigure(0, weight=1) # helps with frame/app resizing on the fly root.rowconfigure(0, weight=1) # helps with frame/app resizing on the fly # define our two main global variables that are to hold active values feet = StringVar() meters = StringVar() # define a text entry widget to capture user input and to reside within the frame feet_entry = ttk.Entry(mainframe, width=7, textvariable=feet) feet_entry.grid(column=2, row=1, sticky=(W, E)) # define the label that will display the calculated meters value; note how textvariable is used # to bind the label the to meters global variable ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E)) # define the button that the user clicks after entering the feet into the text entry input widget # also note how no parameters are passed into the calculate function bound to command; here is the # reliance on globals ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=3, row=3, sticky=W) # define a label widget to display the units; notice that it's defined to reside in the same # row as the text entry widget and the column that would place =it to the right of the same
def get_teleoperation_frame(window, mqtt_sender): """ Constructs and returns a frame on the given window, where the frame has Entry and Button objects that control the EV3 robot's motion by passing messages using the given MQTT Sender. :type window: ttk.Frame | ttk.Toplevel :type mqtt_sender: com.MqttClient """ # Construct the frame to return: frame = ttk.Frame(window, padding=10, borderwidth=5, relief="ridge") frame.grid() # Construct the widgets on the frame: frame_label = ttk.Label(frame, text="Teleoperation") left_speed_label = ttk.Label(frame, text="Left wheel speed (0 to 100)") right_speed_label = ttk.Label(frame, text="Right wheel speed (0 to 100)") straight_speed_lebel = ttk.Label(frame, text='Straight speed(0 to 100)') time_lebel = ttk.Label(frame, text='Time in seconds') distance_lebel = ttk.Label(frame, text ='Distance in inches') left_speed_entry = ttk.Entry(frame, width=8) left_speed_entry.insert(0, "100") right_speed_entry = ttk.Entry(frame, width=8, justify=tkinter.RIGHT) right_speed_entry.insert(0, "100") time_entry = ttk.Entry(frame,width=8) straight_speed_entry = ttk.Entry(frame,width=8) straight_speed_entry.insert(0,"100") distance_entry = ttk.Entry(frame, width =8) forward_button = ttk.Button(frame, text="Forward") backward_button = ttk.Button(frame, text="Backward") left_button = ttk.Button(frame, text="Left") right_button = ttk.Button(frame, text="Right") stop_button = ttk.Button(frame, text="Stop") go_straight_for_second_button= ttk.Button(frame, text='Go straight for second') go_inches_time_button = ttk.Button(frame, text='Go straight for inches using time') go_inches_encoder_button = ttk.Button(frame, text='Go straight for inches using encoder') # Grid the widgets: frame_label.grid(row=0, column=1) left_speed_label.grid(row=1, column=0) right_speed_label.grid(row=1, column=2) left_speed_entry.grid(row=2, column=0) right_speed_entry.grid(row=2, column=2) forward_button.grid(row=3, column=1) left_button.grid(row=4, column=0) stop_button.grid(row=4, column=1) right_button.grid(row=4, column=2) backward_button.grid(row=5, column=1) time_lebel.grid(row=6, column=0) time_entry.grid(row=7, column=0) straight_speed_lebel.grid(row=6, column=1) straight_speed_entry.grid(row=7, column=1) distance_lebel.grid(row=8, column=0) distance_entry.grid(row=9, column=0) go_straight_for_second_button.grid(row=7, column=2) go_inches_time_button.grid(row=8, column=2) go_inches_encoder_button.grid(row=9, column=2) # Set the button callbacks: forward_button["command"] = lambda: handle_forward( left_speed_entry, right_speed_entry, mqtt_sender) backward_button["command"] = lambda: handle_backward( left_speed_entry, right_speed_entry, mqtt_sender) left_button["command"] = lambda: handle_left( left_speed_entry, right_speed_entry, mqtt_sender) right_button["command"] = lambda: handle_right( left_speed_entry, right_speed_entry, mqtt_sender) stop_button["command"] = lambda: handle_stop(mqtt_sender) go_straight_for_second_button['command'] = lambda:handle_go_straight_for_second(time_entry,straight_speed_entry,mqtt_sender) go_inches_time_button['command'] = lambda: handle_inches_time(distance_entry, straight_speed_entry, mqtt_sender) go_inches_encoder_button['command'] = lambda:handle_inches_encoder(distance_entry, straight_speed_entry, mqtt_sender) return frame
def cardreader(): scanner_id() # construct the argument parser and parse the arguments # load the input image global name, name_idin image = cv2.imread('ID.png') # find the barcodes in the image and decode each of the barcodes barcodes = pyzbar.decode(image) for barcode in barcodes: # extract the bounding box location of the barcode and draw the # bounding box surrounding the barcode on the image (x, y, w, h) = barcode.rect cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2) # the barcode data is a bytes object so if we want to draw it on # our output image we need to convert it to a string first barcodeData = barcode.data.decode("utf-8") barcodeType = barcode.type name = barcode.data.decode("utf-8") # draw the barcode data and barcode type on the image text = "{}".format(barcodeData) cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) # print the barcode type and data to the terminal print("[INFO] Found {} barcode: {}".format( barcodeType, barcodeData)) if name == 'S16950636': name = 'Isamu Naets' else: print('notfound') # show the output image cv2.imshow("Image", image) cv2.waitKey(0) cv2.destroyAllWindows() id = ttk.Entry(self) id.insert(END, name) id.pack() print(name) scanPC = ttk.Button(self, text="Scan Laptop") scanPC.configure(command=lambda: qrin2()) scanPC.pack() ############################################################################################################ def qrin2(): scanner_qr() # construct the argument parser and parse the arguments # load the input image global laptop, name_idin image = cv2.imread('qr.png') # find the barcodes in the image and decode each of the barcodes barcodes = pyzbar.decode(image) for barcode in barcodes: # extract the bounding box location of the barcode and draw the # bounding box surrounding the barcode on the image (x, y, w, h) = barcode.rect cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2) # the barcode data is a bytes object so if we want to draw it on # our output image we need to convert it to a string first barcodeData = barcode.data.decode("utf-8") barcodeType = barcode.type laptop = barcode.data.decode("utf-8") # draw the barcode data and barcode type on the image text = "{}".format(barcodeData) cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) # print the barcode type and data to the terminal print("[INFO] Found {} barcode: {}".format( barcodeType, barcodeData)) if laptop == 'S16950636': print('hello Isamu') else: print('notfound') # show the output image cv2.imshow("Image", image) cv2.waitKey(0) cv2.destroyAllWindows() idl = ttk.Entry(self) idl.insert(END, laptop) idl.pack() name_idin = id.get()
myTreeView.column("Value", stretch=False, width=100) myTreeView.column("Price", stretch=False, width=100) myTreeView.column("LAST_PRICE", stretch=False, width=100) myTreeView.heading("Index", text="Index") myTreeView.heading("Value", text="Value") myTreeView.heading("Price", text="Price") myTreeView.heading("LAST_PRICE", text="Last Price") # attach a Horizontal (x) scrollbar to the frame treeXScroll = ttk.Scrollbar(content, orient=HORIZONTAL) treeXScroll.configure(command=myTreeView.xview) myTreeView.configure(xscrollcommand=treeXScroll.set) # initialize the Label and Entry namelbl = ttk.Label(content, text="Name") name = ttk.Entry(content) # initialize Checkbuttons onevar = BooleanVar() twovar = BooleanVar() threevar = BooleanVar() onevar.set(True) twovar.set(False) threevar.set(True) one = ttk.Checkbutton(content, text="One", variable=onevar, onvalue=True) two = ttk.Checkbutton(content, text="Two", variable=twovar, onvalue=True) three = ttk.Checkbutton(content, text="Three", variable=threevar, onvalue=True) # initialize Buttons ok = ttk.Button(content, text="Okay") cancel = ttk.Button(content, text="Cancel")
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) fuente = font.Font(weight='bold') self.motor = MotorLogico("basepruebas.tsv", [], []) self.motor.load_db() self.etiq1 = ttk.Label(self, text='Idioma 1:', font=fuente) self.etiq2 = ttk.Label(self, text='Idioma 2:', font=fuente) self.etiq3 = ttk.Label(self, text='Operaciones:', font=fuente) self.etiq4 = ttk.Label(self, text='Relaciones:', font=fuente) self.radio = StringVar() self.radio_etymological_origin_of_txt = StringVar() self.radio_has_derived_from_txt = StringVar() self.radio_is_derived_from_txt = StringVar() self.radio_etymology_txt = StringVar() self.radio_etymologically_related_txt = StringVar() self.radio_variant_orthography_txt = StringVar() self.radio_derived_txt = StringVar() self.radio_etymologically_txt = StringVar() self.radio_etymological_origin_of_txt.set("n") self.radio_has_derived_from_txt.set("n") self.radio_is_derived_from_txt.set("n") self.radio_etymology_txt.set("n") self.radio_etymologically_related_txt.set("n") self.radio_variant_orthography_txt.set("n") self.radio_derived_txt.set("n") self.radio_etymologically_txt.set("n") self.salida_operacion = Text(self, width=50, height=15) self.salida_operacion.place(relx=0.06, rely=0.3) self.radio_comunes_idiomas_cuenta = ttk.Checkbutton( self, text="¿Contar palabras comunes entre idiomas?", variable=self.radio, onvalue="ContarPalabras", offvalue="") self.radio_comunes_idiomas_lista = ttk.Checkbutton( self, text="¿Listar palabras comunes entre idiomas?", variable=self.radio, onvalue="ListarPalabras", offvalue="") self.radio_aporte_idiomas = ttk.Checkbutton( self, text="¿Idioma que más aportó a otro?", variable=self.radio, onvalue="IdiomaAporte", offvalue="") self.radio_aporte_entre_idiomas = ttk.Checkbutton( self, text="¿Listar todos los idiomas que aportaron al otro?", variable=self.radio, onvalue="IdiomasAporte", offvalue="") self.radio_etymological_origin_of = ttk.Checkbutton( self, text="rel:etymological_origin_of", variable=self.radio_etymological_origin_of_txt, onvalue="rel:etymological_origin_of", offvalue="n") self.radio_has_derived_from = ttk.Checkbutton( self, text="rel:has_derived_form", variable=self.radio_has_derived_from_txt, onvalue="rel:has_derived_form", offvalue="n") self.radio_is_derived_from = ttk.Checkbutton( self, text="rel:is_derived_from", variable=self.radio_is_derived_from_txt, onvalue="rel:is_derived_from", offvalue="n") self.radio_etymology = ttk.Checkbutton( self, text="rel:etymology", variable=self.radio_etymology_txt, onvalue="rel:etymology", offvalue="n") self.radio_etymologically_related = ttk.Checkbutton( self, text="rel:etymologically_related", variable=self.radio_etymologically_related_txt, onvalue="rel:etymologically_related", offvalue="n") self.radio_variant_orthography = ttk.Checkbutton( self, text="rel:variant:orthography", variable=self.radio_variant_orthography_txt, onvalue="rel:variant:orthography", offvalue="n") self.radio_derived = ttk.Checkbutton(self, text="rel:derived", variable=self.radio_derived_txt, onvalue="rel:derived", offvalue="n") self.radio_etymologically = ttk.Checkbutton( self, text="rel:etymologically", variable=self.radio_etymologically_txt, onvalue="rel:etymologically", offvalue="n") self.radio_comunes_idiomas_cuenta.place(relx=0.7, rely=0.1) self.radio_comunes_idiomas_lista.place(relx=0.7, rely=0.15) self.radio_aporte_idiomas.place(relx=0.7, rely=0.2) self.radio_aporte_entre_idiomas.place(relx=0.7, rely=0.25) self.radio_etymological_origin_of.place(relx=0.7, rely=0.5) self.radio_has_derived_from.place(relx=0.7, rely=0.55) self.radio_is_derived_from.place(relx=0.7, rely=0.6) self.radio_etymology.place(relx=0.7, rely=0.65) self.radio_etymologically_related.place(relx=0.7, rely=0.7) self.radio_variant_orthography.place(relx=0.7, rely=0.75) self.radio_derived.place(relx=0.7, rely=0.8) self.radio_etymologically.place(relx=0.7, rely=0.85) self.palabra1 = StringVar() self.palabra2 = StringVar() self.entrada_palabra1 = ttk.Entry(self, textvariable=self.palabra1, width=30) self.entrada_palabra2 = ttk.Entry(self, textvariable=self.palabra2, width=30) self.separ = ttk.Separator(self, orient=HORIZONTAL) self.boton1 = ttk.Button(self, text="Realizar operación", command=self.operar) self.boton2 = ttk.Button(self, text="Cancelar", command=quit) self.boton_abrir_archivo = ttk.Button(self, text="Abrir base", command=self.abrir_archivo) self.boton_abrir_archivo.place(relx=0.06, rely=0.23) self.entrada_palabra1.place(relx=0.1, rely=0.1) self.entrada_palabra2.place(relx=0.4, rely=0.1) self.boton1.place(relx=0.30, rely=0.2) self.etiq1.place(relx=0.1, rely=0.03) self.etiq2.place(relx=0.4, rely=0.03) self.etiq3.place(relx=0.7, rely=0.05) self.etiq4.place(relx=0.7, rely=0.45)
root.geometry("400x300") root.config(bg='#F5F5DC') count = 0 #creating labels #sticky = to stick label left side. label1 = ttk.Label(root,text='Enter username *:',background='#F5F5DC',foreground='#8B4513',font='comicsansMS 10 bold') label2 = ttk.Label(root,text='Enter email *:',background='#F5F5DC',foreground='#8B4513',font='comicsansMS 10 bold') label3 = ttk.Label(root,text='Enter password *:',background='#F5F5DC',foreground='#8B4513',font='comicsansMS 10 bold') label4 = ttk.Label(root,text='Confirm password *:',background='#F5F5DC',foreground='#8B4513',font='comicsansMS 10 bold') label5 = ttk.Label(root,text='Choose your gender *:',background='#F5F5DC',foreground='#8B4513',font='comicsansMS 10 bold') label6 = ttk.Label(root,text='Already registered?',background='#F5F5DC',foreground='#8B4513',font='comicsansMS 10 bold') #creating entry fields username_var = tk.StringVar() username = ttk.Entry(root,textvariable=username_var) username.focus() email_var = tk.StringVar() email = ttk.Entry(root,textvariable=email_var) pass_var = tk.StringVar() password = ttk.Entry(root,textvariable=pass_var,show='*') repass_var = tk.StringVar() repass = ttk.Entry(root,textvariable=repass_var,show='*') #creating combobox gender_var = tk.StringVar() gender_combobox = ttk.Combobox(root,textvariable=gender_var,width=17,state='readonly',background='#F5F5DC',foreground='#8B4513') gender_combobox['values'] = ('Male','Female','Others')
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) fuente = font.Font(weight='bold') self.motor = MotorLogico("basepruebas.tsv", [], []) self.motor.load_db() print(self.motor.database) #self.tabs = ttk.Notebook(raiz) self.etiq1 = ttk.Label(self, text='Palabra:', font=fuente) self.etiq2 = ttk.Label(self, text='Idioma:', font=fuente) self.etiq3 = ttk.Label(self, text='Operaciones:', font=fuente) self.etiq4 = ttk.Label(self, text='Relaciones:', font=fuente) self.radio = StringVar() self.radio_etymological_origin_of_txt = StringVar() self.radio_has_derived_from_txt = StringVar() self.radio_is_derived_from_txt = StringVar() self.radio_etymology_txt = StringVar() self.radio_etymologically_related_txt = StringVar() self.radio_variant_orthography_txt = StringVar() self.radio_derived_txt = StringVar() self.radio_etymologically_txt = StringVar() self.radio_etymological_origin_of_txt.set("n") self.radio_has_derived_from_txt.set("n") self.radio_is_derived_from_txt.set("n") self.radio_etymology_txt.set("n") self.radio_etymologically_related_txt.set("n") self.radio_variant_orthography_txt.set("n") self.radio_derived_txt.set("n") self.radio_etymologically_txt.set("n") self.salida_operacion = Text(self, width=50, height=15) self.salida_operacion.place(relx=0.06, rely=0.3) self.radio_palabras_relacionadas = ttk.Checkbutton( self, text="¿Palabra relacionada con idioma?", variable=self.radio, onvalue="PalabraIdioma", offvalue="") self.radio_idiomas_originados = ttk.Checkbutton( self, text="¿Palabras en idioma originadas por palabra?", variable=self.radio, onvalue="IdiomasOriginados", offvalue="") self.radio_idiomas_relacionados = ttk.Checkbutton( self, text="¿Idiomas relacionados con palabra?", variable=self.radio, onvalue="IdiomasRelacionados", offvalue="") self.radio_etymological_origin_of = ttk.Checkbutton( self, text="rel:etymological_origin_of", variable=self.radio_etymological_origin_of_txt, onvalue="rel:etymological_origin_of", offvalue="") self.radio_has_derived_from = ttk.Checkbutton( self, text="rel:has_derived_form", variable=self.radio_has_derived_from_txt, onvalue="rel:has_derived_form", offvalue="") self.radio_is_derived_from = ttk.Checkbutton( self, text="rel:is_derived_from", variable=self.radio_is_derived_from_txt, onvalue="rel:is_derived_from", offvalue="") self.radio_etymology = ttk.Checkbutton( self, text="rel:etymology", variable=self.radio_etymology_txt, onvalue="rel:etymology", offvalue="") self.radio_etymologically_related = ttk.Checkbutton( self, text="rel:etymologically_related", variable=self.radio_etymologically_related_txt, onvalue="rel:etymologically_related", offvalue="") self.radio_variant_orthography = ttk.Checkbutton( self, text="rel:variant:orthography", variable=self.radio_variant_orthography_txt, onvalue="rel:variant:orthography", offvalue="") self.radio_derived = ttk.Checkbutton(self, text="rel:derived", variable=self.radio_derived_txt, onvalue="rel:derived", offvalue="") self.radio_etymologically = ttk.Checkbutton( self, text="rel:etymologically", variable=self.radio_etymologically_txt, onvalue="rel:etymologically", offvalue="") self.radio_palabras_relacionadas.place(relx=0.7, rely=0.1) self.radio_idiomas_originados.place(relx=0.7, rely=0.15) self.radio_idiomas_relacionados.place(relx=0.7, rely=0.2) self.radio_etymological_origin_of.place(relx=0.7, rely=0.5) self.radio_has_derived_from.place(relx=0.7, rely=0.55) self.radio_is_derived_from.place(relx=0.7, rely=0.6) self.radio_etymology.place(relx=0.7, rely=0.65) self.radio_etymologically_related.place(relx=0.7, rely=0.7) self.radio_variant_orthography.place(relx=0.7, rely=0.75) self.radio_derived.place(relx=0.7, rely=0.8) self.radio_etymologically.place(relx=0.7, rely=0.85) self.palabra1 = StringVar() self.palabra2 = StringVar() self.entrada_palabra1 = ttk.Entry(self, textvariable=self.palabra1, width=30) self.entrada_palabra2 = ttk.Entry(self, textvariable=self.palabra2, width=30) self.separ = ttk.Separator(self, orient=HORIZONTAL) self.boton1 = ttk.Button(self, text="Realizar operación", command=self.operar) self.boton2 = ttk.Button(self, text="Cancelar", command=quit) self.boton_abrir_archivo = ttk.Button(self, text="Abrir base", command=self.abrir_archivo) self.boton_abrir_archivo.place(relx=0.06, rely=0.23) self.entrada_palabra1.place(relx=0.1, rely=0.1) self.entrada_palabra2.place(relx=0.4, rely=0.1) self.boton1.place(relx=0.30, rely=0.2) self.etiq1.place(relx=0.1, rely=0.03) self.etiq2.place(relx=0.4, rely=0.03) self.etiq3.place(relx=0.7, rely=0.05) self.etiq4.place(relx=0.7, rely=0.45)
def contact_n(): global win1 win1 = tk.Toplevel(win) win1.config(background="Black") win1.title("Add New Contact - Contact Book") our_frame = tk.LabelFrame(win1) our_frame.pack(anchor=tk.CENTER, padx=20, pady=20) title_label = ttk.Label(our_frame, text="Add New Contact", font=20) title_label.grid(row=0, columnspan=2, pady=5) # Name Label name_label = ttk.Label(our_frame, text="Name :") name_label.grid(row=1, column=0, sticky=tk.W, padx=10, pady=3) #age abel age_label = ttk.Label(our_frame, text="Age : ") age_label.grid(row=2, column=0, sticky=tk.W, padx=10, pady=3) #gender with radio button global gender_var gender_var = tk.StringVar() radiobtn1 = ttk.Radiobutton(our_frame, text="Male", value="Male", variable=gender_var) radiobtn1.grid(row=3, column=0, sticky=tk.W, padx=10, pady=3) radiobtn2 = ttk.Radiobutton(our_frame, text='Female', value="Female", variable=gender_var) radiobtn2.grid(row=3, column=1, padx=10, pady=3) # More Labels occ_label = ttk.Label(our_frame, text="Occupation :") occ_label.grid(row=4, column=0, sticky=tk.W, padx=10, pady=3) email_label = ttk.Label(our_frame, text="Email :") email_label.grid(row=5, column=0, sticky=tk.W, padx=10, pady=3) phone_label = ttk.Label(our_frame, text="Phone No. :") phone_label.grid(row=6, column=0, sticky=tk.W, padx=10, pady=3) city_label = ttk.Label(our_frame, text="City : ") city_label.grid(row=7, column=0, sticky=tk.W, padx=10, pady=3) state_label = ttk.Label(our_frame, text="State : ") state_label.grid(row=8, column=0, sticky=tk.W, padx=10, pady=3) # Entry_boxes global name_var name_var = tk.StringVar() global name_entry name_entry = ttk.Entry(our_frame, width=16, textvariable=name_var) name_entry.grid(row=1, column=1, padx=10, pady=3) name_entry.focus() global age_var age_var = tk.StringVar() global age_entry age_entry = ttk.Entry(our_frame, width=16, textvariable=age_var) age_entry.grid(row=2, column=1, padx=10, pady=3) # COmbobox for occupation global occ_var occ_var = tk.StringVar() global occ_combobox occ_combobox = ttk.Combobox(our_frame, width=13, textvariable=occ_var) occ_combobox['values'] = ("Student", "Worker", "Businessman") occ_combobox.grid(row=4, column=1, padx=10, pady=3) occ_combobox.current(0) global email_var email_var = tk.StringVar() global email_entry email_entry = ttk.Entry(our_frame, width=16, textvariable=email_var) email_entry.grid(row=5, column=1, padx=10, pady=3) global phone_var phone_var = tk.StringVar() global phone_entry phone_entry = ttk.Entry(our_frame, width=16, textvariable=phone_var) phone_entry.grid(row=6, column=1, padx=10, pady=3) global city_var city_var = tk.StringVar() global city_entry city_entry = ttk.Entry(our_frame, width=16, textvariable=city_var) city_entry.grid(row=7, column=1, padx=10, pady=3) global state_var state_var = tk.StringVar() global state_entry state_entry = ttk.Entry(our_frame, width=16, textvariable=state_var) state_entry.grid(row=8, column=1, padx=10, pady=3) #checkbutton global confirm_var confirm_var = tk.IntVar() global confirm_checkbutton confirm_checkbutton = tk.Checkbutton(our_frame, text="I have rechecked the detail", variable=confirm_var) confirm_checkbutton.grid(row=9, columnspan=2, sticky=tk.W, padx=10, pady=3) #submit Button submitbtn = tk.Button(our_frame, text="Add Contact", command=action, bg="Light Grey") submitbtn.grid(row=10, columnspan=2, padx=10, pady=5)
def create_feature_widgets(self, argument): """Setup variables, style, widgets for appearance on launching""" # *** Set Int variable for Checkbutton set 1 self.entry_1_text = StringVar() # *** Set Int variable for Checkbutton set 2 self.entry_2_text = StringVar() # ===== Create styles for use with ttk widgets ===== self.style = ttk.Style() # Change a root style to modify all widgets. self.style.configure('.', font=('FreeSans', 12)) # Create a Blue style for the label. Use when value 0 self.style.configure('blue.TLabel', foreground='white', background='#0000ff', font=('FreeSans', 16), padding=10) self.style.configure('cyan.TFrame', borderwidth=5, relief="ridge", background='#00ffff') self.style.configure('grey.TEntry', foreground='grey', padding=5) self.style.configure('black.TEntry', foreground='black', padding=5) # ===== Create Widgets ===== # Create Frames # Frame1. Relief = "sunken" "flat" "groove" "ridge" "raised" self.frame_1 = ttk.Frame(self, style='cyan.TFrame', padding="5 5 5 5") # Create Label Frame for entry_1 self.labelframe_1 = ttk.Labelframe(self, text="Account (lower case)") # Create Entry_1: # Use register to define functions to validate and process invalid self.entry_1 = ttk.Entry( self.labelframe_1, textvariable=self.entry_1_text, validate='key', invalidcommand=(self.register(self.is_invalid_entry_1), '%W', '%P'), validatecommand=(self.register(self.is_valid_entry_1), '%P')) # Add a Scrollbar self.scrollbar_1 = ttk.Scrollbar(self.labelframe_1, orient="horizontal", command=self.entry_1.xview) # Link entry_1 to the scrollbar self.entry_1.config(xscrollcommand=self.scrollbar_1.set) # Setup the entry_1 inside the label_frame_1 # self.entry_1.pack(fill=X, expand=Y, padx='1m', pady='1m') self.entry_1.grid( in_=self.labelframe_1, row=0, column=0, padx=5, pady=5, ) self.scrollbar_1.grid(in_=self.labelframe_1, row=1, column=0, padx=5, pady=5, sticky="ew") # Create Label Frame for entry_2 self.labelframe_2 = ttk.LabelFrame(self, text="Password") # Create Entry_2 as though it is a password: self.entry_2 = ttk.Entry(self.labelframe_2, textvariable=self.entry_2_text, show="*") # Setup the entry_2 inside the label_frame_2 # self.entry_1.pack(fill=X, expand=Y, padx='1m', pady='1m') self.entry_2.grid( in_=self.labelframe_2, row=0, column=0, padx=5, pady=5, ) # Create Labels: # label_1 - Main label to display the status of the switches self.label_1 = ttk.Label(self.frame_1, text="", style='blue.TLabel') # Add label_1 into frame_1 self.label_1.grid(row=0, column=0, sticky="WE") # Button_1 Submit the data self.button_1 = ttk.Button(self, text=BUTTON_1_TEXT, command=self.button_1_cb) # ===== Add frames to main grid ===== # *** self.labelframe_1.grid(row=1, column=0, padx=10, pady=5, sticky="w") self.labelframe_2.grid(row=2, column=0, padx=10, pady=5, sticky="w") # self.entry_2.grid(row=2, column=0, padx=10, pady=5, sticky="w") # self.checkbutton_2.grid(row=2, column=0, padx=10, pady=5, sticky=W) self.frame_1.grid(row=0, column=0, columnspan=3, padx=5, pady=5) self.button_1.grid(row=4, column=0, padx=5, pady=5, sticky="w") # ===== Initial Setup ===== # Perform initial setup of entry and invoke submit. # Pass 0 or 1 on command line #*** if argument: self.entry_1_text.set("root") pass