Hi, I have a problem with a dialog. It's similar to an other posting.
I'm interested either in getting a solution for the code below or an
other solution that accomplish the same.

The problem with the code below is that the dialog doesn't go away. If
it has been shown once and closed it pops up as soon as I try to push
one of the button even the button that does nothing!

If the two filenames are the same I want to stop the execution of the
following code until the user either accepts to overwrite or don't want
to overwrite the file.

Thanks
Mattias Nilsson
[EMAIL PROTECTED]


from gtk import *
from gnome.ui import *
from GDK import *


class App:
  def start(self, *args):
    #emulate input of two files with the same name
    filename1 = 'logo.jpg'
    filename2 = 'logo.jpg'

    overwrite = 0
    if filename1 == filename2:
      overwrite = GnomeMessageBox("Overwrite?", "question",
        STOCK_BUTTON_YES, STOCK_BUTTON_NO).run_and_close()
    if overwrite == 0:
      #this code have to wait to be run if the filenames are the same
      #or run at once if they aren't the same
      print 'doing file conversion'
    else:
      #this code or perhaps no code should be run if the user don't want

      # to overwrite the file.
      print 'doing nothing'

  def main(self):
    main_window = GnomeApp()
    main_window.connect('delete_event', mainquit)
    main_window.show()

    hbox = GtkHBox()
    hbox.show()
    main_window.add(hbox)

    button = GtkButton('Start')
    button.connect('pressed', self.start)
    button.show()
    hbox.add(button)

    button2 = GtkButton('nothing')
    button2.show()
    hbox.add(button2)

    mainloop()

if __name__=='__main__':
  app = App()
  app.main()




_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to