def on_button_test_clicked(self, widget, data=None): #get content of textviews buff = self.ui.textview1.get_buffer() name = t.iterTextview(buff) buff2 = self.ui.textview2.get_buffer() #this is a global variable to call it global ;-) --> defined while initialization global proj proj = name = t.iterTextview(buff2) #That is the test - it's just the reprojection and if it doesn't work...the syntax is not right #Could be done better...but I only have 3 weeks...and I will do it later try: #just a test but not a good one...should be replaced later dict1 = t.readProj('./data/media', 'projections.txt') command = 'ogr2ogr -f \'ESRI Shapefile\' ./data/media/cache/syntaxtest ./data/media/ne_110m_admin_0_countries.shp -t_srs \'' + proj + '\' -overwrite -skipfailure' except: home = os.getenv("HOME") folder = home + '/maproj/media' command = 'ogr2ogr -f \'ESRI Shapefile\' ' + folder + '/cache/syntaxtest /usr/share/maproj/media/ne_110m_admin_0_countries.shp -t_srs \'' + proj + '\' -overwrite -skipfailure' tester = os.system(command) #--> Failure = 256 #just do when the test gave 0 --> means everything was done well if tester == 256: self.ui.label_status.set_text('Sorry...thats not right!') elif tester == 0: self.ui.label_status.set_text('Yes...thats the right Syntax!') global setted setted = True #the OK-button shows no text after initialiation #best would be if it doesn't react also but I don't know how to do that...not now!!! self.ui.btn_ok.set_label('Add') else: self.ui.label_status.set_text('Unknown error!')
def finish_initializing(self, builder): """Called when we're finished initializing. finish_initalizing should be called after parsing the ui definition and creating a ChooseprojectionDialog object with it in order to finish initializing the start of the new ChooseprojectionDialog instance. """ # Get a reference to the builder and set up the signals. self.builder = builder self.ui = builder.get_ui(self) global tester tester = False global dict1 global home home = os.getenv("HOME") try: dict1 = t.readProj('./data/media', 'projections.txt') except: if os.system('find ~/maproj/media/projections.txt') != 0: os.system( 'cp /usr/share/maproj/media/projections.txt ~/maproj/media/projections.txt' ) dict1 = t.readProj(home + '/maproj/media', 'projections.txt') if os.system('find ~/maproj') == 0: os.system('mkdir ~/maproj') os.system('mkdir ~/maproj/media') os.system('mkdir ~/maproj/media/cache/') os.system('touch ~/maproj/media/new_world_style.xml') tester = True keylist = dict1.keys() keylist.sort() for key in keylist: #print key, value self.ui.comboboxtext1.append_text(key) #initialize the global variables global counter counter = 0 global name name = '' global imagefile imagefile = ''
def finish_initializing(self, builder): """Called when we're finished initializing. finish_initalizing should be called after parsing the ui definition and creating a ChooseprojectionDialog object with it in order to finish initializing the start of the new ChooseprojectionDialog instance. """ # Get a reference to the builder and set up the signals. self.builder = builder self.ui = builder.get_ui(self) global tester tester = False global dict1 global home home = os.getenv("HOME") try: dict1 = t.readProj('./data/media', 'projections.txt') except: if os.system('find ~/maproj/media/projections.txt') != 0: os.system('cp /usr/share/maproj/media/projections.txt ~/maproj/media/projections.txt') dict1 = t.readProj(home + '/maproj/media', 'projections.txt') if os.system('find ~/maproj') == 0: os.system('mkdir ~/maproj') os.system('mkdir ~/maproj/media') os.system('mkdir ~/maproj/media/cache/') os.system('touch ~/maproj/media/new_world_style.xml') tester = True keylist = dict1.keys() keylist.sort() for key in keylist: #print key, value self.ui.comboboxtext1.append_text(key) #initialize the global variables global counter counter = 0 global name name = '' global imagefile imagefile = ''