100 lines
3.4 KiB
Python
100 lines
3.4 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import pygtk
|
|
pygtk.require('2.0')
|
|
import gtk
|
|
|
|
class AssistantTest:
|
|
def delete_event(self, widget, event, data = None):
|
|
return False
|
|
|
|
def destroy(self, widget, data = None):
|
|
gtk.main_quit()
|
|
|
|
def __init__(self):
|
|
self.data = {
|
|
"filename" : None,
|
|
"outputdir" : None}
|
|
self.ass = gtk.Assistant()
|
|
|
|
self.ass.connect("delete_event", self.delete_event)
|
|
self.ass.connect("close", self.destroy)
|
|
self.ass.connect("cancel", self.destroy)
|
|
|
|
# Construct page 0
|
|
label = gtk.Label("""Buttons for website allows you to produce a series of buttons for use on a website. On the next pages you may choose several options to change the content and the look of the buttons.""")
|
|
label.set_line_wrap(True)
|
|
label.show()
|
|
self.ass.append_page(label)
|
|
self.ass.set_page_title(label, "Introduction to buttons for website")
|
|
self.ass.set_page_type(label, gtk.ASSISTANT_PAGE_INTRO)
|
|
self.ass.set_page_complete(label, True)
|
|
|
|
# Construct page 1
|
|
self.page1 = gtk.VBox(False, 5)
|
|
self.page1.set_border_width(5)
|
|
self.page1.show()
|
|
self.ass.append_page(self.page1)
|
|
self.ass.set_page_title(self.page1,
|
|
"Select the input file and output directory")
|
|
self.ass.set_page_type(self.page1, gtk.ASSISTANT_PAGE_CONTENT)
|
|
|
|
label = gtk.Label("Please choose the file containing your button labels and the directory where the generated files should be put.")
|
|
label.set_line_wrap(True)
|
|
label.show()
|
|
self.page1.pack_start(label, True, True, 0)
|
|
|
|
table = gtk.Table(rows=2, columns=2, homogeneous=False)
|
|
table.show()
|
|
label = gtk.Label("Button label file")
|
|
label.show()
|
|
table.attach(label, 0, 1, 0, 1)
|
|
button = gtk.FileChooserButton("Choose file")
|
|
button.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
|
|
button.connect("selection-changed", self.cb_file_selected, button)
|
|
button.show()
|
|
table.attach(button, 1, 2, 0, 1)
|
|
|
|
label = gtk.Label("Output directory")
|
|
label.show()
|
|
table.attach(label, 0, 1, 1, 2)
|
|
button = gtk.FileChooserButton("Choose directory")
|
|
button.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
button.connect("selection-changed", self.cb_dir_selected, button)
|
|
button.show()
|
|
table.attach(button, 1, 2, 1, 2)
|
|
|
|
self.page1.pack_end(table)
|
|
|
|
# Construct page 2
|
|
label = gtk.Label('Thanks for using btn4ws')
|
|
label.set_line_wrap(True)
|
|
label.show()
|
|
self.ass.append_page(label)
|
|
self.ass.set_page_title(label, 'Page 1: The end')
|
|
self.ass.set_page_type(label, gtk.ASSISTANT_PAGE_SUMMARY)
|
|
|
|
self.ass.show()
|
|
|
|
def checkpage1completion(self):
|
|
print str(self.data)
|
|
if self.data["filename"] and self.data["outputdir"]:
|
|
self.ass.set_page_complete(self.page1, True)
|
|
else:
|
|
self.ass.set_page_complete(self.page1, False)
|
|
|
|
def cb_file_selected(self, w, filesel):
|
|
self.data["filename"] = filesel.get_filename()
|
|
self.checkpage1completion()
|
|
|
|
def cb_dir_selected(self, w, dirsel):
|
|
self.data["outputdir"] = dirsel.get_filename()
|
|
self.checkpage1completion()
|
|
|
|
def main(self):
|
|
gtk.main()
|
|
|
|
if __name__ == "__main__":
|
|
assi = AssistantTest()
|
|
assi.main()
|