Thank god I knew I was doing something realy strange... ;)
The first window get buildup at self.gladefile =
"/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade"  
                self.wTree = gtk.glade.XML(self.gladefile)
the second window gets buildup at the call to gtk.main()...
Below is my program, if you have any comments on the structure, please
let me know, I know it's wrong I just don't know WHAT is wrong... I'm a
newbie...

the program:
#!/usr/bin/env python

import os,sys
import string,re
import pdb
try:
    import pygtk
    pygtk.require("2.0")
except:
    pass

try:
    import gtk
    import gtk.glade
except:
    sys.exit(1)
    
GLADEFILE =
"/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade"  
                        
class NewCD:
        """Dit is de gui class als er een nieuwe cd wordt geladen"""
        def __init__(self):
                pdb.set_trace()
                #Set the Glade file
                self.Artiest=''
                self.CDNaam=''
                self.Genre=''
                self.gladefile =
"/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade"  
                self.wTree = gtk.glade.XML(self.gladefile) 

                #Get the Main Window, and connect the events
                self.window = self.wTree.get_widget("window1")
                if (self.window):
                        self.window.connect("destroy", gtk.main_quit)
                        dic = { "on_AtriestEntry_changed" : 
self.ArtiestEntryChanged,
                        "on_CDNaamEntry_changed" : self.CDNaamEntryChanged,
                        "on_GenreEntry_changed" : self.GenreEntryChanged,
                        "on_RipButton_clicked" : self.RipButtonClicked}
                        self.wTree.signal_autoconnect(dic)


        #Create handler functies
        def ArtiestEntryChanged(self, widget):
                self.Artiest=widget.get_text()
                print "artiest=",self.Artiest

        def CDNaamEntryChanged(self, widget):
                self.CDNaam=widget.get_text()
                print "CDNaam=", self.CDNaam

        def GenreEntryChanged(self, widget):
                self.Genre=widget.get_text()
                print "genre=",self.Genre

        def RipButtonClicked(self, widget):
                if self.Artiest=='':
                        print "Artist NOT set!"
                elif self.CDNaam=='':
                        print "CDNaam NOT set!"
                elif self.Genre.isdigit()==False:
                        print "Genre NOT set!"
                else:
                        print "alles ok dus rippen!"
                        self.RIPCD(self.Artiest,self.CDNaam,self.Genre)
        
        def RIPCD(self,Artiest,CDNaam,Genre):
                self.DIR='/tmp/'+self.Artiest+' - '+self.CDNaam
                self.DESTDIR='/media/data/music/'
                os.mkdir(self.DIR)
                os.chdir(self.DIR)
                os.system('cdparanoia -Bw')
                files=os.listdir('./')
                progress=Progress()
                for file in files:
                        if file.rfind('.wav')!=-1:
                                nummer=re.findall('\d',file)
                        if len(nummer)==3:
                                nr=nummer[0]+nummer[1]+nummer[2]
                        elif len(nummer)==2:
                                nr=nummer[0]+nummer[1]
                        else:
                                nr=nummer[0]
                        os.system('lame --preset cd '+file+' '+nr+'.mp3')
                        os.remove(file)
                        os.system('eyeD3 -a '+self.Artiest+' -A '+self.CDNaam+' 
-G
'+self.Genre+' '+nr+'.mp3')
                        
                os.chdir('/tmp')
                os.system('mv '+self.DIR+' '+self.DESTDIR)
                
class Progress:
        def __init__(self):
                self.wTree=gtk.glade.XML(GLADEFILE) 
                self.progresswindow = self.wTree.get_widget("window2")
                if (self.progresswindow):
                        self.progresswindow.connect("destroy", gtk.main_quit)
                        dic = { "on_button1_clicked" : self.ButtonClicked}
                        self.wTree.signal_autoconnect(dic)
                        self.progress=self.wTree.get_widget("progressbar1")
                        self.button=self.wTree.get_widget("button1")
                        
        def ButtonClicked(self):
                print "Button Clicked!"
                        
if __name__ == "__main__":
    hwg = NewCD()
    gtk.main()


Thanks for looking!!!

Greetings,
Geert


On Fri, 2008-04-18 at 10:24 +0200, Vláďa wrote:
> This sounds very strange. Please check your code or post here a simple 
> example.
> 
> I'm working on an application which is similar to your's (but works with 
> DVDs and video) and everything works fine.
> 
> Vlada
> 
> Geert Geurts napsal(a):
> > Hello, 
> > I'm a newbie trying to get to know pygtk/gtk so my questions might seem
> > stupid...
> > Sorry for that.
> >
> > I'm trying to write a CDrip application using glade/pygtk. I'm now able
> > to write a program making a gui where you can write the artist album
> > info, and the cd is being ripped when you click the button. But I want
> > it to also show a progress window but this second window is shown as
> > soon you start the application altough the second window is in a
> > seperate  class and is not initialized before a button click.
> > How come this window is shown before initialisation and how can I
> > control this behaviour?
> >
> > Greetings,
> > Geert
> >
> > _______________________________________________
> > pygtk mailing list   [email protected]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> >
> >   

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to