def show_user_own_playlist(): global list_, times_called, t1 t1 = Toplevel() t1.config(bg='#3C3C3C') t1.title("Your Created Playlists Are Here!") t2 = Label(t1, text='Here Is The List Of Playlist You Created:', font=('Arial Rounded MT bold', 25, 'bold')) t2.pack() list_ = Listbox(t1, width=32, bg="#3C3C3C", fg='cyan', font=('Arial', 17, 'bold')) list_.pack() x124 = 0 lisst = [] for i1 in names: list_.insert(x124, i1) lisst.append(list_.get(0, END)) print(lisst) x124 += 1 list_.bind('<Double-Button>', question1)
def _create_popwin(self, event): if self._r is not None: top = Toplevel() top.title("统计") # # tr = Treeview(top, columns=('kind','state')) tr = Treeview(top, show='headings', columns=('kind', 'state', 'count')) # ysb = Scrollbar(tr, orient='vertical', command=tr.yview) # tr.configure(yscroll=ysb.set) # ysb.pack() tr.column('kind', width = 100, anchor ='center') tr.column('state', width = 100, anchor ='center') tr.column('count', width = 100, anchor ='center') tr.heading('kind', text='车型') tr.heading('state', text='状态') tr.heading('count', text='总量') for l in self._r: _state = '' if l[1] == 1: _state = '未修改' elif l[1] == 2: _state = '轴数异常' elif l[1] == 3: _state = '已修改' tr.insert('',0, text='', values=(l[0], _state, l[2])) # tr.insert('',0,values=(l[0], _state, l[2])) tr.pack() button = Button(top, text="退出", command=top.destroy) button.pack() top.config(height=top.bbox(tr)[3]+100)
def window_help(): popup = Toplevel() frame_help = LabelFrame(popup, text='Help', font=['TkDefaultFont', 9, 'bold']) frame_help.grid(column=1, row=1, rowspan=2, sticky='N') txt_help = Label(frame_help, height=17, width=40, text='1. Load any type of audio file (MP3, WAV, etc.). There is ffmpeg used for converting, so feel free to use any kind of audio format supported by ffmpeg.\n\n2. Choose preferred dataset and neural network architecture and hit "Predict tags".\n\n3. Predicting may take a while depending on your hardware. NVIDIA GPU with CUDA support for TensorFlow is recommended.', wraplengt=200) txt_help.grid() popup.config(borderwidth=10) popup.grab_set()
def __init__(self, *args, **kwargs): Toplevel.__init__(self, *args, **kwargs) Toplevel.wm_title(self, "FollowingJVparameters") Toplevel.config(self,background="white") self.wm_geometry("500x500") center(self) self.initUI()
def __init__(self, *args, **kwargs): Toplevel.__init__(self, *args, **kwargs) Toplevel.wm_title(self, "DBReadingapp") Toplevel.config(self, background="white") self.wm_geometry("300x150") center(self) self.initUI()
def __init__(self, *args, **kwargs): Toplevel.__init__(self, *args, **kwargs) Toplevel.wm_title(self, "SpectroApp") Toplevel.config(self, background="white") self.wm_geometry("500x500") center(self) self.initUI()
def __init__(self, *args, **kwargs): Toplevel.__init__(self, *args, **kwargs) Toplevel.wm_title(self, "CMM") Toplevel.config(self, background="white") self.wm_geometry("400x205") #self.wm_resizable(False,True) center(self) self.initUI()
def window_about(): popup = Toplevel() frame_about = LabelFrame(popup, text='About', font=['TkDefaultFont', 9, 'bold']) frame_about.grid(column=1, row=1, rowspan=2, sticky='N') Label(frame_about, text='This app is one of the results of my master\'s thesis.', wraplengt=200).grid(column=0, row=0, columnspan=2) Label(frame_about, text='\nUniversity: \nFaculty: \nField of Study: \nThesis: \nSupervisor: \n Author: ', font=['TkDefaultFont', 9, 'bold'], justify='right').grid(column=0, row=1) Label(frame_about, text='\nBrno University of Technology \nFaculty of Electrical Engineering and Communication \nAudio Engineering \nAutomatic Tagging of Musical Compositions Using Machine Learning Methods \nIng. Tomáš Kiska \nBc. René Semela', justify='left').grid(column=1, row=1) popup.config(borderwidth=10) popup.grab_set()
def __init__(self, *args, **kwargs): Toplevel.__init__(self, *args, **kwargs) Toplevel.wm_title(self, "DarkToLight") Toplevel.config(self,background="white") self.wm_geometry("713x277") self.wm_resizable(False,False) center(self) self.initUI()
def show_all(): show_root=Toplevel() show_root.grab_set() show_root.focus() show_root.geometry('795x500+100+150') show_root.resizable(False,False) show_root.config(bg='firebrick1') frame=tk.Frame(show_root,bg='gold2',relief='groove',borderwidth=5) frame.place(x=0,y=0,width=795,height=500) scroll_x=tk.Scrollbar(frame,orient='horizontal') scroll_x.pack(side='bottom',fill='x') scroll_y=tk.Scrollbar(frame,orient='vertical') scroll_y.pack(side='right',fill='y') members_table=ttk.Treeview(frame,columns=('Id','Name','Mobile No','Address','Gender','D.O.B'), yscrollcommand=scroll_y,xscrollcommand=scroll_x) members_table.pack(fill='both',expand=1) scroll_x.config(command=members_table.xview) scroll_y.config(command=members_table.yview) style =ttk.Style() style.configure('Treeview.Heading',foreground='blue',font=('helvetica',16)) style.configure('Treeview',foreground='green',font=('times new roman',15),background='cyan',fg='green',bg='red') members_table.heading('Id',text='Id') members_table.heading('Name',text='Name') members_table.heading('Mobile No',text='Mobile No') members_table.heading('Address',text='Address') members_table.heading('Gender',text='Gender') members_table.heading('D.O.B',text='D.O.B') members_table['show']='headings' members_table.column('Id',width=50) members_table.column('Name',width=300) members_table.column('Mobile No',width=140) members_table.column('Address',width=260) members_table.column('Gender',width=100) members_table.column('D.O.B',width=100) try: strr ='select * from membersdata' my_cursor.execute(strr) datas = my_cursor.fetchall() members_table.delete(*members_table.get_children()) for i in datas: val = [i[0],i[1],i[2],i[3],i[4],i[5]] members_table.insert('', 'end', values=(val)) except: show_root.destroy() m_box.showerror('Notification','Please connect to Database first') show_root.mainloop()
def help_user(self): """ Input: Clicked by user! Output: Explains about the program. Meaning: Contains information about the program. """ top = Toplevel(master=self.root) top.title("Instructions") top.resizable(width=False, height=False) menu_bar = Menu(master=top) menu_bar.add_command(label="Quit", command=top.destroy) top.config(menu=menu_bar) labels = list() labels.append( Label( master=top, text="1) Insert your username and password in the given fields." )) labels.append(Label(master=top, text="2) Click login.")) labels.append( Label( master=top, text= "3) Once you get the message you're authenticated you're good to go, else, retry." )) labels.append( Label( master=top, text= "4) If you want to run on existing dates tick v on override existing data." )) labels.append( Label( master=top, text= "5) Click Submit Hours from Excel, choose your excel hours file." )) labels.append( Label(master=top, text="6)You're free to go, your hours have been submitted.")) labels.append( Label( master=top, text= "\nNote) It doesn't take breaks in count, only the earliest hour and the latest one." )) for label in labels: label.pack() self.geometry_setter(top, minimum_x=500, minimum_y=160)
def message(self): msg = Toplevel(self) msg.geometry('300x100') msg.title('Error') msg.config(bg='#34378b') label = tk.Label(msg, text='Debe seleccionar un item para editar', bg='#34378b', fg='#ffffff') label.grid(row=0, column=0, padx=5, pady=5, sticky='ew') tk.Button(msg, text='Cerrar', command=msg.destroy).grid(row=1, column=0, padx=5, pady=5, sticky='ew')
def raise_window(self, player): if self.text == "Go!!": return win = Toplevel(self.root) win.config(bg=self.color) win.resizable(False, False) if "visit" in self.text.lower(): win.title("Visiting Jail...") imgopen = Image.open(r"resources\Jail.jpg") imgtk = ImageTk.PhotoImage(imgopen) lbl = Label(win, image=imgtk) lbl.image = imgtk fee = 10000 player.balance -= fee Label(win, text=f"Visiting Jail...Entry fee = {fee}!", bg="white", font=Font(20)).grid(row=0, column=0, sticky="we") lbl.grid(row=1, column=0, sticky="we") elif "jail" in self.text.lower(): win.title("GO TO JAIL!") imgopen = Image.open(r"resources\Go to Jail.jpg") imgtk = ImageTk.PhotoImage(imgopen) lbl = Label(win, image=imgtk) lbl.image = imgtk Label(win, text=f"{player.name} going to jail for 3 turns!!", bg="white", font=Font(20)).grid(row=0, column=0, sticky="we") lbl.grid(row=1, column=0, sticky="we") else: win.title("MOLE HOLE!") imgopen = Image.open(r"resources\Mole Hole.png").resize( (640, 360), Image.ANTIALIAS) imgtk = ImageTk.PhotoImage(imgopen) lbl = Label(win, image=imgtk) lbl.image = imgtk Label(win, text=f"Welcome to the Mole Hole!", bg="white", font=Font(20)).grid(row=0, column=0, sticky="we") lbl.grid(row=1, column=0, sticky="we") win.mainloop()
def raise_window(self, player): win = Toplevel(self.root) win.geometry("600x550") win.config(bg=self.color) name = self.square.name ext = ".jpg" if "Burn" in name or "Scale" in name else ".png" imgFile = ImageTk.PhotoImage( Image.open(fr"resources\utils\{name}{ext}")) def close(): win.destroy() def buy(): self.square.sell(player) close() if self.square.owned_by is None: Label(win, text=f"Equipment - {name}!", bg=self.color, font=Font(20)).grid(row=0, column=0, sticky="we") img = Label(win, image=imgFile) img.image = imgFile img.grid(row=1, column=0, sticky="we") Button(win, text="Buy!", bg="green", font=Font(15), command=buy).grid(row=2, column=0, sticky="we") win.update_idletasks() else: Label(win, text=f"{self.square.owned_by.name} owns {name}!", font=Font(18), bg=self.color).grid(row=0, column=0, sticky="we") img = Label(win, image=imgFile) img.image = imgFile img.grid(row=1, column=0, sticky="we") Button(win, text="OK", bg="blue", fg="white", font=Font(12), command=close).grid(row=2, column=0, sticky="we") win.mainloop() return
def Home(): global Home Home = Toplevel() Home.protocol('WM_DELETE_WINDOW', Exit) # intercept [X] to stop mainloop() Home.title("Inventory System/Home") bg = "#4287f5" width = 840 height = 540 screen_width = Home.winfo_screenwidth() screen_height = Home.winfo_screenheight() x = (screen_width / 2) - (width / 2) y = (screen_height / 2) - (height / 2) Home.geometry("%dx%d+%d+%d" % (width, height, x, y)) Home.resizable(0, 0) Title = Frame(Home, bd=1, relief=SOLID) Title.pack(pady=10) Title.place(relx=0.5, rely=0.4, anchor='center') lbl_display = Label(Title, text="Inventory System", font=('arial', 45)) lbl_display.pack() Description = Frame(Home) Description.pack(pady=10) Description.place(relx=0.5, rely=0.55, anchor='center') lbl_display2 = Label(Description, text="Welcome Back!", font=('arial', 18), bg=bg) lbl_display2.pack() menubar = Menu(Home) filemenu1 = Menu(menubar, tearoff=0) filemenu2 = Menu(menubar, tearoff=0) filemenu3 = Menu(menubar, tearoff=0) filemenu1.add_command(label="Export to CSV", command=Export) filemenu1.add_command(label="Add New Item", command=ShowAddNew) filemenu2.add_command(label="Logout", command=Logout) filemenu2.add_command(label="Exit", command=Exit) filemenu3.add_command(label="View Inventory", command=ShowView) # filemenu3.add_command(label="View Clients", command=ShowViewClients) menubar.add_cascade(label="File", menu=filemenu1) menubar.add_cascade(label="Account", menu=filemenu2) menubar.add_cascade(label="View", menu=filemenu3) Home.config(menu=menubar) Home.config(bg=bg)
def new_sunday(): def new_sun(): try: global new_table new_table='sarathi'+date_entry.get() rr = f'create table {new_table} (user_id int primary key,foreign key(user_id) references membersdata(id ))' my_cursor.execute(rr) m_box.showinfo('Notification','Fresh Sunday',parent=date) all_mem() date.destroy() except NameError: todays_mem_root.destroy() date.destroy() m_box.showerror('Error','Please connect to Database First') except: res = m_box.askyesnocancel('Confirmation','Is it todays Date?',parent=date) if res: all_mem() date.destroy() date=Toplevel() date.grab_set() date.focus() date.geometry('490x180+300+300') date.resizable(False,False) date.config(bg='black') theme_name=tk.Label(date,text='Date should be like this:10May2020 ',bg='light green',fg='blue',font=('times new roman',18), width=30,borderwidth=5,anchor='center',relief='groove') theme_name.pack() date_name=tk.Label(date,text='Add Todays Date : ',bg='light green',fg='blue',font=('times new roman',18), width=15,borderwidth=5,anchor='w',relief='groove') date_name.place(x=0,y=50) date_entry=tk.Entry(date,fg='blue',font=('times new roman',18), width=20,borderwidth=5,relief='groove') date_entry.place(x=240,y=50) submit_date=tk.Button(date,text='Submit',command=new_sun,bg='light green',fg='blue',font=('times new roman',18), width=5,borderwidth=5,anchor='center',relief='groove') submit_date.place(x=190,y=110)
def update_sarathian(): global enter_id_root enter_id_root=Toplevel() enter_id_root.grab_set() enter_id_root.focus() enter_id_root.geometry('400x110+300+300') enter_id_root.config(bg='red') id_label=tk.Label(enter_id_root,text='Enter Id to update : ',bg='light green',fg='blue',font=('times new roman',18), width=15,borderwidth=5,anchor='w',relief='groove') id_label.place(x=10,y=10) global enter_id_var enter_id_var=tk.StringVar() id_entry=tk.Entry(enter_id_root,fg='blue',textvariable=enter_id_var,font=('times new roman',18), width=12,borderwidth=5,relief='groove') id_entry.place(x=230,y=10) id_entry.focus() submit_btn=tk.Button(enter_id_root,width=6,text='Upadate',command=update,bg='light green',fg='blue', activebackground='gold2',activeforeground='blue',font=('times new roman',18)) submit_btn.place(x=130,y=60)
def saveFilePopup(self, *args): # Create and Initialize Popup Window saveWindow = Toplevel() saveWindow.geometry("300x150") saveWindow.config(background="#FFFFFF") self.window.iconbitmap(r'Asset_10.ico') saveWindow.resizable(False, False) saveWindow.title("Save File") # Popup message message = Label(saveWindow, text="Choose which data to save?") msgFont = ('times', 14, 'normal') message.config(font=msgFont, background="#FFFFFF", height=5, width=30) message.grid(row=0, column=0, rowspan=2, columnspan=2, sticky=NSEW) # Frame for buttons buttonFrame = Frame(saveWindow, borderwidth=0, background="#ABA6A4") buttonFrame.grid(row=2, column=0, columnspan=2, sticky=S + E + W, pady=(0, 0)) emotionBtn = Button(buttonFrame, text="Emotion Data", command=self.saveEmotionInfo, background="#FFFFFF").pack( side=LEFT, padx=(50, 0), pady=(7, 7)) dlibBtn = Button(buttonFrame, text="Facial Data", command=self.saveDlibInfo, background="#FFFFFF").pack( side=RIGHT, padx=(0, 50), pady=(7, 7))
def new_body_mem(): def new_mem(): try: global new_body_db new_body_db='ExecutiveBody'+exe_entry.get() rr = f'create table {new_body_db} (body_id int primary key,foreign key(body_id) references membersdata(id ),mem_post varchar(50))' my_cursor.execute(rr) m_box.showinfo('Notification','Fresh Executive Body',parent=ex) all_mems() ex.destroy() except NameError: m_box.showerror('Error','Please connect to Database First',parent=ex) ex.destroy() Exe_body_root.destroy() except: res = m_box.askyesnocancel('Confirmation',f'Is it {exe_entry.get()} Executive body?',parent=ex) if res: all_mems() ex.destroy() ex=Toplevel() ex.grab_set() ex.title('Executive Body') ex.focus() ex.geometry('490x180+300+300') ex.resizable(False,False) ex.config(bg='black') exe_label=tk.Label(ex,text='Add Executive Body Number Below',bg='light green',fg='blue',font=('times new roman',18), width=40,borderwidth=5,anchor='center',relief='groove') exe_label.place(x=0,y=0) exe_entry=tk.Entry(ex,fg='blue',font=('times new roman',18), width=6,borderwidth=5,relief='groove') exe_entry.place(x=190,y=60) exe_entry.focus() submit_exe=tk.Button(ex,text='Submit',command=new_mem,bg='light green',fg='blue',font=('times new roman',18), width=5,borderwidth=5,anchor='center',relief='groove') submit_exe.place(x=190,y=110)
def edit(): #entry config font global name, t3 t3 = Toplevel() t3.title('Edit') t3.config(bg='#3C3C3C') edit_label = Label(t3, text='Edit Playlist Name Here:', font=('Arial', 25, 'bold')).pack() name = Entry(t3, bg='#3C3C3C', fg='yellow', font=('Arial Rounded MT bold', 14, 'bold')) name.pack() done = Button(t3, text='Done', font=('Arial', 20, 'bold'), fg='white', bg='#3C3C3C', activeforeground='white', activebackground='#3C3C3C', command=save_name) done.pack()
def creators_page() -> None: """ Opens another window which showcases a picture of the creators """ creators_window = Toplevel(ROOT) creators_window.title('Creators') creators_window.update_idletasks() width = 575 height = 350 x = (creators_window.winfo_screenwidth() // 2) - (width // 2) y = (creators_window.winfo_screenheight() // 2) - (height // 2) creators_window.geometry('{}x{}+{}+{}'.format(width, height, x, y)) creators_window.iconbitmap('leaf.ico') creators_window.config(bg='#FFE4AE') introduction_label = Label(creators_window, text='This project was created by...', font=('Helvetica', 10, 'bold'), bg='#FFE4AE', fg='#800000', borderwidth=0) introduction_label.grid(row=1, column=1, columnspan=4, pady=(10, 20)) # Opens the image for the title creator_image = Image.open('creator_image.png') # Resizes the image resized = creator_image.resize((600, 250), Image.ANTIALIAS) new_creator = ImageTk.PhotoImage(resized) # Displays the image as a label creator_label = Label(creators_window, image=new_creator, borderwidth=0) creator_label.photo = new_creator creator_label.grid(row=2, column=1, columnspan=4) why_label = Label(creators_window, text='for the CSC110 Final Project', font=('Helvetica', 10, 'bold'), bg='#FFE4AE', fg='#800000', borderwidth=0) why_label.grid(row=3, column=1, columnspan=4, pady=(10, 0))
def clicker(): global pop pop = Toplevel(root) pop.title("My popup") pop.geometry("250x150") pop.config(bg="Green") pop_label = Label(pop, text="Would you like do continue?") pop_button_yes = Button(pop, text="Yes", command=lambda: button_choice("yes")) pop_button_no = Button(pop, text="No", command=lambda: button_choice("no")) my_frame = Frame(pop, bg="white") my_frame.grid(row=0, column=0) pop_label.grid(row=0, column=0, padx=10, columnspan=2) pop_button_yes.grid(row=1, column=0, padx=10) pop_button_no.grid(row=1, column=1, padx=10) return
def map_(): Map_pop = Toplevel() Map_pop.geometry("400x400") Map_pop.title("Your Map") Map_pop.config(bg="#CABB92") m = World.make_map() yscroll = Scrollbar(Map_pop) xscroll = Scrollbar(Map_pop, orient="horizontal") yscroll.pack(side=RIGHT, fill=Y) xscroll.pack(side=BOTTOM, fill=X) Text_ = Text(Map_pop, bg="#CABB92", fg="black", relief="flat", highlightbackground="#CABB92", font=("DejaVu Sans Mono", 14), yscrollcommand=yscroll.set, xscrollcommand=xscroll.set, wrap=NONE) Text_.insert("1.0", m) Text_.pack(expand=False) yscroll.config(command=Text_.yview) xscroll.config(command=Text_.xview) Text_.config(state=DISABLED) def update(): if Everything.map_uptodate is False: scrollposx = Text_.xview() scrollposy = Text_.yview() scrollposx = str(scrollposx)[1:-1].split(", ") scrollposy = str(scrollposy)[1:-1].split(", ") Text_.config(state=NORMAL) x = World.make_map() Text_.delete("1.0", END) Text_.insert("1.0", x) # the code below is for keeping the map # focus to where you scrolled it Text_.yview_moveto(float(scrollposy[0])) Text_.xview_moveto(float(scrollposx[0])) Text_.config(state=DISABLED) Everything.map_uptodate = True Map_pop.after(500, update) Map_pop.after(100, update)
def Connectdb(): def submitdb(): global con, mycursor host = hostval.get() user = userval.get() password = passwordval.get() try: con = pymysql.connect(host=host, user=user, password=password) mycursor = con.cursor() except: messagebox.showerror('Notifications', 'Data is incorrect please try again', parent=dbroot) return try: strr = 'create database studentmanagementsystem1' mycursor.execute(strr) strr = 'use studentmanagementsystem1' mycursor.execute(strr) strr = 'create table studentdata1(id int,name varchar(20),mobile varchar(12),email varchar(30),address varchar(100),gender varchar(50),dob varchar(50),date varchar(50),time varchar(50))' mycursor.execute(strr) strr = 'alter table studentdata1 modify column id int not null' mycursor.execute(strr) strr = 'alter table studentdata1 modify column id int primary key' mycursor.execute(strr) messagebox.showinfo( 'Notification', 'database created and now you are connected connected to the database ....', parent=dbroot) except: strr = 'use studentmanagementsystem1' mycursor.execute(strr) messagebox.showinfo('Notification', 'Now you are connected to the database ....', parent=dbroot) dbroot.destroy() dbroot = Toplevel() dbroot.grab_set() dbroot.geometry('470x250+800+230') dbroot.iconbitmap('mana.ico') dbroot.resizable(False, False) dbroot.config(bg='blue') #-------------------------------Connectdb Labels hostlabel = Label(dbroot, text="Enter Host : ", bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=13, anchor='w') hostlabel.place(x=10, y=10) userlabel = Label(dbroot, text="Enter User : "******"Enter Password : ", bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=13, anchor='w') passwordlabel.place(x=10, y=130) #-------------------------Connectdb Entry hostval = StringVar() userval = StringVar() passwordval = StringVar() hostentry = Entry(dbroot, font=('roman', 15, 'bold'), bd=5, textvariable=hostval) hostentry.place(x=250, y=10) userentry = Entry(dbroot, font=('roman', 15, 'bold'), bd=5, textvariable=userval) userentry.place(x=250, y=70) passwordentry = Entry(dbroot, font=('roman', 15, 'bold'), bd=5, textvariable=passwordval) passwordentry.place(x=250, y=130) #-------------------------------- Connectdb button submitbutton = Button(dbroot, text='Submit', font=('roman', 15, 'bold'), bg='red', bd=5, width=20, activebackground='blue', activeforeground='white', command=submitdb) submitbutton.place(x=150, y=190) dbroot.mainloop()
def updatestudent(): def update(): id = idval.get() name = nameval.get() mobile = mobileval.get() email = emailval.get() address = addressval.get() gender = genderval.get() dob = dobval.get() date = dateval.get() time = timeval.get() strr = 'update studentdata1 set name=%s,mobile=%s,email=%s,address=%s,gender=%s,dob=%s,date=%s,time=%s where id=%s' mycursor.execute( strr, (name, mobile, email, address, gender, dob, date, time, id)) con.commit() messagebox.showinfo('Notifications', 'Id {} Modified sucessfully...'.format(id), parent=updateroot) strr = 'select *from studentdata1' mycursor.execute(strr) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) updateroot = Toplevel(master=DataEntryFrame) updateroot.grab_set() updateroot.geometry('470x585+220+160') updateroot.title('Student Management System') updateroot.config(bg='firebrick1') updateroot.iconbitmap('mana.ico') updateroot.resizable(False, False) #--------------------------------------------------- Add studenmt Labels idlabel = Label(updateroot, text='Enter Id : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') idlabel.place(x=10, y=10) namelabel = Label(updateroot, text='Enter Name : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') namelabel.place(x=10, y=70) mobilelabel = Label(updateroot, text='Enter Mobile : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') mobilelabel.place(x=10, y=130) emaillabel = Label(updateroot, text='Enter Email : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') emaillabel.place(x=10, y=190) addresslabel = Label(updateroot, text='Enter Address : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') addresslabel.place(x=10, y=250) genderlabel = Label(updateroot, text='Enter Gender : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') genderlabel.place(x=10, y=310) doblabel = Label(updateroot, text='Enter D.O.B : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') doblabel.place(x=10, y=370) datelabel = Label(updateroot, text='Enter Date : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') datelabel.place(x=10, y=430) timelabel = Label(updateroot, text='Enter Time : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') timelabel.place(x=10, y=490) ##----------------------------------------------------------- Add student Entry idval = StringVar() nameval = StringVar() mobileval = StringVar() emailval = StringVar() addressval = StringVar() genderval = StringVar() dobval = StringVar() dateval = StringVar() timeval = StringVar() identry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=idval) identry.place(x=250, y=10) nameentry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=nameval) nameentry.place(x=250, y=70) mobileentry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=mobileval) mobileentry.place(x=250, y=130) emailentry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=idval) emailentry.place(x=250, y=190) addressentry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=addressval) addressentry.place(x=250, y=250) genderentry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=genderval) genderentry.place(x=250, y=310) dobentry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=dobval) dobentry.place(x=250, y=370) dateentry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=dateval) dateentry.place(x=250, y=430) timeentry = Entry(updateroot, font=('roman', 15, 'bold'), bd=5, textvariable=dateval) timeentry.place(x=250, y=490) ############------------------------- add button submitbtn = Button(updateroot, text='Submit', font=('roman', 15, 'bold'), width=20, bd=5, activebackground='blue', activeforeground='white', bg='red', command=update) submitbtn.place(x=150, y=540) cc = studenmttable.focus() content = studenmttable.item(cc) pp = content['values'] if (len(pp) != 0): idval.set(pp[0]) nameval.set(pp[1]) mobileval.set(pp[2]) emailval.set(pp[3]) addressval.set(pp[4]) genderval.set(pp[5]) dobval.set(pp[6]) dateval.set(pp[7]) timeval.set(pp[8]) updateroot.mainloop()
def searchstudent(): def search(): id = idval.get() name = nameval.get() mobile = mobileval.get() email = emailval.get() address = addressval.get() gender = genderval.get() dob = dobval.get() addeddate = time.strftime("%d/%m/%Y") if (id != ''): strr = 'select *from studentdata1 where id=%s' mycursor.execute(strr, (id)) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) elif (name != ''): strr = 'select *from studentdata1 where name=%s' mycursor.execute(strr, (name)) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) elif (mobile != ''): strr = 'select *from studentdata1 where mobile=%s' mycursor.execute(strr, (mobile)) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) elif (email != ''): strr = 'select *from studentdata1 where email=%s' mycursor.execute(strr, (email)) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) elif (address != ''): strr = 'select *from studentdata1 where address=%s' mycursor.execute(strr, (address)) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) elif (gender != ''): strr = 'select *from studentdata1 where gender=%s' mycursor.execute(strr, (gender)) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) elif (dob != ''): strr = 'select *from studentdata1 where dob=%s' mycursor.execute(strr, (dob)) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) elif (addeddate != ''): strr = 'select *from studentdata1 where addeddate=%s' mycursor.execute(strr, (addeddate)) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) searchroot = Toplevel(master=DataEntryFrame) searchroot.grab_set() searchroot.geometry('470x540+220+200') searchroot.title('Student Management System') searchroot.config(bg='firebrick1') searchroot.iconbitmap('mana.ico') searchroot.resizable(False, False) #--------------------------------------------------- Add studenmt Labels idlabel = Label(searchroot, text='Enter Id : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') idlabel.place(x=10, y=10) namelabel = Label(searchroot, text='Enter Name : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') namelabel.place(x=10, y=70) mobilelabel = Label(searchroot, text='Enter Mobile : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') mobilelabel.place(x=10, y=130) emaillabel = Label(searchroot, text='Enter Email : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') emaillabel.place(x=10, y=190) addresslabel = Label(searchroot, text='Enter Address : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') addresslabel.place(x=10, y=250) genderlabel = Label(searchroot, text='Enter Gender : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') genderlabel.place(x=10, y=310) doblabel = Label(searchroot, text='Enter D.O.B : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') doblabel.place(x=10, y=370) datelabel = Label(searchroot, text='Enter Date : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') datelabel.place(x=10, y=430) ##----------------------------------------------------------- Add student Entry idval = StringVar() nameval = StringVar() mobileval = StringVar() emailval = StringVar() addressval = StringVar() genderval = StringVar() dobval = StringVar() dateval = StringVar() identry = Entry(searchroot, font=('roman', 15, 'bold'), bd=5, textvariable=idval) identry.place(x=250, y=10) nameentry = Entry(searchroot, font=('roman', 15, 'bold'), bd=5, textvariable=nameval) nameentry.place(x=250, y=70) mobileentry = Entry(searchroot, font=('roman', 15, 'bold'), bd=5, textvariable=mobileval) mobileentry.place(x=250, y=130) emailentry = Entry(searchroot, font=('roman', 15, 'bold'), bd=5, textvariable=emailval) emailentry.place(x=250, y=190) addressentry = Entry(searchroot, font=('roman', 15, 'bold'), bd=5, textvariable=addressval) addressentry.place(x=250, y=250) genderentry = Entry(searchroot, font=('roman', 15, 'bold'), bd=5, textvariable=genderval) genderentry.place(x=250, y=310) dobentry = Entry(searchroot, font=('roman', 15, 'bold'), bd=5, textvariable=dobval) dobentry.place(x=250, y=370) dateentry = Entry(searchroot, font=('roman', 15, 'bold'), bd=5, textvariable=dateval) dateentry.place(x=250, y=430) ############------------------------- add button submitbtn = Button(searchroot, text='Submit', font=('roman', 15, 'bold'), width=20, bd=5, activebackground='blue', activeforeground='white', bg='red', command=search) submitbtn.place(x=150, y=480) searchroot.mainloop()
def addstudent(): def submitadd(): id = idval.get() name = nameval.get() mobile = mobileval.get() email = emailval.get() address = addressval.get() gender = genderval.get() dob = dobval.get() addedtime = time.strftime("%H:%M:%S") addeddate = time.strftime("%d/%m/%Y") try: strr = 'insert into studentdata1 values(%s,%s,%s,%s,%s,%s,%s,%s,%s)' mycursor.execute(strr, (id, name, mobile, email, address, gender, dob, addeddate, addedtime)) con.commit() res = messagebox.askyesnocancel( 'Notificatrions', 'Id {} Name {} Added sucessfully.. and want to clean the form'. format(id, name), parent=addroot) if (res == True): idval.set('') nameval.set('') mobileval.set('') emailval.set('') addressval.set('') genderval.set('') dobval.set('') except: messagebox.showerror('Notifications', 'Id Already Exist try another id...', parent=addroot) strr = 'select * from studentdata1' mycursor.execute(strr) datas = mycursor.fetchall() studenmttable.delete(*studenmttable.get_children()) for i in datas: vv = [i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]] studenmttable.insert('', END, values=vv) addroot = Toplevel(master=DataEntryFrame) addroot.grab_set() addroot.geometry('470x470+220+200') addroot.title('Student Management System') addroot.config(bg='blue') addroot.iconbitmap('mana.ico') addroot.resizable(False, False) #--------------------------------------------------- Add studenmt Labels idlabel = Label(addroot, text='Enter Id : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') idlabel.place(x=10, y=10) namelabel = Label(addroot, text='Enter Name : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') namelabel.place(x=10, y=70) mobilelabel = Label(addroot, text='Enter Mobile : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') mobilelabel.place(x=10, y=130) emaillabel = Label(addroot, text='Enter Email : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') emaillabel.place(x=10, y=190) addresslabel = Label(addroot, text='Enter Address : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') addresslabel.place(x=10, y=250) genderlabel = Label(addroot, text='Enter Gender : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') genderlabel.place(x=10, y=310) doblabel = Label(addroot, text='Enter D.O.B : ', bg='gold2', font=('times', 20, 'bold'), relief=GROOVE, borderwidth=3, width=12, anchor='w') doblabel.place(x=10, y=370) ##----------------------------------------------------------- Add student Entry idval = StringVar() nameval = StringVar() mobileval = StringVar() emailval = StringVar() addressval = StringVar() genderval = StringVar() dobval = StringVar() identry = Entry(addroot, font=('roman', 15, 'bold'), bd=5, textvariable=idval) identry.place(x=250, y=10) nameentry = Entry(addroot, font=('roman', 15, 'bold'), bd=5, textvariable=nameval) nameentry.place(x=250, y=70) mobileentry = Entry(addroot, font=('roman', 15, 'bold'), bd=5, textvariable=mobileval) mobileentry.place(x=250, y=130) emailentry = Entry(addroot, font=('roman', 15, 'bold'), bd=5, textvariable=emailval) emailentry.place(x=250, y=190) addressentry = Entry(addroot, font=('roman', 15, 'bold'), bd=5, textvariable=addressval) addressentry.place(x=250, y=250) genderentry = Entry(addroot, font=('roman', 15, 'bold'), bd=5, textvariable=genderval) genderentry.place(x=250, y=310) dobentry = Entry(addroot, font=('roman', 15, 'bold'), bd=5, textvariable=dobval) dobentry.place(x=250, y=370) ############------------------------- add button submitbtn = Button(addroot, text='Submit', font=('roman', 15, 'bold'), width=20, bd=5, activebackground='blue', activeforeground='white', bg='red', command=submitadd) submitbtn.place(x=150, y=420) addroot.mainloop()
class FilePane: def __init__(self, root, items=list(), on_selection=list(), on_close=list()): self.items = items self.item_count = len(items) self.on_selection = on_selection self.on_close = on_close self.window = Toplevel() self.window.title('Files') self.window.transient(root) self.window.protocol("WM_DELETE_WINDOW", self.on_window_close) self.menubar = Menu(self.window) self.menubar.add_command(label='Previous', command=self.previous) self.menubar.add_command(label='Next', command=self.next) # Display the menu self.window.config(menu=self.menubar) self.scrollbar = Scrollbar(self.window, orient='vertical') self.listbox = Listbox(self.window, yscrollcommand=self.scrollbar.set, exportselection=False) self.set_items(items) self.scrollbar.config(command=self.listbox.yview) self.scrollbar.pack(side='right', fill='y') self.listbox.pack(side='left', fill='both', expand=1) self.listbox.bind('<<ListboxSelect>>', self.on_select) def on_window_close(self): for callback in self.on_close: callback() self.window.withdraw() def hide(self): self.window.withdraw() def show(self): self.window.deiconify() def selected_item(self): return self.items[self.listbox.curselection()[0]] def select_index(self, index): self.listbox.selection_clear(0, END) # From https://stackoverflow.com/a/25451279/11628429 self.listbox.select_set( index) #This only sets focus on the first item. self.listbox.event_generate("<<ListboxSelect>>") def set_items(self, items): self.items = items self.item_count = len(items) self.listbox.delete(0, END) for item in items: item = path.split(item)[1] self.listbox.insert(END, item) self.select_index(0) def previous(self): index = self.listbox.curselection()[0] - 1 if index < 0: index = self.item_count - 1 self.select_index(index) def next(self): index = self.listbox.curselection()[0] + 1 if index >= self.item_count: index = 0 self.select_index(index) def on_select(self, event): if self.on_selection: for callback in self.on_selection: callback(self.selected_item())
def doctors(): global enter_city, doc doc = Toplevel() doc.geometry('600x300') doc.resizable(0, 0) doc.configure(background='AntiqueWhite1') doc.title('Doctors') menu = Menu(root) option = Menu(menu, tearoff=0) option.add_command(label='Info', command=info) option.add_separator() option.add_command(label="Exit", command=root.quit) menu.add_cascade(label="About", menu=option) help = Menu(menu, tearoff=0) help.add_command(label='Doctor info', command=doctors) menu.add_cascade(label="Help", menu=help) root.config(menu=menu) doc_menu = Menu(doc) doc_option = Menu(doc_menu, tearoff=0) doc_option.add_command(label='Info', command=info) doc_option.add_separator() doc_option.add_command(label="Exit", command=doc.destroy) doc_menu.add_cascade(label="About", menu=doc_option) doc_help = Menu(doc_menu, tearoff=0) doc_help.add_command(label='Doctor info', command=doctors) doc_menu.add_cascade(label="Help", menu=doc_help) doc.config(menu=doc_menu) doc_img = Image.open('doctor.jpg').convert('RGB') doc_img = doc_img.resize((int(150), int(150)), Image.ANTIALIAS) doc_img.save('doc.ppm', 'ppm') doc_img = PhotoImage(file='doc.ppm') details = Label(doc, text='Download Details', font=('bold', 15), bg='AntiqueWhite1', fg='black') details.place(x=230, y=20) label = Label(doc, image=doc_img) label.place(x=370, y=80) city = Label(doc, text='City', font=('bold', 13), bg='AntiqueWhite1') city.place(x=70, y=120) enter_city = Entry(doc, bg='white', fg='black') enter_city.place(x=120, y=122) dload = Button(doc, text='Download', font=('bold', 11), bg='white', fg='black', activebackground='orange', command=download) dload.place(x=85, y=150) doc.mainloop()
class GUI: def __init__(self): self.window = Tk() self.window.title('Battle Tree Builder') #Strength Arrays self.nor = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.fig = np.array( [1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0]) self.fly = np.array( [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) self.poi = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) self.gro = np.array( [0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0]) self.roc = np.array( [0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]) self.buu = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0]) self.gho = np.array( [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]) self.ste = np.array( [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1]) self.fir = np.array( [0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0]) self.wat = np.array( [0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]) self.gra = np.array( [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]) self.ele = np.array( [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]) self.psy = np.array( [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.icc = np.array( [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0]) self.dra = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]) self.dar = np.array( [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]) self.fai = np.array( [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]) #Weak Arrays + Strength Arrays self.normal = np.array( [0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + self.nor self.fighting = np.array([ 0, 0, -1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, -1 ]) + self.fig self.flying = np.array([ 0, 1, 0, 0, 1, -1, 1, 0, 0, 0, 0, 1, -1, 0, -1, 0, 0, 0 ]) + self.fly self.poison = np.array([ 0, 1, 0, 1, -1, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1 ]) + self.poi self.ground = np.array([ 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, -1, -1, 1, 0, -1, 0, 0, 0 ]) + self.gro self.rock = np.array([ 1, -1, 1, 1, -1, 0, 0, 0, -1, 1, -1, -1, 0, 0, 0, 0, 0, 0 ]) + self.roc self.bug = np.array([ 0, 1, -1, 0, 1, -1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 0, 0 ]) + self.buu self.ghost = np.array([ 1, 1, 0, 1, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 ]) + self.gho self.steel = np.array([ 1, -1, 1, 1, -1, 1, 1, 0, 1, -1, 0, 1, 0, 1, 1, 1, 0, 1 ]) + self.ste self.fire = np.array([ 0, 0, 0, 0, -1, -1, 1, 0, 1, 1, -1, 1, 0, 0, 1, 0, 0, 1 ]) + self.fir self.water = np.array([ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, -1, -1, 0, 1, 0, 0, 0 ]) + self.wat self.grass = np.array([ 0, 0, -1, -1, 1, 0, -1, 0, 0, -1, 1, 1, 1, 0, -1, 0, 0, 0 ]) + self.gra self.electric = np.array( [0, 0, 1, 0, -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0]) + self.ele self.psychic = np.array([ 0, 1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0 ]) + self.psy self.ice = np.array([ 0, -1, 0, 0, 0, -1, 0, 0, -1, -1, 0, 0, 0, 0, 1, 0, 0, 0 ]) + self.icc self.dragon = np.array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, -1, -1, 0, -1 ]) + self.dra self.dark = np.array([ 0, -1, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, -1 ]) + self.dar self.fairy = np.array([ 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1, 1, 0 ]) + self.fai self.none = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.A = np.column_stack(([ self.normal, self.fighting, self.flying, self.poison, self.ground, self.rock, self.bug, self.ghost, self.steel, self.fire, self.water, self.grass, self.electric, self.psychic, self.ice, self.dragon, self.dark, self.fairy ])) frame1 = Frame(self.window) frame2 = Frame(self.window) frame3 = Frame(self.window) self.frame4 = Frame(self.window) Label(frame1, text='Welcome to the Battle Tree Builder v1.0!').grid(row=0) Label(frame1, text='Please pick the typing of your two Pokemon:\n').grid(row=1) #Dropdown with options for picking types Label(frame2, text='First Pokemon:').grid(column=0, row=2) self.type11 = tkinter.StringVar(frame2) self.type11.set('none') self.w11 = OptionMenu(frame2, self.type11, 'none', 'normal', 'fighting', 'flying', 'poison', 'ground', 'rock', 'bug', 'ghost', 'steel', 'fire', 'water', 'grass', 'electric', 'psychic', 'ice', 'dragon', 'dark', 'fairy').grid(column=0, row=3) self.type12 = tkinter.StringVar(frame2) self.type12.set('none') self.w12 = OptionMenu(frame2, self.type12, 'none', 'normal', 'fighting', 'flying', 'poison', 'ground', 'rock', 'bug', 'ghost', 'steel', 'fire', 'water', 'grass', 'electric', 'psychic', 'ice', 'dragon', 'dark', 'fairy').grid(column=0, row=4) Label(frame2, text='Second Pokemon:').grid(column=1, row=2) self.type21 = tkinter.StringVar(frame3) self.type21.set('none') self.w21 = OptionMenu(frame2, self.type21, 'none', 'normal', 'fighting', 'flying', 'poison', 'ground', 'rock', 'bug', 'ghost', 'steel', 'fire', 'water', 'grass', 'electric', 'psychic', 'ice', 'dragon', 'dark', 'fairy').grid(column=1, row=3) self.type22 = tkinter.StringVar(frame3) self.type22.set('none') self.w22 = OptionMenu(frame2, self.type22, 'none', 'normal', 'fighting', 'flying', 'poison', 'ground', 'rock', 'bug', 'ghost', 'steel', 'fire', 'water', 'grass', 'electric', 'psychic', 'ice', 'dragon', 'dark', 'fairy').grid(column=1, row=4) Button(frame3, text='Okay', command=self.clear).pack() frame1.grid() frame2.grid() frame3.grid() self.frame4.grid() tkinter.mainloop() def clear(self): self.frame4.destroy() self.checkbox() def checkbox(self): self.frame4 = Frame(self.window) self.frame4.grid() self.pika = {} self.pika["normal"] = np.array( [0, -1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.pika["fighting"] = np.array( [0, 0, -1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, -1, 0]) self.pika["flying"] = np.array( [0, 1, 0, 0, 2, -1, 1, 0, 0, 0, 0, 1, -1, 0, -1, 0, 0, 0, 0]) self.pika["poison"] = np.array( [0, 1, 0, 1, -1, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1, 0]) self.pika["ground"] = np.array( [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, -1, -1, 1, 0, -1, 0, 0, 0, 0]) self.pika["rock"] = np.array( [1, -1, 1, 1, -1, 0, 0, 0, -1, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0]) self.pika["bug"] = np.array( [0, 1, -1, 0, 1, -1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0]) self.pika["ghost"] = np.array( [2, 1, 0, 1, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0]) self.pika["steel"] = np.array( [1, -1, 1, 2, -1, 1, 1, 0, 1, -1, 0, 1, 0, 1, 1, 1, 0, 1, 0]) self.pika["fire"] = np.array( [0, 0, 0, 0, -1, -1, 1, 0, 1, 1, -1, 1, 0, 0, 1, 0, 0, 1, 0]) self.pika["water"] = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, -1, -1, 0, 1, 0, 0, 0, 0]) self.pika["grass"] = np.array( [0, 0, -1, -1, 1, 0, -1, 0, 0, -1, 1, 1, 1, 0, -1, 0, 0, 0, 0]) self.pika["electric"] = np.array( [0, 0, 1, 0, -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) self.pika["psychic"] = np.array( [0, 1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0]) self.pika["ice"] = np.array( [0, -1, 0, 0, 0, -1, 0, 0, -1, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0]) self.pika["dragon"] = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, -1, -1, 0, -1, 0]) self.pika["dark"] = np.array( [0, -1, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 2, 0, 0, 1, -1, 0]) self.pika["fairy"] = np.array( [0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0]) self.pika["none"] = np.array( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) self.value = {} self.value[0] = "Normal" self.value[1] = "Fighting" self.value[2] = "Flying" self.value[3] = "Poison" self.value[4] = "Ground" self.value[5] = "Rock" self.value[6] = "Bug" self.value[7] = "Ghost" self.value[8] = "Steel" self.value[9] = "Fire" self.value[10] = "Water" self.value[11] = "Grass" self.value[12] = "Electric" self.value[13] = "Psychic" self.value[14] = "Ice" self.value[15] = "Dragon" self.value[16] = "Dark" self.value[17] = "Fairy" self.poke = self.pika[self.type11.get()] + self.pika[self.type12.get( )] + self.pika[self.type21.get()] + self.pika[self.type22.get()] for t in range(len(self.poke)): if self.poke[t] < 0: self.poke[t] = -1 elif self.poke[t] > 0: self.poke[t] = 1 else: continue #Identify what the Pokemon are weak to weak = any(self.poke < 0) p = np.linspace(0, 0, len(self.poke)) if weak == True: for t in range(len(self.poke)): if self.poke[t] < 0: p[t] = 1 else: p[t] = 0 elif self.type11.get() == 'none' and self.type12.get( ) == 'none' and self.type21.get() == 'none' and self.type22.get( ) == 'none': Label(self.frame4, text="bitch").grid() else: Label(self.frame4, text="....your team has no weaknesses....").grid() self.q = [] for t in range(len(p)): if p[t] == 1: self.q.append(t) else: continue #print(p,self.q) #GUI stuff #For 1 weakness self.cb = [] self.cbv = [] for t in range(0, len(self.q)): self.cbv.append('') self.cbv[t] = IntVar() self.cbv[t].set(1) for t in range(0, len(self.q)): self.cb.append( Checkbutton(self.frame4, text=str(self.value[self.q[t]]), variable=self.cbv[t])) for t in range(0, len(self.q)): self.cb[t].grid() if weak == True: Button(self.frame4, text='Okay', command=self.results).grid() def results(self): #Checks over all possible combinations self.win = Toplevel(master=self.window, height=500, width=500) self.win.title('Results') scroll = Scrollbar(self.win) scroll.pack(side='right', fill='y') self.listbox = tkinter.Listbox(self.win, width=25) self.listbox.config(yscrollcommand=scroll.set) scroll.config(command=self.listbox.yview) for u in range(0, 18): for v in range(u, 18): self.combo = self.A[:, u] + self.A[:, v] for t in range(0, 18): if self.combo[t] < 0: self.combo[t] = -1 elif self.combo[t] > 0: self.combo[t] = 1 else: continue bin = '' for t in range(0, len(self.q)): if t == 0: bin += '[self.cbv[' + str(t) + '].get()' elif t <= (len(self.q) - 1): bin += ',self.cbv[' + str(t) + '].get()' if t == len(self.q) - 1: bin += ']' bin = eval(bin) h = [ ] #h the array containing the indices of q corresponding to which boxes are checked for t in range(len(bin)): if bin[t] == 1: h.append(t) else: continue cond = '' for t in range(0, len(h)): cond += 'self.combo[self.q[h[' + str( t) + ']]]==-self.poke[self.q[h[' + str(t) + ']]]' if t < (len(h) - 1): cond += ' and ' if eval(cond): if u == v: self.listbox.insert(1, self.value[u]) else: self.listbox.insert( 1, self.value[u] + " " + self.value[v]) self.listbox.insert(tkinter.END, ' ') self.listbox.insert(tkinter.END, 'End of Results') self.listbox.pack() self.menu() def menu(self): menubar = Menu(self.win) file = Menu(menubar, tearoff=0) file.add_command(label='Save Results', command=self.save) file.add_command(label='Exit', command=self.win.destroy) menubar.add_cascade(label='File', menu=file) self.win.config(menu=menubar) def save(self): global filename f = asksaveasfile(mode='w', defaultextension='.txt') results = self.listbox.get(0, tkinter.END) try: f.write('Working Team:\n') f.write(self.type11.get().capitalize() + ' ' + self.type12.get().capitalize() + '\n') f.write(self.type21.get().capitalize() + ' ' + self.type22.get().capitalize() + '\n\n') f.write('Possible Friends:\n') for t in range(0, self.listbox.size() - 1): f.write(results[t] + '\n') f.close() except: return