rioghal
January 8th, 2007, 01:17 AM
Here's what I am doing. I found a nice little pygtk app here:
http://awesum.sourceforge.net/
I am learning python and pygtk at the moment and am using my new skills to re-write an app that I like. I originally had a bash script that prompted the user for a file and an expected md5 checksum and then compared the file with the checksum the user entered. I had been using it quite a bit until I found awesum at the above URL.
I have re-written a bit of the python script and the .glade file but I need one more thing to be able to make the GUI look better.
As you can see from the first attached screenshot, the original app uses an old GtkOptionMenu (which is depricated) and I'd like to replace it with two radio buttons, as seen in the second attached screenshot, to make the GUI look better. What I need is to learn how to detect which of the two radio buttons is selected so the app knows whether to use MD5 or SHA1 as the digest type.
How does one determine which radio button is selected?
Here is a bit of the code so you can see what the app is doing. The name of the widget I want to replace is 'csum_type' (I added the red color to the text), it's the one in the first screenshot that has 'MD5" in it:
#Determine the correct algorithm
history = gladeXML.get_widget("csum_type").get_history()
if(history == 0):
algorithm = "MD5"
elif(history == 1):
algorithm = "SHA"
else:
#Error
raise "ERROR: csum_type out of range"
#Get the filename
filename = get_filename()
if(filename != ""):
if(do_checksum(filename, checksum, algorithm)):
#Checksum verification successful
msgdlg = gtk.MessageDialog(
None,
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_CLOSE,
"Checksum verification successful!"
)
msgdlg.run()
msgdlg.destroy()
gladeXML.get_widget("expected_csum").set_text("")
else:
#Checksum verification failed
msgdlg = gtk.MessageDialog(
None,
gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
"Checksum values do not match."
)
msgdlg.run()
msgdlg.destroy()
gladeXML.get_widget("expected_csum").set_text("")
return
So, anyone want to teach me how to detect which radio button was selected? I'm betting it's something simple like:
gladeXML.get_widget("csum_type").get_selected()
http://awesum.sourceforge.net/
I am learning python and pygtk at the moment and am using my new skills to re-write an app that I like. I originally had a bash script that prompted the user for a file and an expected md5 checksum and then compared the file with the checksum the user entered. I had been using it quite a bit until I found awesum at the above URL.
I have re-written a bit of the python script and the .glade file but I need one more thing to be able to make the GUI look better.
As you can see from the first attached screenshot, the original app uses an old GtkOptionMenu (which is depricated) and I'd like to replace it with two radio buttons, as seen in the second attached screenshot, to make the GUI look better. What I need is to learn how to detect which of the two radio buttons is selected so the app knows whether to use MD5 or SHA1 as the digest type.
How does one determine which radio button is selected?
Here is a bit of the code so you can see what the app is doing. The name of the widget I want to replace is 'csum_type' (I added the red color to the text), it's the one in the first screenshot that has 'MD5" in it:
#Determine the correct algorithm
history = gladeXML.get_widget("csum_type").get_history()
if(history == 0):
algorithm = "MD5"
elif(history == 1):
algorithm = "SHA"
else:
#Error
raise "ERROR: csum_type out of range"
#Get the filename
filename = get_filename()
if(filename != ""):
if(do_checksum(filename, checksum, algorithm)):
#Checksum verification successful
msgdlg = gtk.MessageDialog(
None,
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_CLOSE,
"Checksum verification successful!"
)
msgdlg.run()
msgdlg.destroy()
gladeXML.get_widget("expected_csum").set_text("")
else:
#Checksum verification failed
msgdlg = gtk.MessageDialog(
None,
gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
"Checksum values do not match."
)
msgdlg.run()
msgdlg.destroy()
gladeXML.get_widget("expected_csum").set_text("")
return
So, anyone want to teach me how to detect which radio button was selected? I'm betting it's something simple like:
gladeXML.get_widget("csum_type").get_selected()