2008/11/13 Frédéric <[EMAIL PROTECTED]>

> On jeudi 13 novembre 2008, Neil Munro wrote:
>
> > I've gotten rid of the quit methods etc since I don't need them but
> > every time I hit my ok button (which should just close the about window)
> > does nothing except the code that acknowledges something happens.
>
> Could you provide the complete code and glade file?

I have attached the files :)

>
>
> --
>     Frédéric
>
>    http://www.gbiloba.org
> _______________________________________________
> pygtk mailing list   [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
#!/usr/bin/env python

import sys, os, os.path, gtk.glade, pygtk, gtk, recordstoreabout
pygtk.require( "2.0" )

class GUI:
	Play = "true"

	def __init__( self ):
		## Set the Glade file. ##
		self.wTree = gtk.glade.XML( "musicdb-gui.glade", "window1" )

		## Event handlers. ##
		dic= { "on_window1_destroy" : self.Main_Quit, 
			"on_mnu_quit_activate" : self.Main_Quit, 
			"on_BTN_Add_Album_clicked" : self.Add_Album,
			"on_mnu_Add_Album_activate" : self.Add_Album, 
			"on_BTN_Edit_Album_clicked" : self.Edit_Album, 
			"on_mnu_Edit_Album_activate" : self.Edit_Album,
			"on_BTN_Delete_Album_clicked" : self.Delete_Album, 
			"on_mnu_Delete_Album_activate" : self.Delete_Album,
			"on_BTN_Play_clicked" : self.Play, 
			"on_BTN_Stop_clicked" : self.Stop, 
			"on_mnu_Help_activate" : recordstoreabout.About }
		self.wTree.signal_autoconnect ( dic )
		
	## Functions for event handlers. ##
	def Main_Quit( self, obj ):
		gtk.main_quit( )
		sys.exit( 1 )
	
	def About_Quit( self, obj ):
		import GTK_About

	def Add_Album( self, obj ):
		print "Add album."

	def Edit_Album( self, obj ):
		print "Edit album."

	def Delete_Album( self, obj ):
		print "Delete album."
		

	def Play( self, obj ):
		try:
			if self.Play == "true":
				print "Play track."
				self.Play = "flase"
				self.BTN_Play.set_text(_ ( "Pause" ) )

			elif self.Play == "false":
				print "Pause track."
				self.Play = "true"
				self.BTN_Play.set_text(_ ( "Play" ) )
				
		except Exception, ex:
			print "An error occured: %s." % ex

	def Stop( self, obj ):
		print "Stop track."


class Application:	
	## Need a data structure that can hold a string and another data structure. ##
	## Try out dictionarys. ##
	def __init__( self ):	
		try:
			print "Welcome to RecordStore!"
			if __name__ == '__main__':
				try:
					GUI( )
					gtk.gdk.threads_init( )
				except:
					print "No threading was enabled when pyGTK was compiled!"
					sys.exit( 1 )

			gtk.gdk.threads_enter( )
			gtk.main( )
			gtk.gdk.threads_leave( )

		except Exception, ex:
			print "An error has occured: %s." % ex

	## Sort the writing of stuff alpha-numerically. ##
	## Convert this all to SQL database. ##
	def CreateXMLFile( self ):
		try:
			RootMusic = "/home/niadh/Music/"
			XMLFile = file( "media-library.xml", "w" )
			Artists = os.listdir( RootMusic )
			ArtistsIterate = 0 
			XMLFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n" )
			XMLFile.write( "<music>\n" )

			## Artist listing. ##
			while ArtistsIterate < len( Artists ):
				AlbumIterate = 0
				location = os.path.join( RootMusic + Artists[ ArtistsIterate ] )
				Albums = os.listdir( location )
				XMLFile.write( "\t<artist>\n" + "\t\t<name>" + Artists[ ArtistsIterate ] + "</name>\n" )

				## Album listing. ##
				while AlbumIterate < len( Albums ):
					TrackIterate = 0
					location = os.path.join( RootMusic + Artists[ ArtistsIterate ] + "/" + Albums[ AlbumIterate ] )
					Tracks = os.listdir( location )
					XMLFile.write( "\t\t<album>\n" )
					XMLFile.write( "\t\t\t<albumname>" + Albums[ AlbumIterate ] + "</albumname>\n" )
					XMLFile.write( "\t\t\t<releasedate>" + "</releasedate>\n" )
					XMLFile.write( "\t\t\t<format>" + "</format>\n" )			
					AlbumIterate = AlbumIterate +1	

					## Track listing. ##	
					while TrackIterate < len( Tracks ):
						XMLFile.write( "\t\t\t<track>" + Tracks[ TrackIterate ] + "</track>\n" )
						TrackIterate = TrackIterate +1	

					XMLFile.write( "\t\t</album>\n" )	
			
				XMLFile.write ( "\t</artist>\n\n" )
				ArtistsIterate = ArtistsIterate +1
			XMLFile.write( "</music>\n" )

		except Exception, ex: 
			print "An error occured: %s." % ex
			
App = Application( )

Attachment: recordstoreabout.pyc
Description: Binary data

Attachment: musicdb-gui.glade
Description: application/glade

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

Reply via email to