def on_btok_clicked(self, widget, data=None):
     self.scale= self.spbtscale.get_value_as_int()    
     self.distance= self.spbtdistance.get_value_as_int()    
     self.cheat= self.spbtcheat.get_value_as_int()  
     self.orig=self.txtpathorig.get_text()
     self.output=self.txtpathmosaic.get_text()
     
     
     if self.txtpathorig.get_text_length() <= 0 or  self.txtpathmosaic.get_text_length() <= 0:
         mosaic.on_dialog(self.wdcreatemosaic, 
         _("Please select the original picture and mosaic output filenames"), gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE)
     else:
          if (self.txtpathorig.get_text()== self.txtpathmosaic.get_text()):
              mosaic.on_dialog(self.wdcreatemosaic, 
              _("Please select different filenames for original picture and mosaic output"),
               gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)
          else:
              self.generate_mosaic()
 def on_btok_clicked(self, widget, data=None):
     generate_pieces = False
     fail=False
     if (self.txtpathphotos.get_text_length() >0 and self.txtpathwork.get_text_length() > 0 and
     self.txtpathwork.get_text()== self.txtpathphotos.get_text()):
         mosaic.on_dialog(self.wdselectpaths,
         _("Please select differents paths"), gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)
         fail=True
     else:
         if self.txtpathphotos.get_text_length() <= 0:
             generate_pieces = False
             if self.txtpathwork.get_text_length() <= 0:
                 mosaic.on_dialog(self.wdselectpaths,
                 _("Please select a work path"), gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)
                 fail=True
             else: 
                 if self.check_path_index(self.txtpathwork.get_text()):
                     generate_pieces = False
                     
                 else:
                     mosaic.on_dialog(self.wdselectpaths,
                     _("Please select a work path that contains pieces of mosaic"), gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)
                     fail=True
         else:
             generate_pieces = True
             if self.txtpathwork.get_text_length() <= 0:
                 mosaic.on_dialog(self.wdselectpaths,
                 _("Please select a work path"), gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE)
                 fail=True
             else: 
                 if self.check_path_index(self.txtpathwork.get_text()):
                     if self.question_generate():
                         generate_pieces = True
                     else:
                         generate_pieces = False
                 else:
                     generate_pieces = True
     
     self.mosaic.txtphotos = self.txtpathphotos.get_text()
     self.mosaic.txtwork = self.txtpathwork.get_text()
     self.mosaic.recursive = self.chbtrecursive.get_active()
     self.mosaic.width = self.spbtwidth.get_value_as_int()
     self.mosaic.height = self.spbtheight.get_value_as_int()
     if not fail:
         if generate_pieces:   
             #self.res = subprocess.Popen(["metapixel", "--width="+self.mosaic.width, "--height="+self.mosaic.width])
             self.execute_pieces()
         
         else:
             self.wdselectpaths.destroy()             
 def generate_mosaic(self):
     self.processexecute=process.Process(None,self,"create")
     self.res = subprocess.Popen(["metapixel", "--metapixel", self.orig, self.output,
      "--l="+self.mosaic.txtwork, "--cheat="+str(self.cheat), "--width="+str(self.mosaic.width),
      "--height="+str(self.mosaic.width),"--distance="+str(self.distance), "--scale="+str(self.scale) ], stdout=subprocess.PIPE)
     thread=ThreadMeta(self.res)     
     thread.start()
     while thread.isAlive():
         time.sleep(0.09)
         self.processexecute.pgbar.pulse()
         while gtk.events_pending():
             gtk.main_iteration()
     
     if (self.res.returncode!=0):
         self.processexecute.wdprocess.destroy()
         mosaic.on_dialog(self.wdcreatemosaic, 
         _("Error: Select a small size or distance"), gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE)
     else:    
         self.processexecute.pgbar.set_fraction(1.0)
         self.processexecute.label1.set_text(_("Mosaic has been created"))
         self.processexecute.wdprocess.set_title(_("Getapixel - Complete"))
                    
         self.processexecute.btok.show()