Advertisement
Guest User

Untitled

a guest
May 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. #! /usr/bin/env python
  2.  
  3. from Tkinter import *
  4. #from twitter import *
  5. import sys
  6.  
  7. def Quit():
  8. RealRoot.destroy()
  9.  
  10. class TopWindow(Toplevel):
  11.  
  12. def __init__(self,name,**k):
  13. Toplevel.__init__(self,border=4,**k)
  14. self.master.withdraw() # hide real tk root
  15. self.title(name)
  16.  
  17. def run(self):
  18. self.center()
  19. self.focus()
  20. self.wait_window()
  21.  
  22. def focus(self):
  23. self.grab_set()
  24. self.focus_set()
  25.  
  26. def center(self):
  27. self.update_idletasks()
  28. w= self["width"]!=0 and self["width"] or self.winfo_width()
  29. h= self["height"]!=0 and self["height"] or self.winfo_height()
  30. ws,hs = self.winfo_screenwidth(),self.winfo_screenheight()
  31. self.geometry('%dx%d+%d+%d' % (w, h, (ws/2) - (w/2), (hs/2) - (h/2)))
  32.  
  33.  
  34. RealRoot=Tk()
  35.  
  36. RealRoot.title("Jason Twitter Client")
  37. RealRoot.config(bg="light blue")
  38. RealRoot.protocol("WM_DELETE_WINDOW",RealRoot.quit)
  39.  
  40.  
  41. Root=TopWindow("Jason Twitter Client")
  42. Root.protocol("WM_DELETE_WINDOW",RealRoot.quit)
  43. Status=Label(Root,text="Status:",bg="light blue")
  44. Status.grid(column=1,row=0,sticky=N+S+E+W)
  45.  
  46. StatusText=Text(Root,bg="white",height=2)
  47. StatusText.grid(column=2,row=0,columnspan=5,sticky=N+S+E+W)
  48.  
  49. Refresh=Button(Root,text="Refresh")
  50. Refresh.grid(column=8,row=0,sticky=N+S+E+W)
  51.  
  52. DisplayScroll=Scrollbar(Root,orient=VERTICAL)
  53. DisplayScroll.grid(column=8,row=2,rowspan=8,sticky=N+S+W)
  54.  
  55. Display=Text(Root,bg="white",yscrollcommand=DisplayScroll.set)
  56. Display.grid(column=3,row=2,columnspan=5,rowspan=9,sticky=N+S+E+W)
  57.  
  58. DisplayScroll["command"]=Display.yview
  59.  
  60. Home=Button(Root,text="Home")
  61. Home.grid(column=0,row=1,sticky=N+S+E+W)
  62.  
  63. Profile=Button(Root,text="Profile")
  64. Profile.grid(column=1,row=1,sticky=N+S+E+W)
  65.  
  66. ChoiceVar=IntVar()
  67.  
  68. FriendChoice=Radiobutton(Root,text="Friends",variable=ChoiceVar,value=0,bg="light blue")
  69. FriendChoice.grid(column=0,row=2,columnspan=2,sticky=W)
  70.  
  71. FollowerChoice=Radiobutton(Root,text="Followers",variable=ChoiceVar,value=1,bg="light blue")
  72. FollowerChoice.grid(column=0,row=3,columnspan=2,sticky=W)
  73.  
  74. UserScroll=Scrollbar(Root,orient=VERTICAL)
  75. UserScroll.grid(column=2,row=4,rowspan=5,sticky=N+S)
  76.  
  77. Users=Listbox(Root,bg="white",height=15,yscrollcommand=UserScroll.set)
  78. Users.grid(column=0,row=4,rowspan=5,columnspan=2)
  79.  
  80. UserScroll["command"]=Users.yview
  81.  
  82. Search=Label(Root,text="Search:")
  83. Search.grid(column=3,row=1,sticky=N+S+E+W)
  84.  
  85. SearchText=Entry(Root,bg="white")
  86. SearchText.grid(column=4,row=1,columnspan=3,sticky=N+S+E+W)
  87.  
  88. SearchButton=Button(Root,text="Search")
  89. SearchButton.grid(column=8,row=1,sticky=N+S+E+W)
  90.  
  91. TweetLabel=Label(Root,text="Tweet:")
  92. TweetLabel.grid(column=3,row=10,sticky=N+S+E+W)
  93.  
  94. TweetText=Entry(Root,bg="white")
  95. TweetText.grid(column=4,row=10,columnspan=3,sticky=N+S+E+W)
  96.  
  97. TweetButton=Button(Root,text="Tweet")
  98. TweetButton.grid(column=8,row=10,sticky=N+S+E+W)
  99.  
  100. CharsLeft=Message(Root,text="140",bg="light blue")
  101. CharsLeft.grid(column=8,row=9)
  102.  
  103. Root.run()
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112. CredWindow=TopWindow("User Credentials")
  113. CredText=Label(CredWindow,text="Welcome to pyTweet!")
  114. CredText.grid(column=0,row=0,columnspan=2,sticky=N+S+E+W)
  115.  
  116. UsernameText=Label(CredWindow,text="Username:")
  117. UsernameText.grid(column=0,row=1,sticky=N+S+E+W)
  118.  
  119. PasswordText=Label(CredWindow,text="Password:")
  120. PasswordText.grid(column=0,row=2,sticky=N+S+E+W)
  121.  
  122. UsernameEntry=Entry(CredWindow)
  123. UsernameEntry.grid(column=1,row=1,sticky=N+S+E+W)
  124.  
  125. PasswordEntry=Entry(CredWindow,show="*")
  126. PasswordEntry.grid(column=1,row=2,sticky=N+S+E+W)
  127.  
  128. LoginButton=Button(CredWindow,text="Login")
  129. LoginButton.grid(column=0,row=3,columnspan=2)
  130.  
  131. CredWindow.run()
  132.  
  133. #class FriendWindow:
  134. # def __init__(self)
  135. #
  136. # def Makefwin:
  137. # Fwin=Toplevel()
  138. # InfoPane=Text(Fwin)
  139. # InfoPane.grid(column=2,row=0,columnspan=8,rowspan=8,sticky=N+S+E+W)
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146. Root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement