def __init__ (self): self.panel = {} self.step_completed = 0 self.labels = [] self.ppu = 1.0 self.idle_id = None self.window = gtk.Window () self.window.connect ('destroy', mainquit) self.window.set_title ('Geocomp') self.window.set_border_width (10) self.out_vbox = gtk.VBox () self.window.add (self.out_vbox) self.extra_label = gtk.Label ('----------') self.out_vbox.pack_end (self.extra_label, expand = FALSE) self.main_hbox = gtk.HBox () self.out_vbox.pack_start (self.main_hbox) self.canvas_vbox = gtk.VBox () self.main_hbox.pack_end (self.canvas_vbox) ha = gtk.Adjustment (0, 0, 1000, 40, 100, 100) va = gtk.Adjustment (0, 0, 1000, 40, 100, 100) self.scroll = gtk.ScrolledWindow (ha, va) self.canvas_vbox.pack_start (self.scroll) #self.canvas = gnome.Canvas (aa=TRUE) self.canvas = Canvas (aa=FALSE) self.canvas.set_usize (config.WIDTH, config.HEIGHT) self.canvas.set_scroll_region(0,0, config.WIDTH, config.HEIGHT) self.scroll.add (self.canvas) self.controls_box = gtk.HBox () self.canvas_vbox.pack_end (self.controls_box, expand=FALSE) self.dyn_controls_box = gtk.HBox () self.controls_box.pack_start (self.dyn_controls_box) self.delay = gtk.SpinButton (gtk.Adjustment (config.DELAY, 0, config.MAX_DELAY, 10, config.MAX_DELAY/10, config.MAX_DELAY/10), digits=0, climb_rate=10) self.delay.set_numeric (TRUE) self.dyn_controls_box.pack_start (self.delay)#, expand=TRUE, fill=FALSE) self.step = gtk.CheckButton ('passo a passo') self.step.set_state (TRUE) self.step.connect_after ('clicked', self.step_clicked) self.dyn_controls_box.pack_start (self.step, fill=FALSE) self.zoom_in = gtk.Button ('+') self.zoom_out = gtk.Button ('-') #self.zoom_box = gtk.HBox () #self.canvas_vbox.pack_start (self.zoom_box) self.dyn_controls_box.pack_start (self.zoom_in) self.dyn_controls_box.pack_start (self.zoom_out) self.zoom_in.connect ('clicked', self.zoom, 1.5) self.zoom_out.connect ('clicked', self.zoom, 2.0/3.0) self.hide = gtk.CheckButton ('esconder') self.hide.set_state (TRUE) self.controls_box.pack_start (self.hide, fill=FALSE) geocomp.init_display (gnome, self) self.left_box = gtk.VBox () self.left_box.set_border_width (5) self.main_hbox.pack_start (self.left_box, expand=FALSE) self.file_box = gtk.VBox () self.left_box.pack_start (self.file_box) self.files_combo = gtk.Combo () self.handler_id = self.files_combo.entry.connect ("changed", self.open_file) #self.handler_id = self.files_combo.list.connect ("selection_changed", self.open_file) self.files_combo.set_value_in_list (val = TRUE, ok_if_empty = FALSE) self.files_combo.disable_activate () self.files_combo.entry.set_editable (FALSE) self.file_box.pack_start (self.files_combo, expand = FALSE) self.create_buttons (None, (geocomp, None)) self.window.show_all () style = self.canvas.get_style () style.bg[STATE_NORMAL] = style.black self.update_files (config.DATADIR, 1) self.files_combo.entry.emit ("changed") self.window.add_events (gtk.gdk.KEY_RELEASE)
def __init__(self): "cria a janela e inicializa tudo" self.panel = {} self.labels = [] self.file_cont = 0 self.current_algorithm = None self.tk = Tk() self.tk.title('Geocomp') self.tk.bind('<Control-q>', self.delete_cb) self.bottom_label = Label(self.tk, text='----------') self.bottom_label.pack(side=BOTTOM, fill=X) self.left = Frame(self.tk, borderwidth=10) self.left.pack(side=LEFT, fill=Y) self.file_frame = Frame(self.left) self.file_frame.pack(fill=X) self.selected_file = StringVar() self.file_label = Label(self.file_frame, text='Arquivo:') self.file_label.pack() self.file_sub_frame = Frame(self.file_frame) self.file_sub_frame.pack(fill=BOTH) self.selected_file.trace_variable( "w", lambda x, y, z, self=self: self.open_file()) filename = self.update_files(config.DATADIR) self.create_buttons(None, 1) self.main_frame = Frame(self.tk) self.main_frame.pack(fill=BOTH, expand=1) self.main_frame.bind('<Control-q>', lambda event, self=self: self.tk.quit()) self.canvas = Canvas(self.main_frame, width=config.WIDTH, height=config.HEIGHT, bg='black', takefocus=1) self.canvas.pack(fill=BOTH, expand=1) self.controls = Frame(self.main_frame) self.controls.pack(fill=BOTH, expand=1) self.step_by_step = IntVar() self.step_button = Checkbutton(self.controls, text='passo a passo', variable=self.step_by_step) self.step_button.grid(row=0, column=0, sticky=W + E, padx=20) self.print_canvas = Button(self.controls, text='imprimir', command=self.print_to_file) self.print_canvas.grid(row=0, column=1, sticky=W + E, padx=20) self.show_var = IntVar() self.show_button = Checkbutton(self.controls, text='esconder', variable=self.show_var) self.show_button.grid(row=0, column=2, sticky=W + E, padx=20) self.delay = Scale(self.main_frame, orient=HORIZONTAL, from_=0, to=config.MAX_DELAY, resolution=10) self.delay.set(config.DELAY) self.delay.pack(fill=X, side=BOTTOM) geocomp.init_display(tk, self) self.points = [] self.step = IntVar() self.step.set(1) self.selected_file.set(filename) self.tk.protocol("WM_DELETE_WINDOW", self.delete_cb)
def __init__ (self): "cria a janela e inicializa tudo" self.panel = {} self.labels = [] self.file_cont = 0 self.current_algorithm = None self.tk = Tk () self.tk.title ('Geocomp') self.tk.bind ('<Control-q>', self.delete_cb) self.bottom_label = Label (self.tk, text = '----------') self.bottom_label.pack (side = BOTTOM, fill = X) self.left = Frame (self.tk, borderwidth = 10) self.left.pack (side = LEFT, fill=Y) self.file_frame = Frame (self.left) self.file_frame.pack (fill = X) self.selected_file = StringVar () self.file_label = Label (self.file_frame, text = 'Arquivo:') self.file_label.pack () self.file_sub_frame = Frame (self.file_frame) self.file_sub_frame.pack (fill = BOTH) self.selected_file.trace_variable ("w", lambda x, y, z, self=self: self.open_file ()) filename = self.update_files (config.DATADIR) self.create_buttons (None, 1) self.main_frame = Frame (self.tk) self.main_frame.pack (fill=BOTH, expand = 1) self.main_frame.bind ('<Control-q>', lambda event, self=self: self.tk.quit ()) self.canvas = Canvas (self.main_frame, width = config.WIDTH, height = config.HEIGHT, bg = 'black', takefocus=1) self.canvas.pack (fill = BOTH, expand=1) self.controls = Frame (self.main_frame) self.controls.pack (fill = BOTH, expand = 1) self.step_by_step = IntVar () self.step_button = Checkbutton (self.controls, text = 'passo a passo', variable = self.step_by_step) self.step_button.grid (row=0, column=0, sticky=W+E, padx=20) self.print_canvas = Button (self.controls, text = 'imprimir', command = self.print_to_file) self.print_canvas.grid (row=0, column = 1, sticky=W+E, padx=20) self.show_var = IntVar () self.show_button = Checkbutton (self.controls, text = 'esconder', variable = self.show_var) self.show_button.grid (row=0, column = 2, sticky=W+E, padx=20) self.delay = Scale (self.main_frame, orient = HORIZONTAL, from_ = 0, to = config.MAX_DELAY, resolution = 10) self.delay.set (config.DELAY) self.delay.pack (fill = X, side=BOTTOM) geocomp.init_display (tk, self) self.input = [] self.step = IntVar () self.step.set (1) self.selected_file.set (filename) self.tk.protocol ("WM_DELETE_WINDOW", self.delete_cb)
run_alg(func, lInput) def many_files(strings): func_name = strings.pop(0) print(func_name, ':') func = get_func(func_name) for filename in strings: print(os.path.basename(filename), ':', end=' ') lInput = geocomp.open_file(filename) run_alg(func, lInput) if __name__ == '__main__': if len(sys.argv) < 2: print(sys.argv[0], '<algorithm> <file1> [file2]...') print(sys.argv[0], '-a <file1> <algorithm1> [algorithm2]...') sys.exit(1) geocomp.init_display(dummy, None) if sys.argv[1] == '-a': sys.argv.pop(0) sys.argv.pop(0) many_algs(sys.argv) else: sys.argv.pop(0) many_files(sys.argv)
def __init__(self): self.panel = {} self.step_completed = 0 self.labels = [] self.ppu = 1.0 self.idle_id = None self.window = gtk.Window() self.window.connect('destroy', mainquit) self.window.set_title('Geocomp') self.window.set_border_width(10) self.out_vbox = gtk.VBox() self.window.add(self.out_vbox) self.extra_label = gtk.Label('----------') self.out_vbox.pack_end(self.extra_label, expand=FALSE) self.main_hbox = gtk.HBox() self.out_vbox.pack_start(self.main_hbox) self.canvas_vbox = gtk.VBox() self.main_hbox.pack_end(self.canvas_vbox) ha = gtk.Adjustment(0, 0, 1000, 40, 100, 100) va = gtk.Adjustment(0, 0, 1000, 40, 100, 100) self.scroll = gtk.ScrolledWindow(ha, va) self.canvas_vbox.pack_start(self.scroll) #self.canvas = gnome.Canvas (aa=TRUE) self.canvas = Canvas(aa=FALSE) self.canvas.set_usize(config.WIDTH, config.HEIGHT) self.canvas.set_scroll_region(0, 0, config.WIDTH, config.HEIGHT) self.scroll.add(self.canvas) self.controls_box = gtk.HBox() self.canvas_vbox.pack_end(self.controls_box, expand=FALSE) self.dyn_controls_box = gtk.HBox() self.controls_box.pack_start(self.dyn_controls_box) self.delay = gtk.SpinButton(gtk.Adjustment(config.DELAY, 0, config.MAX_DELAY, 10, config.MAX_DELAY / 10, config.MAX_DELAY / 10), digits=0, climb_rate=10) self.delay.set_numeric(TRUE) self.dyn_controls_box.pack_start( self.delay) #, expand=TRUE, fill=FALSE) self.step = gtk.CheckButton('passo a passo') self.step.set_state(TRUE) self.step.connect_after('clicked', self.step_clicked) self.dyn_controls_box.pack_start(self.step, fill=FALSE) self.zoom_in = gtk.Button('+') self.zoom_out = gtk.Button('-') #self.zoom_box = gtk.HBox () #self.canvas_vbox.pack_start (self.zoom_box) self.dyn_controls_box.pack_start(self.zoom_in) self.dyn_controls_box.pack_start(self.zoom_out) self.zoom_in.connect('clicked', self.zoom, 1.5) self.zoom_out.connect('clicked', self.zoom, 2.0 / 3.0) self.hide = gtk.CheckButton('esconder') self.hide.set_state(TRUE) self.controls_box.pack_start(self.hide, fill=FALSE) geocomp.init_display(gnome, self) self.left_box = gtk.VBox() self.left_box.set_border_width(5) self.main_hbox.pack_start(self.left_box, expand=FALSE) self.file_box = gtk.VBox() self.left_box.pack_start(self.file_box) self.files_combo = gtk.Combo() self.handler_id = self.files_combo.entry.connect( "changed", self.open_file) #self.handler_id = self.files_combo.list.connect ("selection_changed", self.open_file) self.files_combo.set_value_in_list(val=TRUE, ok_if_empty=FALSE) self.files_combo.disable_activate() self.files_combo.entry.set_editable(FALSE) self.file_box.pack_start(self.files_combo, expand=FALSE) self.create_buttons(None, (geocomp, None)) self.window.show_all() style = self.canvas.get_style() style.bg[STATE_NORMAL] = style.black self.update_files(config.DATADIR, 1) self.files_combo.entry.emit("changed") self.window.add_events(gtk.gdk.KEY_RELEASE)
def many_files (strings): func_name = strings.pop (0) print func_name,':' func = get_func (func_name) for filename in strings: print os.path.basename (filename),':', input = geocomp.open_file (filename) run_alg (func, input) if __name__ == '__main__': if len (sys.argv) < 2: print sys.argv[0], '<algorithm> <file1> [file2]...' print sys.argv[0], '-a <file1> <algorithm1> [algorithm2]...' sys.exit (1) geocomp.init_display (dummy, None) if sys.argv[1] == '-a': sys.argv.pop (0) sys.argv.pop (0) many_algs (sys.argv) else: sys.argv.pop (0) many_files (sys.argv)