Advertisement
Guest User

Python issue

a guest
Oct 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. # By: Andrew Seemann
  2.  
  3. from graphics import *
  4.  
  5. def main():
  6.     print("This program creates a scene from a given file")
  7.     print()
  8.  
  9.     # Get the file
  10.     infileName = input("What is the name of the text file?")
  11.     infile = open(infileName, "r")
  12.  
  13.     # Line 1 - Window Size
  14.     window = infile.readline().split(" ")
  15.     windowWidth = window[0]
  16.     windowHeight = window[1]
  17.  
  18.     # Line 2 - Coords
  19.     coords = infile.readline().split(" ")
  20.     coords1 = coords[0:2]
  21.     coords2 = coords[2:4]
  22.  
  23.     # Window and Coords
  24.     win = GraphWin("Test", windowWidth, windowHeight)
  25.     win.setCoords(int(coords1[0]), int(coords1[1]), int(coords2[0])
  26.                   , int(coords2[1]))
  27.  
  28.     # Line 3 and beyond
  29.     for line in infile:
  30.         line = infile.readline()
  31.         values = line.split()
  32.         red = int(values[0])
  33.         green = int(values[1])
  34.         blue = int(values[2])
  35.         xandy = values[3:]
  36.         points = []
  37.        
  38.         for i in range(0,len(xandy),2):
  39.             x = xandy[i]
  40.             y = xandy[i + 1]
  41.             aPoint = Point(x,y)
  42.             points.append(aPoint)
  43.             print(points)
  44.             line = infile.readline()
  45.  
  46.             #polygon = points.getPoints()              
  47.             #polygon.setFill(color_rgb(red, green, blue))
  48.  
  49.             #polygon.draw(win)
  50.                
  51.    
  52.     win.getMouse()
  53.     win.close()
  54. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement