please patient me, 16 years old, started programming last year september on codeacademy. anyway, i'm creating program can end of term grade math have been told school may want use it. have make gui pretty , whatnot , doing came across problem, grid doesn't work ".pack()" widgets in same window such "root" question is:
how move things grid , place them want without such limiting scope of "left,right,bottom,top"
here code:
from tkinter import * import tkinter.messagebox import os tkinter import font tkinter import ttk root = tk() root.geometry("800x500") root.configure(background="grey") root.title("mathematical assistance program") #********functions**********# def about(): beep = tkinter.messagebox.askquestion("about", "m.a.p created mykel mills using amazing programming skills math awesome or what?") if beep == "yes": tkinter.messagebox.showinfo("thanks", "thank much!") else: os.startfile("killthem.flv") def author(): authorwindow = toplevel() authorwindow.geometry("500x200") authorwindow.title("the developer") photo = photoimage(file="pain.gif") label1 = label(authorwindow, image=photo) label1.image = photo label1.grid(row=0, column=0) def addingmatrices(): os.startfile("madd.mp4") tkinter.messagebox.showinfo("here", "i've opened pdf questions.") os.startfile("1.pdf") def multiplymatrices(): os.startfile("mm1.mp4") tkinter.messagebox.showinfo("part 2", "let's begin part 2!") os.startfile("mm2.mp4") tkinter.messagebox.showinfo("worksheet", "i'll open worksheet you!") os.startfile("mm.pdf") #*******menu , sub menu**********# menu = menu(root) root.config(menu=menu) submenu = menu(menu) cssubmenu = menu(menu) matrixsubmenu = menu(menu) menu.add_cascade(label="home", menu=submenu) menu.add_cascade(label="choose topic", menu=cssubmenu) submenu.add_command(label="about", command=about) submenu.add_command(label="developer", command=author) submenu.add_separator() submenu.add_command(label="help", command=root.quit) submenu.add_command(label="quit", command=root.quit) matrixsubmenu.add_command(label="adding , subtracting matrices", command=addingmatrices) matrixsubmenu.add_command(label="multiplying matrices", command=multiplymatrices) cssubmenu.add_cascade(label="matrices", menu=matrixsubmenu) cssubmenu.add_command(label="vectors", command=root.quit) cssubmenu.add_command(label="circle theorom", command=root.quit) cssubmenu.add_command(label="algebra", command=root.quit) #*********status bar**********# status = label(root, text="welcome m.a.p, host today, name bob, please request clicking button", bd=1, relief=sunken, anchor=w) status.pack(side=bottom, fill=x) #**********to list****************** lf = labelframe(root, text="to do", padx=5, pady=5, bg="grey") lf.pack(side=left) label = label(lf, text="1. add vector videos , questions", bg="grey") label1 = label(lf, text="2. complete other possible topics", bg="grey") label2 = label(lf, text="3. create ui more user friendly", bg="grey") label3 = label(lf, text="4. create point system rewards", bg="grey") label4 = label(lf, text="5. design i.em.s possible ", bg="grey") label.pack() label1.pack() label2.pack() label3.pack() label4.pack() #*******home page title********* label5 = label(root, text="m.a.p", font=("helvetica", 50), bg="grey") label5.pack(side=top) root.mainloop()
thanks million!
use .place()
in absolute positioning, programmer specifies position , size of each widget in pixels. size , position of widget not change if resize window.
.place() uses x , y coordinates specify placement on window.
example:
label.place(x=40, y=50)
here's url full explanation of .pack() , .grid() , .place(): http://zetcode.com/gui/tkinter/layout/
please note: .grid() better , more organized way make tkinter window. not limited think, if use sticky argument (which allows more specific single cell). won't go far grid, since isn't part of question. rather use .grid() .place()
Comments
Post a Comment