Βοήθεια στην ανάπτυξη μιας graphical εφαρμογής

...χαλαρή κουβεντούλα, γενικός σχολιασμός, φιλοσοφικές συζητήσεις, meeting point / γνωριμία

Συντονιστής: konnn

Βοήθεια στην ανάπτυξη μιας graphical εφαρμογής

Δημοσίευσηαπό jonian » 12 Ιούλ 2010, 23:46

Καλησπέρα σε όλους.

Έχω δημιουργήσει ένα σετ εικονιδίων, Candy Icon Theme, προτεινόμενα για το ubuntu 10.10. To σετ έχει φτιαχτεί με τη χρήση του one canvas work-flow (όλα τα μεγέθη σε ένα .svg αρχείο). Μετά, με τη χρήση ενός script (σε python), τα εικονίδια αυτά εξάγονται από το .svg αρχείο και τοποθετούνται στους κατάλληλους φακέλους και με τη χρήση ενός δεύτερου script (σε bash) δημιουργούνται τα κατάλληλα symlinks.

Εκεί που χρειάζομαι βοήθεια, από όσους έχουν τις γνώσεις και τη διάθεση, είναι στη δημιουργία μιας graphical εφαρμογής που θα ζητάει από το χρήστη να διαλέγει ένα χρώμα της αρεσκείας του και με τη χρήση των scripts, που προανέφερα, να δημιουργεί ένα σετ εικονιδίων με το νέο color scheme.

Περισσότερα για το Candy Icon Theme μπορείτε να μάθετε στο Launchpad
Ubuntu user # 23776
Linux user # 477919
Άβαταρ μέλους
jonian
babeTUX
babeTUX
 
Δημοσιεύσεις: 2
Εγγραφή: 23 Ιαν 2010, 04:03
Εκτύπωση

Re: Βοήθεια στην ανάπτυξη μιας graphical εφαρμογής

Δημοσίευσηαπό headless » 13 Ιούλ 2010, 06:20

Ωραίο το theme σου!
Κάτι τέτοιο ψάχνεις; http://gnome-look.org/content/show.php/ ... ent=124870
Γνώσεις ⇛ Linux: Καλές ┃ Προγραμματισμός: Μέτριος ┃ Αγγλικά: Καλά
Λειτουργικό: debian wheezy/sid 64-bit (en_US.utf8)
Προδιαγραφές ⇛ CPU: 2x Intel Core2 Duo CPU E8400 3.00GHz │ RAM 3965 MiB │ ASUS INC. P5QL/EPU
Κάρτα γραφικών: nVidia GF104 [GeForce GTX 460] [10de:0e22]
Δίκτυα: eth0: Realtek RTL8111/8168B PCI Express Gigabit Ethernet controller [10ec:8168]
My Blog
Άβαταρ μέλους
headless
powerTUX
powerTUX
 
Δημοσιεύσεις: 2173
Εγγραφή: 14 Μάιος 2008, 17:30
Τοποθεσία: Αθήνα
Launchpad: headl3ss
IRC: h3adl3ss
Εκτύπωση

Re: Βοήθεια στην ανάπτυξη μιας graphical εφαρμογής

Δημοσίευσηαπό jennie » 13 Ιούλ 2010, 12:58

Hi!
Πολύ υποσχόμενο το καινούριο θέμα!
Αν αλλάξεις λίγο τα σκριπτ ώστε να παράγονται αρχεία .svg αντί για .png, υπάρχουν κάποιες έτοιμες γραφικές εφαρμογές που θα μπορούσαν να χρησιμοποιούν οι χρήστες για να αλλάζουν τα χρώματα. Μία είναι αυτή που ανέφερε ο h3adl3ss, μια άλλη είναι το magicons, που είναι η προσωπική μου προτίμηση. Για να το χρησιμοποιήσεις με ένα θέμα εικονιδίων, πρέπει να συμπεριλάβεις στο φάκελο του θέματος ένα αρχείο απλού κειμένου με τα χρώματα που θα επιτρέπεται να αλλάζει ο χρήστης, και με τους προτεινόμενους εναλλακτικούς συνδυασμούς χρωμάτων (προαιρετικά). Αν έχεις κάπου σημειωμένα τα χρώματα που χρησιμοποίησες, μπορώ να στο φτιάξω και εγώ.
Νομίζω ότι αυτή η εκδοχή του render_bitmap.py τα καταφέρνει να δημιουργήσει μόνο svg αρχεία σε διάφορα μεγέθη:
Κώδικας: Επιλογή όλων
#!/usr/bin/env python
#
# Copyright (c) 2008 Patryk Zawadzki <pzawadzki@gnome.org>
# Based on an idea and Ruby script by Jakub Steiner
#
# Licensed under LGPL v3+ (http://www.gnu.org/copyleft/lesser.html)
#
#Renders the one-canvas source SVG into individual bitmaps. Run without parameters to get all the svgs in ./source_svg rendered. Pass a specific name to get just that one SVG rendered.#!/usr/bin/env python

from xml.dom.minidom import parse
from xml.dom.minidom import Node
import os
import sys

INKSCAPE = 'inkscape'
SRC = os.path.join(os.getcwd(), 'source_svg')
OUTPUT = os.path.join(os.getcwd(), 'Candy')
RENDERED = os.path.join(os.getcwd(), 'source_svg', 'rendered')

def renderIt(template):
print 'Rendering %s...' % template
doc = parse(template)
groups = doc.getElementsByTagName('g')
layers = [g for g in groups if g.getAttribute("inkscape:groupmode") == 'layer']
icons = []
platemap = {}
# split layers and plates
for l in layers:
lname = l.getAttribute('inkscape:label')
print '\tProcessing Layer: %s' % lname
if '/' in lname:
if lname[:6] == 'plate:':
# one plate per icon
platemap[lname[6:]] = l
print '\t\tSetting plate "%s"' % lname[6:]
else:
icons.append(lname)
print '\t\tSetting icon "%s"' % lname
elif lname == 'plate':
# one plate to rule them all
if platemap.has_key('-'):
print '\t\tDANGER! DANGER! Will Robinson! Multiple master plates!'
platemap['-'] = l
print '\t\tSetting master plate'
for name in icons:
# for each icon
if platemap.has_key(name):
# find a suitable plate
plate = platemap[name]
else:
# or fall back to the generic plate
plate = platemap['-']
basedir = os.path.split(name)[0]
sizes = plate.getElementsByTagName('rect')
for s in sizes:
rectid = s.getAttribute('id')
width = s.getAttribute('width')
height = s.getAttribute('height')
# if s.getAttribute('inkscape:label') == 'scalable':
# dirname = u'scalable/%s' % basedir
# else:
dirname = u'%sx%s/%s' % (width, height, basedir)
dirname = OUTPUT + os.sep + dirname
if not os.path.exists(dirname):
os.makedirs(dirname)
# if s.getAttribute('inkscape:label') == 'scalable':
# fname = u'scalable/%s.svg' % name
# else:
fname = u'%sx%s/%s.svg' % (width, height, name)
fname = OUTPUT + os.sep + fname

# if s.getAttribute('inkscape:label') == 'scalable':
print '\tWriting size scalable'
# make a copy to work with
cmd = u'cp -f "%s" "%s"' % (template, fname)
os.system(cmd)

# Reposition the canvas for the scalable area
print '\t\tResizing canvas (' + rectid + ')'
cmd = u'%s --select=%s --verb=FitCanvasToSelection --verb=EditDelete --verb=FileSave --verb=FileClose "%s"' % (INKSCAPE, rectid, fname)
os.system(cmd)

# Remove all groups and unlink clones
# print '\t\tRemoving groups and clones'
# cmd = u'%s --verb="EditSelectAll" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="SelectionUnGroup" --verb="EditUnlinkClone" --verb=FileSave --verb=FileClose %s' % (INKSCAPE, fname)
# os.system(cmd)

# Get the list of objects -- and their bounding box
print '\t\tCalculating Bounding Boxes'
cmd = u'%s --query-all "%s"' % (INKSCAPE, fname)
stdout = os.popen(cmd)
deletables = []
for id in stdout:
delete = False

boundingbox = id.split(',')
boundingbox[4] = boundingbox[4][:-1] # newline removal

id_x = float(boundingbox[1])
id_y = float(boundingbox[2])

id_width = float(boundingbox[3])
id_height = float(boundingbox[4])

if id_x < 0.0 and id_x + id_width < 0.0:
delete = True
if id_x > float(width):
delete = True
if id_y < 0.0 and id_y + id_height < 0.0:
delete = True
if id_y > float(height):
delete = True

if delete:
deletables.append(boundingbox[0])
# print "Marking for delete: " + boundingbox[0] + " x: " + str(id_x) + " y: " + str(id_y) + " " + str(id_width) + "x" + str(id_height)

print '\t\tDeleting nodes outside canvas ' + width + 'x' + height
newdoc = parse(fname)
stack = [newdoc.documentElement]
while stack:
node = stack.pop()
stack.extend(node.childNodes)
if node.nodeType is Node.ELEMENT_NODE and node.getAttribute('id') in deletables and not node.tagName == 'g':
node.parentNode.removeChild(node)

fileout = open(fname, "w")
newdoc.writexml(fileout)
fileout.close()

# Removing extra defs
print '\t\tVacuuming defs'
cmd = u'%s --vacuum-defs "%s"' % (INKSCAPE, fname)
os.system(cmd)

# else:
# print '\tWriting size %sx%s (%s)' % (width, height, s.getAttribute('inkscape:label'))
# cmd = u'mkdir -p %s' % (os.sep.join(fname.split(os.sep)[0:-1]))
# # print '\t\tMaking directory: %s' % (cmd)
# os.popen(cmd)
# cmd = u'%s -i "%s" -e "%s" "%s"' % (INKSCAPE, rectid, fname, template)
# # print '\t\tBuilding image: %s' % (cmd)
# os.popen(cmd)
##build out a render of the whole thing
#renderedfile = RENDERED + os.sep + '.'.join(template.split(os.sep)[-1].split('.')[0:-1]) + '.png'
#print '\tRendering full file (%s)' % (renderedfile)
#cmd = u'%s -e "%s" "%s"' % (INKSCAPE, renderedfile, template)
#os.popen(cmd)

if __name__ == '__main__':
cmd = u'mkdir -p %s' % (OUTPUT)
os.popen(cmd)

cmd = u'mkdir -p %s' % (RENDERED)
os.popen(cmd)

args = sys.argv[1:]
if args:
for a in args:
renderIt(a)
else:
for root, dirs, files in os.walk(SRC):
for f in files:
if os.path.splitext(f)[1] == '.svg':
renderIt(os.path.join(root, f))
1 Γνώσεις Linux: Μέτριες ┃ Προγραμματισμού: Ελάχιστες ┃ Αγγλικών: Εξαιρετικές
2 Ubuntu 12.04 LTS σε όλους τους υπολογιστές της οικογένειάς μου
Άβαταρ μέλους
jennie
dudeTUX
dudeTUX
 
Δημοσιεύσεις: 495
Εγγραφή: 24 Δεκ 2008, 13:57
Εκτύπωση


Επιστροφή στο Περί ανέμων