parent
7bfa24d3a0
commit
64f9dd7033
2 changed files with 148 additions and 2 deletions
50
btn4ws.py
50
btn4ws.py
|
@ -31,13 +31,17 @@ port of the older gimp-perl version to python.
|
|||
"""
|
||||
import os, urllib, logging, sys
|
||||
import gimp, gimpplugin
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
from gimpenums import *
|
||||
from gimpshelf import shelf
|
||||
pdb = gimp.pdb
|
||||
|
||||
btn4ws_version = "0.7.0"
|
||||
|
||||
logging.basicConfig(level=logging.INFO,
|
||||
format='$(asctime)s %(levelname)s %(message)s',
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s %(levelname)s %(message)s',
|
||||
stream=sys.stderr)
|
||||
|
||||
class text_to_name_mapper:
|
||||
|
@ -145,6 +149,31 @@ class text_to_name_mapper:
|
|||
return os.path.join(dirname, fname)
|
||||
return fname
|
||||
|
||||
class Btn4wsDialog:
|
||||
"""This class is the input dialog field for btn4ws"""
|
||||
def delete_event(self, widget, event, data = None):
|
||||
return False
|
||||
|
||||
def destroy(self, widget, data = None):
|
||||
gtk.main_quit()
|
||||
|
||||
def __init__(self, filename, outdir, font,
|
||||
strcolor, transparency, bgcolor,
|
||||
glow, glowcolor,
|
||||
usepattern, pattern,
|
||||
buttoncolor, roundradius,
|
||||
padding, glowsize, bevelwidth,
|
||||
nova, novasparkles, novaradius,
|
||||
novacolor, writexcf, makeinactive,
|
||||
makeactive, makepressed, makejscript):
|
||||
self.window = gtk.Assistant()
|
||||
self.window.connect("delete_event", self.delete_event)
|
||||
self.window.connect("destroy", self.destroy)
|
||||
self.window.show()
|
||||
|
||||
def main(self):
|
||||
gtk.main()
|
||||
|
||||
class btn4wsplugin(gimpplugin.plugin):
|
||||
"""This is the btn4ws gimp plugin."""
|
||||
def parsefont(font):
|
||||
|
@ -283,6 +312,23 @@ class btn4wsplugin(gimpplugin.plugin):
|
|||
This function controls the creation of the buttons and is
|
||||
registered as gimp plugin.
|
||||
"""
|
||||
if runmode == RUN_INTERACTIVE:
|
||||
logging.debug("runmode interactive")
|
||||
dialog = Btn4wsDialog(filename, outdir, font, strcolor,
|
||||
transparency, bgcolor, glow, glowcolor,
|
||||
usepattern, pattern, buttoncolor,
|
||||
roundradius, padding, glowsize, bevelwidth,
|
||||
nova, novasparkles, novaradius, novacolor,
|
||||
writexcf, makeinactive, makeactive,
|
||||
makepressed, makejscript)
|
||||
dialog.main()
|
||||
elif runmode == RUN_NONINTERACTIVE:
|
||||
logging.debug("runmode noninteractive")
|
||||
elif runmode == RUN_WITH_LASTVALS:
|
||||
logging.debug("runmode with lastvals")
|
||||
if shelf.has_key("btn4ws"):
|
||||
initialvalues = shelf["btn4ws"]
|
||||
return
|
||||
# import used gimp pdb functions
|
||||
createtext = pdb['gimp_text_fontname']
|
||||
selectionlayeralpha = pdb['gimp_selection_layer_alpha']
|
||||
|
|
100
gtktest.py
Normal file
100
gtktest.py
Normal file
|
@ -0,0 +1,100 @@
|
|||
#!/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()
|
Loading…
Reference in a new issue