Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def addBox():
- labelframe = Tkinter.Frame()
- labelframe.bind("<Add Input>", callback)
- labelframe.pack()
- labelframe = Tkinter.Frame()
- labelFrom = Tkinter.Label(labelframe, text= "from")
- labelFrom.grid(column=1, row=0)
- e = Tkinter.Entry(labelframe)
- e.grid(column=1, row=1)
- labelTo = Tkinter.Label(labelframe, text= "to")
- labelTo.grid(column=2, row=0)
- e2 = Tkinter.Entry(labelframe)
- e2.grid(column=2, row=1)
- labelframe.pack()
- addboxButton = Button( root,text='<Add Time Input>', fg="Red",command="addBox")
- addboxButton.pack(side=Tkinter.TOP)
- from Tkinter import *
- #------------------------------------
- def addBox():
- print "ADD"
- ent = Entry(root)
- ent.pack()
- all_entries.append( ent )
- #------------------------------------
- def showEntries():
- for number, ent in enumerate(all_entries):
- print number, ent.get()
- #------------------------------------
- all_entries = []
- root = Tk()
- showButton = Button(root, text='Show all text', command=showEntries)
- showButton.pack()
- addboxButton = Button(root, text='<Add Time Input>', fg="Red", command=addBox)
- addboxButton.pack()
- root.mainloop()
- #------------------------------------
- from Tkinter import *
- #------------------------------------
- def addBox():
- print "ADD"
- # I use len(all_entries) to get nuber of next free column
- next_column = len(all_entries)
- # add label in first row
- lab = Label(frame_for_boxes, text=str(next_column+1))
- lab.grid(row=0, column=next_column)
- # add entry in second row
- ent = Entry(frame_for_boxes)
- ent.grid(row=1, column=next_column)
- all_entries.append( ent )
- #------------------------------------
- def showEntries():
- for number, ent in enumerate(all_entries):
- print number, ent.get()
- #------------------------------------
- all_entries = []
- root = Tk()
- showButton = Button(root, text='Show all text', command=showEntries)
- showButton.pack()
- addboxButton = Button(root, text='<Add Time Input>', fg="Red", command=addBox)
- addboxButton.pack()
- frame_for_boxes = Frame(root)
- frame_for_boxes.pack()
- root.mainloop()
- #------------------------------------
- from Tkinter import *
- #------------------------------------
- def addBox():
- print "ADD"
- frame = Frame(root)
- frame.pack()
- Label(frame, text='From').grid(row=0, column=0)
- ent1 = Entry(frame)
- ent1.grid(row=1, column=0)
- Label(frame, text='To').grid(row=0, column=1)
- ent2 = Entry(frame)
- ent2.grid(row=1, column=1)
- all_entries.append( (ent1, ent2) )
- #------------------------------------
- def showEntries():
- for number, (ent1, ent2) in enumerate(all_entries):
- print number, ent1.get(), ent2.get()
- #------------------------------------
- all_entries = []
- root = Tk()
- showButton = Button(root, text='Show all text', command=showEntries)
- showButton.pack()
- addboxButton = Button(root, text='<Add Time Input>', fg="Red", command=addBox)
- addboxButton.pack()
- root.mainloop()
- #------------------------------------
- class OptionsView(Frame):
- """Frame for options in main window"""
- def __init__(self, x, y, parent):
- Frame.__init__(self, parent)
- self.x = x
- self.y = y
- self.placed = False
- self.hidden = False
- self.btn = Button(self, text = 'Button attached to the frame ..', command = lambda: print('Button in frame clicked ..')).pack()
- def pack(self):
- self.place(x = self.x, y = self.y)
- self.placed = True
- def toggle_view(self):
- if self.hidden:
- self.pack()
- self.hidden = False
- else:
- self.place_forget()
- self.hidden = True
- if __name__ == '__main__':
- def m_frame():
- if val.get() and not options_frame.placed:
- print('Showing Frame ..')
- options_frame.pack()
- else:
- print('Toggling Frame ..')
- options_frame.toggle_view()
- root = Tk()
- root.geometry('300x400+500+600')
- root.title('Testing Hiding Frames ..')
- options_frame = OptionsView(200, 300, root)
- val = BooleanVar(value = False)
- Checkbutton(text = 'View more Options ..', var = val, command = m_frame).place(x=root.winfo_height()/2, y=root.winfo_width()/2)
- try: root.mainloop()
- except e: showerror('Error!', 'It seems there's a problem ..', str(e))
- from Tkinter import *
- frame = Frame(root)
- frame.pack()
- Label(frame, text='From').grid(row=0, column=0)
- ent1 = Entry(frame)
- ent1.grid(row=1, column=0)
- Label(frame, text='To').grid(row=0, column=1)
- ent2 = Entry(frame)
- ent2.grid(row=1, column=1)
- all_entries.append( (ent1, ent2) )
- for number, (ent1, ent2) in enumerate(all_entries):
- print number, ent1.get(), ent2.get()
Add Comment
Please, Sign In to add comment