Skip to main content

Thread: PyGTK and interface update


i've got problem interface update when work os.system() command. i've got progressbar on form want pulse until os.system() finished. i've tried add
code:
while gtk.events_pending():     gtk.main_iteration(false)
but still no go.
here code:
code:
        self.pages = self.builder.get_object("pagesspinbutton")         pagescount = self.pages.get_value_as_int()           self.progressbar = self.builder.get_object("progressbar")                  tmpfile = filepath + "/book.ps"              workingfile = string.replace(filename,".pdf","") + ".ps"         outputfile = string.replace(filename,".pdf","") + "_booklet.pdf"                          command_list = ('pdf2ps \"%s\" \"%s\"' %(filename, workingfile),                         'psbook -s%d \"%s\" \"%s\"'  %(pagescount, workingfile, tmpfile),                         'psnup -2 -p a5 -p a4 \"%s\" > \"%s\"' %(tmpfile, workingfile),                         'ps2pdf \"%s\" \"%s\"' %(workingfile, outputfile),                         'rm -f  \"%s\" \"%s\"' %(tmpfile, workingfile)                                         )         message_list = ('converting postscript...',                         'making broshures...',                         'creating booklet...',                         'converting pdf...',                         'job has been done...'                         )                  if (pagescount % 4 != 0):                        self.builder.get_object("hbox7").show()         else:             self.builder.get_object("makebutton").set_sensitive(0)                          in range(len(command_list)):                 self.progressbar.set_text(message_list[i])                 keep_pulsing = true                 gobject.timeout_add(200, do_pulse)                               print "executing command: %s" %command_list[i]                 os.system(command_list[i])                 while gtk.events_pending():                     gtk.main_iteration(false)                           keep_pulsing = false              self.progressbar.set_fraction(0)          def do_pulse(self,*args):         global keep_pulsing         if keep_pulsing:             self.progressbar.pulse()             return true         return false

you should use module subprocess,
check, google examples , using poll
one:
> http://stackoverflow.com/questions/1...es-with-python

@ example 2:
here's little python script starts process, checks if running, waits while, kills it, waits terminate, checks again. uses 'kill' command. version 2.6 of python subprocess has kill function.
, on.....

cannot run process , keep parent-prog (=python) idle until other program finishes. 1 way use output of started child-program , update progressbar while feedback stdout of running child-program
(you did check progressbar.py example in pygtk?)


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] PyGTK and interface update


Ubuntu

Comments

Popular posts from this blog

Joomla site hacked, cant see front and - Joomla! Forum - community, help and support

Christian Home School Programs - Joomla! Forum - community, help and support

Trouble with PF_OutFlag_I_USE_AUDIO and PF_CHECKOUT_LAYER_AUDIO