Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter.ttk import Notebook
  3.  
  4. N = 25
  5.  
  6. class IterEntryField:
  7. def __init__(self, frame, label):
  8. self.frame = frame
  9. self.label = label
  10. def pack(self):
  11. self.valLabel = Label(self.frame, text = self.label, anchor = 'w')
  12. self.valLabel.pack(side = LEFT)
  13. self.variable = StringVar()
  14. self.variable.set('0')
  15. self.valEntry = Entry(self.frame, textvariable = self.variable)
  16. self.valEntry.pack(side = RIGHT)
  17.  
  18. def notebookpopup():
  19. zSetupWindow = Toplevel(root)
  20. zSetupWindow.geometry('{}x{}'.format(800, 300))
  21. notebook = Notebook(zSetupWindow)
  22.  
  23. evspace = Frame(notebook)
  24. notebook.add(evspace, text = "Evenly spaced values")
  25.  
  26. sOverflow = Label(evspace, text = 'Ignore this')
  27. sOverflow.pack()
  28.  
  29. uevspace = Frame(notebook)
  30. notebook.add(uevspace, text = "Individual values")
  31. canvas = Canvas(uevspace)
  32. vsb = Scrollbar(canvas, command=canvas.yview)
  33. canvas.config(yscrollcommand = vsb.set)
  34. canvas.pack(side = LEFT, fill = BOTH, expand = True)
  35. vsb.pack(side = RIGHT, fill = Y, expand = True)
  36. entryContainer = Frame(canvas)
  37. entryContainer.pack(expand = True)
  38.  
  39. frameDict = {}
  40.  
  41. for i in range(0, N):
  42. frameDict[i] = Frame(entryContainer)
  43. frameDict[i].pack()
  44. entry = IterEntryField(frameDict[i], 'Z value for subfile {}'.format(i+1))
  45. entry.pack()
  46. canvas.create_window(0, 0, window = entryContainer, anchor = 'nw')
  47. root.update()
  48. print()
  49. canvas.config(scrollregion = canvas.bbox('all'))
  50. notebook.pack(fill = BOTH, expand = True)
  51.  
  52. root = Tk()
  53. button = Button(root, text = 'new window', command = notebookpopup)
  54. button.pack()
  55.  
  56. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement