import pygtk pygtk.require('2.0') import gtk import gtk.glade import pickle from grid import * class New_Grid_Window: def __init__(self,winmain,core): # -------------------- Usable Variables self.name="" self.rows=1 self.cols=1 # ----------------------------------------------- self.winmain=winmain self.core=core self.min=2 self.max=6 self.glade = gtk.glade.XML("../rsrc/glade_new_grid.glade") self.window=self.glade.get_widget("new_grid_window") self.window.connect("destroy", self.destroy) self.window.show() self.window.set_modal(True) self.rows_spinbutton=self.glade.get_widget("rows_spinbutton") self.cols_spinbutton=self.glade.get_widget("cols_spinbutton") self.adjustment_rows=gtk.Adjustment(1,self.min,self.max,1,1,0) self.adjustment_cols=gtk.Adjustment(1,self.min,self.max,1,1,0) self.rows_spinbutton.set_adjustment(self.adjustment_rows) self.rows_spinbutton.set_value(2) self.cols_spinbutton.set_adjustment(self.adjustment_cols) self.cols_spinbutton.set_value(2) self.name_entry=self.glade.get_widget("name_entry") self.name_entry.set_text(self.name) self.accept_button=self.glade.get_widget("accept_button") self.cancel_button=self.glade.get_widget("cancel_button") self.accept_button.connect("clicked", self.set_variables) self.cancel_button.connect("clicked", self.hide_window) #gtk.main() #def __init__ def destroy(self, widget, data=None): #gtk.main_quit() print "Closing New Grid Window..." def set_variables(self,data=None): self.name=self.name_entry.get_text() self.rows=self.rows_spinbutton.get_value_as_int() self.cols=self.cols_spinbutton.get_value_as_int() self.window.hide() grid=Grid(self.winmain.core,self.name,self.rows,self.cols,self.core.id_counter) self.core.id_counter+=1 print "creating grid" self.winmain.label_manager.add_grid(grid) self.winmain.label_manager.update_manager(grid.id) def get_variables(self,data=None): #print "" #print ("## Name: %s"%self.name) #print ("## Num of rows: %s"%self.rows) #print ("## Num of cols: %s"%self.cols) variables=(self.name,self.rows,self.cols) return variables def hide_window(self,data=None): self.window.hide() #def hide_window # class New_Grid_Window if __name__ == "__main__": '''print "" print "# Pickle example " write=False load=True #app=New_Grid_Window() if write: print "## Writing pickle file..." output = open('/home/hector/data.pkl', 'wb') pickle.dump(app, output, -1) output.close() if load: print "## Loading pickle file..." pkl_file = open('/home/hector/data.pkl', 'rb') data1 = pickle.load(pkl_file) pkl_file.close() data1.get_variables() data1.window.show() gtk.main()''' app=New_Grid_Window() gtk.main()