Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. #!/usr/bin/python
  2. #!/home/lubuntu/subscription_app
  3.  
  4. from Tkinter import *
  5. from ttk import *
  6.  
  7. class members(Frame):
  8.  
  9. def __init__(self, parent):
  10. self.parent = parent
  11. Frame.__init__(self, parent)
  12. # add all "def xx()" to show on Frame
  13. self.initUI()
  14. self.entries()
  15. self.buttons()
  16. self.txt_label()
  17. self.centerWindow()
  18.  
  19. def initUI(self):
  20. # parent border of Frame
  21. self.parent.title("Ocean State Reef Aquarium Society")
  22. self.pack(expand=TRUE, fill=BOTH)
  23.  
  24. def centerWindow(self):
  25. # centers main window when opened
  26. w = 600
  27. h = 500
  28. sw = self.parent.winfo_screenwidth()
  29. sh = self.parent.winfo_screenheight()
  30. x = (sw - w)/2
  31. y = (sh - h)/2
  32. self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
  33. # expand main frame
  34. Grid.rowconfigure(self, 0, weight=1)
  35. Grid.rowconfigure(self, 1, weight=1)
  36. Grid.rowconfigure(self, 2, weight=1)
  37. Grid.columnconfigure(self, 0, weight=1)
  38. Grid.columnconfigure(self, 1, weight=1)
  39.  
  40. #### row 0 ####
  41.  
  42. def txt_label(self):
  43. # create the frame
  44. tp_label = Frame(self)
  45. tp_label.grid(row=0, sticky=E+W, pady=10)
  46. # create the label
  47. top_label = Label(tp_label, text="sgdrfgrsfgsgfds")
  48. # grid the label
  49. top_label.grid(sticky=E+W)
  50. # expand labels
  51. Grid.rowconfigure(tp_label, 0, weight=1)
  52. Grid.columnconfigure(tp_label, 0, weight=1)
  53.  
  54. #### row 1-6 ####
  55.  
  56. def entries(self):
  57. # create the frame
  58. entry = Frame(self)
  59. entry.grid(row=1, sticky=E+W+N+S)
  60. # create the entry boxes
  61. date_entry = Entry(entry)
  62. name_entry_first = Entry(entry)
  63. name_entry_last = Entry(entry)
  64. username_entry = Entry(entry)
  65. password_entry = Entry(entry)
  66. email_entry = Entry(entry)
  67. # create the labels
  68. date_label = Label(entry, text="Date:")
  69. name_label_first = Label(entry, text="First Name:")
  70. name_label_last = Label(entry, text="Last Name:")
  71. username_label = Label(entry, text="Username:")
  72. password_label = Label(entry, text="Password:")
  73. email_label = Label(entry, text="Email:")
  74. # grid the entry boxes into frame
  75. date_entry.grid(row=1, column=1, sticky=E+W+N+S, pady=5)
  76. name_entry_first.grid(row=2, column=1, sticky=E+W+N+S, pady=5)
  77. name_entry_last.grid(row=3, column=1, sticky=E+W+N+S, pady=5)
  78. username_entry.grid(row=4, column=1, sticky=E+W+N+S, pady=5)
  79. password_entry.grid(row=5, column=1, sticky=E+W+N+S, pady=5)
  80. email_entry.grid(row=6, column=1, sticky=E+W+N+S, pady=5)
  81. # grid the labels into frame
  82. date_label.grid(row=1, sticky=E+W+N+S)
  83. name_label_first.grid(row=2, sticky=E+W+N+S,pady=5)
  84. name_label_last.grid(row=3, sticky=E+W+N+S,pady=5)
  85. username_label.grid(row=4, sticky=E+W+N+S, pady=5)
  86. password_label.grid(row=5, sticky=E+W+N+S,pady=5)
  87. email_label.grid(row=6, sticky=E+W+N+S, pady=5)
  88. # expand entry frames
  89. Grid.rowconfigure(entry, 1, weight=1)
  90. Grid.rowconfigure(entry, 2, weight=1)
  91. Grid.rowconfigure(entry, 3, weight=1)
  92. Grid.rowconfigure(entry, 4, weight=1)
  93. Grid.rowconfigure(entry, 5, weight=1)
  94. Grid.rowconfigure(entry, 6, weight=1)
  95. Grid.rowconfigure(entry, 7, weight=1)
  96. Grid.columnconfigure(entry, 0, weight=1)
  97. Grid.columnconfigure(entry, 1, weight=1)
  98.  
  99. #### row 7 ####
  100.  
  101. def buttons(self):
  102. # create the frame
  103. buttons = Frame(self)
  104. buttons.grid(row=7, sticky=W+E, pady=5)
  105. # create the buttons
  106. button_save = Button(buttons, text="Save entry to database")
  107. # grid the buttons
  108. button_save.grid(row=0, sticky=W+E)
  109. # expand buttons
  110. Grid.rowconfigure(buttons, 0, weight=1)
  111. Grid.columnconfigure(buttons, 0, weight=1)
  112.  
  113. def main():
  114.  
  115. root = Tk()
  116. app = members(root)
  117. root.mainloop()
  118.  
  119. if __name__ == '__main__':
  120. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement