Advertisement
Guest User

how to 45 minute break

a guest
Apr 19th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. from tkinter import *
  2. import random
  3.  
  4. window = Tk()
  5. window.title("Random Story Generator v1")
  6.  
  7. Starts = ["From the crow's nest of your ship your first mate yells down a story about ","Once there was ","Once upon a time there was ","One day while walking in the woods you encountered ","While in a plane you look out the window and see ", "While peering into a doorway to an alternate reality you witness "]
  8. Subject = ["a pirate ","a potato ","a magical flying octopus ","a traveling salesman ", "a sentient rock ", "a giant tuna "]
  9. Action = ["that stared blankly into your soul.","that was said he was your father.","that died.","that danced a merry pirate jig.","that did absolutely nothing.","that told you the secrets of the universe.", "riding a shark."]
  10.  
  11. def Generate():
  12.     File = open("RandomFile.txt", "w")
  13.     random.shuffle(Starts)
  14.     random.shuffle(Subject)
  15.     random.shuffle(Action)
  16.     File.write(Starts[0])
  17.     File.write(Subject[0])
  18.     File.write(Action[0])
  19.     File.close()
  20.    
  21.     Story = open("RandomFile.txt", "r")
  22.     Lines = Story.read()
  23.     messagebox.showinfo("Story", Lines)
  24.     Story.close()
  25.    
  26.  
  27. Button = Button(window, text = "Begin your journey", command = Generate).pack()
  28.  
  29. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement