def __init__(self, parent, lines, game_number=0): self.lines = lines self.auto_mode = False self.game_number = game_number if lines != None: self.lines = shape.list_from_str_list(lines) self.lines_shape_index = 0 self.auto_mode = True """ Intialise the game... """ self.parent = parent self.score = 0 self.level = 0 self.delay = 1000 #ms #lookup table self.shapes = [ square_shape, t_shape, l_shape, reverse_l_shape, z_shape, s_shape, i_shape ] self.thresholds = level_thresholds(500, NO_OF_LEVELS) self.status_bar = status_bar(parent) self.status_bar.pack(side=TOP, fill=X) #print "Status bar width",self.status_bar.cget("width") self.status_bar.set("Score: %-7d\t Level: %d " % (self.score, self.level + 1)) #create the status window self.status_window = StatusWindow(parent) self.status_window.pack() #create the game board self.board = Board(parent, scale=SCALE, max_x=MAXX, max_y=MAXY, offset=OFFSET) self.board.pack(side=BOTTOM) self.board.focus() self.parent.bind("<Left>", self.left_callback) self.parent.bind("<Right>", self.right_callback) self.parent.bind("<Up>", self.up_callback) self.parent.bind("<Down>", self.down_callback) self.parent.bind("a", self.a_callback) self.parent.bind("s", self.s_callback) self.parent.bind("p", self.p_callback) self.parent.bind("q", self.quit_callback) self.shape = self.get_next_shape() self.after_id = self.parent.after(self.delay, self.move_my_shape)
import StatusWindow s_path_of_net_xml = "../data/3choices.net.xml" n_cell_width = 15 sw = StatusWindow.StatusWindow(n_cell_width, s_path_of_net_xml)
import StatusWindow import NavigationWindow s_path_of_net_xml = "./test_map/Davenport.net.xml" s_window_title = "Status Window" n_max_window_width = 1000 n_max_window_height = 600 n_cell_width = 10 n_edge_length_scale = 1 is_cells_mode_on = False is_minimap_mode_on = True sw = StatusWindow.StatusWindow(s_path_of_net_xml) sw.set_window_title(s_window_title) sw.set_window_max_dimensions(n_max_window_width, n_max_window_height) sw.set_edge_length_scale(n_edge_length_scale) sw.set_cell_width(n_cell_width) sw.set_cells_mode(is_cells_mode_on) sw.set_minimap_mode(is_minimap_mode_on) nw = NavigationWindow.NavigationWindow(sw)
def main(): global VERSION global write, log BatchMode = False ##Parse command-line args for i in range(len(sys.argv)): if sys.argv[i] == '-F': # batch mode - get input from control file BatchMode = True try: controlfilename = sys.argv[i + 1] except: sys.stderr.write( "Must supply control file name; falling back to interactive mode\n" ) BatchMode = False options = {} if BatchMode: # create logger instance log = logger.Logger("izterrain.log") # set output function write = log.scrn options = grokCmdFile(controlfilename) if not options: # scream and die print "CANNOT PARSE COMMAND FILE %s. ABORT." % (controlfilename) sys.exit(0) else: ##Convenience variables data_filetypes = (("Reduced Data Files", "*.out"), ("All Files", "*")) dem_filetypes = (("DEM Files", "*.hdr"), ("All Files", "*")) out_filetypes = (("Inner zone TC Files", "*.iztc"), ("All Files", "*")) ##Fire up the GUI root = Tkinter.Tk() root.title("Inner Zone Terrain Correction") # create status window status_win = StatusWindow.StatusWindow(root, 150, 30) status_win.show() # create logger instance log = logger.Logger("izterrain.log", window=status_win) # set output function write = log.win # get default control options options = defaultOptions() # timestamp the log files write("# Started %s\n" % time.asctime(time.localtime(time.time()))) write("########################################################\n") write("## Inner Zone Terrain Corrections from DEMs ##\n") write("%s\n" % VERSION) write("## Paul Gettings ##\n") write("########################################################\n") write("\n*** READ REDUCED GRAVITY DATA ***\n\n") if not BatchMode: write("#-----------------------\n") write( "# Select the reduced gravity data file. The file should be in the format\n" ) write("# output by 'reduce.py'; comments are OK.\n") write("#-----------------------\n") root.update() # # Read Raw Data if BatchMode: raw_file = options["raw_file"] else: raw_file = tkFileDialog.askopenfilename(parent=root, title="Gravity Data File", initialdir=".", filetypes=data_filetypes) if not raw_file: write("!!! must enter a processed data filename!\n") if not BatchMode: tkMessageBox.showerror("No File Name", "Must enter a data filename!") sys.exit() write(">>> Reading station data file\n") try: data = explfileop.readData(raw_file) except Exception, e: write("!!! error processing data file %s\nException: %s\n" % (raw_file, e)) if not BatchMode: tkMessageBox.showerror("Data File Error", "Error processing data file %s!" % raw_file) sys.exit()
def init_status_win(): global status win = Toplevel() win.title("Program Status") status = StatusWindow(win, 80, 24) status.show()
if not "cmd" in args.keys(): sys.stderr.write("Please give executeable to debug.") sys.exit(-2) if "--vim-servername" in args.keys(): vimservername = args["--vim-servername"] else: vimservername = "pygdb" #Create Terminal dbgterm = GdbTerminal.GdbTerminal(args["cmd"]) #Create windows mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm) statusWnd = StatusWindow.StatusWindow(dbgterm, vimservername) dbgterm.initialize() #Load configuration conf = Configuration.Configuration() conf.load(".pygdb.conf") statusWnd.applyConfiguration(conf) gtk.main() #Store config conf = Configuration.Configuration() statusWnd.fillConfiguration(conf) conf.delCurrpos() conf.store(".pygdb.conf")