Removes code for gtk. Not supported any more

This commit is contained in:
2012-08-31 11:25:44 +02:00
parent b6fac0ba25
commit 40177f0ce8
12 changed files with 218 additions and 1265 deletions

View File

@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAboutDialog" id="about_ivolution_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="icon">../media/vitruve.svg</property>
<property name="type_hint">normal</property>
<property name="program_name">Ivolution</property>
<property name="version">0.1</property>
<property name="copyright" translatable="yes">BSD License</property>
<property name="website">https://github.com/jlengrand/ivolution</property>
<property name="website_label" translatable="yes">Ivolution</property>
<property name="authors">Julien Lengrand-Lambert &lt;julien@lengrand.fr&gt;</property>
<property name="artists">Luc Viatour &lt;www.Lucnix.be&gt;</property>
<property name="logo">../media/vitruve_50.jpg</property>
<property name="license_type">bsd</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="layout_style">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -1,711 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-local-resource-path ../media -->
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0.46000000834465027</property>
<property name="stock">gtk-help</property>
</object>
<object class="GtkWindow" id="ivolution_window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Ivolution</property>
<property name="icon">../media/ivolution.svg</property>
<signal name="delete-event" handler="on_destroy" swapped="no"/>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="mnu_help">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="helpMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="menu_help">
<property name="label" translatable="yes">Help online</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image2</property>
<property name="use_stock">False</property>
<accelerator key="F1" signal="activate"/>
<signal name="activate" handler="on_menu_help_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_about">
<property name="label">gtk-about</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_menu_about_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="title_box">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="vitruve_title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="pixbuf">../media/vitruve_50.jpg</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">-1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="speedlabel1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="ypad">1</property>
<property name="label" translatable="yes">Ivolution</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Bold 14"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="speedlabel2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="label" translatable="yes">Take one picture of yourself a day,
automatically generate a movie! </property>
<attributes>
<attribute name="font-desc" value="Ubuntu 11"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="config_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSeparator" id="separator2">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="mandatory_params_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="ypad">7</property>
<property name="label" translatable="yes">Required parameters :</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Mono Bold 12"/>
<attribute name="weight" value="ultrabold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="inputbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="input_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0.10000000149011612</property>
<property name="label" translatable="yes">Choose your input folder :</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Mono Bold 11"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="filechooserinput">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="action">select-folder</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="outputbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="output_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0.10000000149011612</property>
<property name="label" translatable="yes">Choose your output folder:</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Mono Bold 11"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="filechooseroutput">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="action">select-folder</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="paramsbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="params_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="ypad">7</property>
<property name="label" translatable="yes">Optional parameters :</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Mono Bold 12"/>
<attribute name="weight" value="ultrabold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="type_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="typelabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0.10000000149011612</property>
<property name="label" translatable="yes">Type of face :</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Mono Bold 11"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="typecombobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="entry_text_column">0</property>
<items>
<item translatable="yes">frontal_face</item>
<item translatable="yes">profile_face</item>
</items>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="speed_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="speedlabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0.10000000149011612</property>
<property name="label" translatable="yes">Video speed :</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Mono Bold 11"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="speedcombobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
<item translatable="yes">slow</item>
<item translatable="yes">medium</item>
<item translatable="yes">fast</item>
</items>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="modelabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0.10000000149011612</property>
<property name="label" translatable="yes">Choose your prefered mode :</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Mono Bold 11"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkRadioButton" id="cropradiobutton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">blackboxradiobutton</property>
<signal name="toggled" handler="on_cropradiobutton_toggled" swapped="no"/>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Crop Mode</property>
<attributes>
<attribute name="font-desc" value="Ubuntu 10"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="blackboxradiobutton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">cropradiobutton</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Conservative Mode</property>
<attributes>
<attribute name="font-desc" value="Ubuntu 10"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">1</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="sortbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="sortlabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0.10000000149011612</property>
<property name="label" translatable="yes">File sorting method :</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Mono Bold 11"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkRadioButton" id="namesortradiobutton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="yalign">0.51999998092651367</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">EXIFsortradiobutton</property>
<signal name="toggled" handler="on_namesortradiobutton_toggled" swapped="no"/>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">File Name</property>
<attributes>
<attribute name="font-desc" value="Ubuntu 10"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="EXIFsortradiobutton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">namesortradiobutton</property>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">EXIF Metadata</property>
<attributes>
<attribute name="font-desc" value="Ubuntu 10"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkBox" id="startbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="startbutton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="pressed" handler="on_startbutton_pressed" swapped="no"/>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Create Movie !</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Bold 10"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="stopbutton">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="pressed" handler="on_stopbutton_pressed" swapped="no"/>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Stop Processing</property>
<attributes>
<attribute name="font-desc" value="Ubuntu Bold 10"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">7</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="text" translatable="yes"> </property>
<property name="show_text">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkStatusbar" id="statusbar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel" id="statuslabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">5</property>
<property name="ypad">5</property>
<property name="label" translatable="yes">Status Area</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">5</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -1,20 +0,0 @@
from gi.repository import Gtk
from .. import get_data
class AboutDialog():
def __init__(self):
"""
Special static method that's automatically called by Python when
constructing a new instance of this class.
Returns a fully instantiated AboutDialog object.
"""
self.builder = Gtk.Builder()
self.builder.add_from_file(get_data("/ui/AboutIvolutionDialog.glade"))
self.window = self.builder.get_object("about_ivolution_dialog")
self.window.run()
self.window.destroy()

329
ivolution/gui/IvolutionWindow.py Executable file → Normal file
View File

@@ -1,108 +1,97 @@
#!/usr/bin/env python
"""
.. module:: IvolutionWindow
:platform: Unix, Windows, Mac
:synopsis: Main Window of the Ivolution GUI designed to be supported by all platforms.
.. moduleauthor:: Julien Lengrand-Lambert <jlengrand@gmail.com>
"""
import wx
import wx.lib.newevent
import sys
import os
import webbrowser
import logging
import webbrowser
from gi.repository import Gtk, GLib
from AboutDialog import AboutDialog
from .. import get_data
# import os
# parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# os.sys.path.insert(0,parentdir) # import parent folder
from .. import get_data # used to load images and files
from .. import FaceParams
from .. import FacemovieThread
from ..util.Notifier import Observer
from ..util.Notifier import Observable
from IvolutionTemplate import IvolutionTemplate
from SettingsWindow import SettingsWindow
class IvolutionWindow(Observer, Observable):
def __init__(self, name):
Observer.__init__(self, name)
class IvolutionWindow(IvolutionTemplate, Observer, Observable):
"""
Main Window of the Ivolution application
"""
def __init__(self, parent, title):
"""
Overrides init frame IvolutionTemplate
"""
IvolutionTemplate.__init__(self, parent)
Observer.__init__(self, "Interface")
Observable.__init__(self)
# Sets up logging capability
self.my_logger = None
self.console_logger = None
self.setup_logger()
self.builder = Gtk.Builder()
self.builder.add_from_file(get_data('ui/IvolutionWindow.glade'))
#self.builder.add_from_file("ivolution/data/ui/IvolutionWindow.glade")
#self.builder.connect_signals({ "on_ivolutionwindow_destroy" : Gtk.main_quit })
self.window = self.builder.get_object("ivolution_window")
self.window.show()
self.builder.connect_signals(self)
# Defines all our parameters neededfor the facemovie
self.get_default_parameters()
self.process_running = False
self.facemovie = None
self.inputtextbox.SetLabel(self.in_fo) # sets label to default input folder
self.SetIcon(wx.Icon('ivolution/data/media/vitruve.ico', wx.BITMAP_TYPE_ICO)) # Sets icon
self.Show(True) # Finally show the frame
def get_default_parameters(self):
"""
"""
# FIXME: Put really general stuff here !
self.videospeedlistChoices = [u"slow", u"medium", u"fast"]
self.gaugerange = 100
## Defines parameters needed to run the FaceMovie
self.root_fo = ""
self.in_fo = "" # Input folder, where images are located
self.out_fo = "" # Input folder, where the video will be saved
self.mode = "crop" # type of video to be created
self.sort = "name" # how image files will be chronologically sorted
self.speed = 1 # Speed of the movie
self.param = "frontal_face" # type of face profile to be searched for
self.in_fo = "" # Input folder, where images are located
self.process_running = False
self.facemovie = None
self.AboutDialog = None # class
self.setup()
self.setup_logger()
def setup(self):
"""
Sets up all the default paramters and retrieve the element of the GUI we want to follow
"""
self.AboutDialog = AboutDialog # FIXME : Still not working
self.startbutton = self.builder.get_object("startbutton")
self.filechooserinput = self.builder.get_object("filechooserinput")
self.filechooseroutput = self.builder.get_object("filechooseroutput")
self.typecombobox = self.builder.get_object("typecombobox")
self.typecombobox.set_active(0)
self.speedcombobox = self.builder.get_object("speedcombobox")
self.speedcombobox.set_active(0)
self.cropradiobutton = self.builder.get_object("cropradiobutton")
self.namesortradiobutton = self.builder.get_object("namesortradiobutton")
self.progressbar = self.builder.get_object("progressbar")
self.statuslabel = self.builder.get_object("statuslabel")
# Signal handling related stuff
def on_cropradiobutton_toggled(self, widget):
"""
We need to take care only of this one as both are grouped
"""
if widget.get_active(): # means crop is activated
self.mode = "crop"
if "win" in sys.platform:
self.out_fo = "C:/Users/jll/Videos/" # Default folder for Windows
self.in_fo = "C:\Users\jll\Pictures/"
else:
self.mode = "conservative"
self.out_fo = "/home/jll/Videos/" # Default folder for Linux
self.in_fo = "/home/jll/Pictures/"
def on_namesortradiobutton_toggled(self, widget):
"""
We need to take care only of this one as both are grouped
"""
if widget.get_active(): # means name is activated
self.sort = "name"
else:
self.sort = "exif"
# Overriding event handling methods
def on_settings(self, event):
settings = SettingsWindow(self)
settings.Show(True) # Finally show the frame
def on_startbutton_pressed(self, widget):
def on_start(self, event):
"""
User asks for starting the algorithm
Sets all parameters and start processing
"""
self.my_logger.debug("start pressed")
if not self.process_running: # start only if not already running
# Empty list on screen
self.filelist.DeleteAllItems()
self.set_parameters()
self.print_parameters()
# Instantiating the facemovie
@@ -117,59 +106,150 @@ class IvolutionWindow(Observer, Observable):
self.console_logger.error("Cannot start, process already running !")
self.my_logger.error("Cannot start, process already running !")
def on_stopbutton_pressed(self, widget):
def on_stop(self, event):
"""
Asks the Facemovie thread to terminate
User asks for stopping the algorithm
Asks the FacemovieThread to terminate
"""
self.my_logger.debug("Stop pressed")
self.console_logger.debug("Stop pressed")
self.notify(["STOP"]) # Asking the Facemovie to stop
self.notify(["Application", ["STOP"]]) # Asking the Facemovie to stop
self.process_running = False
def on_destroy(self, widget, data=None):
"""Called when the IvolutionWindow is closed."""
# Clean up code for saving application state should be added here.
self.notify(["STOP"]) # Asking the Facemovie to stop
self.process_running = False
#self.on_exit(event) # Finally shuts down the interface
Gtk.main_quit()
print "Gtk Exited"
def on_menu_about_activate(self, widget, data=None):
def on_input(self, event):
"""
Displays the about box for Ivolution
# FIXME : Can start several about Dialogs at the same time
Activated when a user clicks to choose its input location
"""
if self.AboutDialog is not None:
about = self.AboutDialog()
self.inputdialog = wx.DirDialog(self, "Please choose your input directory", style=1, defaultPath=self.in_fo)
def on_menu_help_activate(self, widget, data=None):
if self.inputdialog.ShowModal() == wx.ID_OK:
self.in_fo = self.inputdialog.GetPath()
self.inputtextbox.SetLabel(self.in_fo)
self.inputdialog.Destroy()
def on_output(self, event):
"""
Activated when a user clicks to choose its output location
"""
default_dir = "~/Videos"
self.outputdialog = wx.DirDialog(self, "Please choose your output directory", style=1, defaultPath=default_dir)
if self.outputdialog.ShowModal() == wx.ID_OK:
self.outputchoosertext.SetLabel(self.outputdialog.GetPath())
self.outputdialog.Destroy()
def on_help(self, event):
"""
Opens a browser and points to online help.
"""
url = "http://jlengrand.github.com/FaceMovie/"
webbrowser.open(url, new=2) # in new tab if possible
#print "Should open help"
#Methods processing data
def on_about(self, event):
"""
Displays the about box for Ivolution
"""
description =""" Ivolution is a project aiming at helping you
create videos of yourself over time.
Simply take pictures of yourself, Ivolution does
everything else for you.
Ivolution may be used for faces, but also profiles
(to show women along pregnancy for example)
or full body (for people workouting).
The only limitation comes from you !
"""
licence = """Copyright (c) <2012>, <Julien Lengrand-Lambert>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project."""
info = wx.AboutDialogInfo()
info.SetIcon(wx.Icon('ivolution/data/media/vitruve.png', wx.BITMAP_TYPE_PNG))
info.SetName('Ivolution')
info.SetVersion('0.8')
info.SetDescription(description)
info.SetCopyright('(C) 2012 Julien Lengrand-Lambert')
info.SetWebSite('http://www.lengrand.fr')
info.SetLicence(licence)
info.AddDeveloper('Julien Lengrand-Lambert')
info.AddDocWriter('Julien Lengrand-Lambert')
info.AddArtist('Luc Viatour')
info.AddTranslator('Julien Lengrand-Lambert')
wx.AboutBox(info)
def on_exit(self, event):
"""
Called when the IvolutionWindow is closed, or File/Exit is called.
"""
# Clean up code for saving application state should be added here.
self.notify(["Application", ["STOP"]]) # Asking the Facemovie to stop
self.process_running = False
self.Close(True) # Close the frame.
# system methods
def get_current_mode(self):
"""
"""
if self.cropmode.GetValue():
mode = "crop"
else:
mode = "conservative"
return mode
def get_current_sort(self):
"""
"""
if self.namemode.GetValue():
sort = "name"
else:
sort = "exif"
return sort
def set_parameters(self):
"""
Sets all needed parameters for create the movie.
Retrieves all parameters needed for the algorithm to run
"""
self.in_fo = self.filechooserinput.get_current_folder() + "/" # TODO : Find correct fix
self.out_fo = self.filechooseroutput.get_current_folder() + "/" # TODO : Find correct fix
self.param = self.typecombobox.get_active_text()
self.speed = self.speedcombobox.get_active() # We need and integer between 0 and 2
# Instantiating the face_params object that will be needed by the facemovie
self.out_fo += "/" #FIXME: enhance that
par_fo = os.path.join(self.root_fo, get_data("haarcascades"))
self.face_params = FaceParams.FaceParams(par_fo,
self.in_fo,
self.out_fo,
self.param,
self.sort,
self.mode,
self.speed)
self.in_fo,
self.out_fo,
self.param,
self.sort,
self.mode,
self.speed)
def print_parameters(self):
print "#########"
@@ -234,10 +314,10 @@ class IvolutionWindow(Observer, Observable):
if message[0] == "PROGRESS": # progress bar
# big steps performed
# Uses GLib to run Thread safe operations on GUI
GLib.idle_add(self.progressbar.set_fraction, float(message[2]))
GLib.idle_add(self.progressbar.set_text, message[1])
wx.MutexGuiEnter() # to avoid thread problems
self.progressgauge.SetValue(self.gaugerange * float(message[2]))
self.statusbar.SetStatusText(message[1], 0)
wx.MutexGuiLeave()
if float(message[2]) >= 1.0: # 100% of process
self.my_logger.debug("Reached end of facemovie process")
@@ -245,16 +325,35 @@ class IvolutionWindow(Observer, Observable):
self.process_running = False
elif message[0] == "STATUS": # status label
# intermediate results
GLib.idle_add(self.statuslabel.set_text, message[1])
#pass
if message[1] == "Error":
wx.MutexGuiEnter() # to avoid thread problems
self.statusbar.SetStatusText("Error detected", 0)
self.progressgauge.SetValue(0)
wx.MutexGuiLeave()
self.process_running = False
wx.MutexGuiEnter() # to avoid thread problems
self.statusbar.SetStatusText(message[1], 1)
wx.MutexGuiLeave()
elif message[0] == "FILEADD":
item = wx.ListItem()
item.SetText(message[1])
wx.MutexGuiEnter() # to avoid thread problems
self.filelist.InsertItem(item)
wx.MutexGuiLeave()
elif message[0] == "FILEDONE":
for i in range(self.filelist.GetItemCount()):
if message[1] == self.filelist.GetItemText(i):
if message[2] == 1:
color = "green"
else:
color = "red"
wx.MutexGuiEnter() # to avoid thread problems
self.filelist.SetItemTextColour(i, color)
wx.MutexGuiLeave()
elif len(message) > 1: # system commands shall be ignored
self.console_logger.debug("Unrecognized command")
self.my_logger.debug("Unrecognized command")
self.console_logger.debug(message)
self.my_logger.debug(message)
if __name__ == "__main__":
app = IvolutionWindow()
Gtk.main()

0
ivolution/gui/__init__.py Executable file → Normal file
View File

View File

@@ -1,359 +0,0 @@
#!/usr/bin/env python
"""
.. module:: IvolutionWindow
:platform: Unix, Windows, Mac
:synopsis: Main Window of the Ivolution GUI designed to be supported by all platforms.
.. moduleauthor:: Julien Lengrand-Lambert <jlengrand@gmail.com>
"""
import wx
import wx.lib.newevent
import sys
import os
import logging
import webbrowser
from .. import get_data # used to load images and files
from .. import FaceParams
from .. import FacemovieThread
from ..util.Notifier import Observer
from ..util.Notifier import Observable
from IvolutionTemplate import IvolutionTemplate
from SettingsWindow import SettingsWindow
class IvolutionWindow(IvolutionTemplate, Observer, Observable):
"""
Main Window of the Ivolution application
"""
def __init__(self, parent, title):
"""
Overrides init frame IvolutionTemplate
"""
IvolutionTemplate.__init__(self, parent)
Observer.__init__(self, "Interface")
Observable.__init__(self)
# Sets up logging capability
self.my_logger = None
self.console_logger = None
self.setup_logger()
# Defines all our parameters neededfor the facemovie
self.get_default_parameters()
self.process_running = False
self.facemovie = None
self.inputtextbox.SetLabel(self.in_fo) # sets label to default input folder
self.SetIcon(wx.Icon('ivolution/data/media/vitruve.ico', wx.BITMAP_TYPE_ICO)) # Sets icon
self.Show(True) # Finally show the frame
def get_default_parameters(self):
"""
"""
# FIXME: Put really general stuff here !
self.videospeedlistChoices = [u"slow", u"medium", u"fast"]
self.gaugerange = 100
self.root_fo = ""
self.mode = "crop" # type of video to be created
self.sort = "name" # how image files will be chronologically sorted
self.speed = 1 # Speed of the movie
self.param = "frontal_face" # type of face profile to be searched for
if "win" in sys.platform:
self.out_fo = "C:/Users/jll/Videos/" # Default folder for Windows
self.in_fo = "C:\Users\jll\Pictures/"
else:
self.out_fo = "/home/jll/Videos/" # Default folder for Linux
self.in_fo = "/home/jll/Pictures/"
# Overriding event handling methods
def on_settings(self, event):
settings = SettingsWindow(self)
settings.Show(True) # Finally show the frame
def on_start(self, event):
"""
User asks for starting the algorithm
Sets all parameters and start processing
"""
self.my_logger.debug("start pressed")
if not self.process_running: # start only if not already running
# Empty list on screen
self.filelist.DeleteAllItems()
self.set_parameters()
self.print_parameters()
# Instantiating the facemovie
self.facemovie = FacemovieThread.FacemovieThread(self.face_params)
self.facemovie.subscribe(self) # I want new information ! Subscribes to facemovie reports
self.subscribe(self.facemovie) # Subscribing facemovie to our messages
self.facemovie.start()
self.process_running = True
else:
self.console_logger.error("Cannot start, process already running !")
self.my_logger.error("Cannot start, process already running !")
def on_stop(self, event):
"""
User asks for stopping the algorithm
Asks the FacemovieThread to terminate
"""
self.my_logger.debug("Stop pressed")
self.console_logger.debug("Stop pressed")
self.notify(["Application", ["STOP"]]) # Asking the Facemovie to stop
self.process_running = False
#self.on_exit(event) # Finally shuts down the interface
def on_input(self, event):
"""
Activated when a user clicks to choose its input location
"""
self.inputdialog = wx.DirDialog(self, "Please choose your input directory", style=1, defaultPath=self.in_fo)
if self.inputdialog.ShowModal() == wx.ID_OK:
self.in_fo = self.inputdialog.GetPath()
self.inputtextbox.SetLabel(self.in_fo)
self.inputdialog.Destroy()
def on_output(self, event):
"""
Activated when a user clicks to choose its output location
"""
default_dir = "~/Videos"
self.outputdialog = wx.DirDialog(self, "Please choose your output directory", style=1, defaultPath=default_dir)
if self.outputdialog.ShowModal() == wx.ID_OK:
self.outputchoosertext.SetLabel(self.outputdialog.GetPath())
self.outputdialog.Destroy()
def on_help(self, event):
"""
Opens a browser and points to online help.
"""
url = "http://jlengrand.github.com/FaceMovie/"
webbrowser.open(url, new=2) # in new tab if possible
def on_about(self, event):
"""
Displays the about box for Ivolution
"""
description =""" Ivolution is a project aiming at helping you
create videos of yourself over time.
Simply take pictures of yourself, Ivolution does
everything else for you.
Ivolution may be used for faces, but also profiles
(to show women along pregnancy for example)
or full body (for people workouting).
The only limitation comes from you !
"""
licence = """Copyright (c) <2012>, <Julien Lengrand-Lambert>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project."""
info = wx.AboutDialogInfo()
info.SetIcon(wx.Icon('ivolution/data/media/vitruve.png', wx.BITMAP_TYPE_PNG))
info.SetName('Ivolution')
info.SetVersion('0.8')
info.SetDescription(description)
info.SetCopyright('(C) 2012 Julien Lengrand-Lambert')
info.SetWebSite('http://www.lengrand.fr')
info.SetLicence(licence)
info.AddDeveloper('Julien Lengrand-Lambert')
info.AddDocWriter('Julien Lengrand-Lambert')
info.AddArtist('Luc Viatour')
info.AddTranslator('Julien Lengrand-Lambert')
wx.AboutBox(info)
def on_exit(self, event):
"""
Called when the IvolutionWindow is closed, or File/Exit is called.
"""
# Clean up code for saving application state should be added here.
self.notify(["Application", ["STOP"]]) # Asking the Facemovie to stop
self.process_running = False
self.Close(True) # Close the frame.
# system methods
def get_current_mode(self):
"""
"""
if self.cropmode.GetValue():
mode = "crop"
else:
mode = "conservative"
return mode
def get_current_sort(self):
"""
"""
if self.namemode.GetValue():
sort = "name"
else:
sort = "exif"
return sort
def set_parameters(self):
"""
Retrieves all parameters needed for the algorithm to run
"""
# Instantiating the face_params object that will be needed by the facemovie
self.out_fo += "/" #FIXME: enhance that
par_fo = os.path.join(self.root_fo, get_data("haarcascades"))
self.face_params = FaceParams.FaceParams(par_fo,
self.in_fo,
self.out_fo,
self.param,
self.sort,
self.mode,
self.speed)
def print_parameters(self):
print "#########"
print "Settings:"
print "input folder : %s" % (self.in_fo)
print "output folder : %s" % (self.out_fo)
print "Face Type : %s" % (self.param)
print "Speed chosen : %s" % (self.speed)
print "Mode chosen : %s" % (self.mode)
print "Sort method : %s" % (self.sort)
print "#########"
def setup_logger(self):
"""
Configures our logger to save error messages
Start logging in file here
"""
personal_dir = "~/.ivolution"
log_root = 'fm.log'
log_file = os.path.join(os.path.expanduser(personal_dir), log_root)
# create logger for 'facemovie'
self.my_logger = logging.getLogger('FileLog')
self.my_logger.setLevel(logging.DEBUG)
# create file handler which logs even debug messages
#fh = logging.StreamHandler()
fh = logging.FileHandler(log_file)
fh.setLevel(logging.DEBUG)
# create console handler with a higher log level
self.console_logger = logging.getLogger('ConsoleLog')
self.console_logger.setLevel(logging.DEBUG) # not needed
ch = logging.StreamHandler()
#ch.setLevel(logging.DEBUG) # not needed
# add the handlers to the logger
self.my_logger.addHandler(fh)
self.my_logger.info("######") # Separating different sessions
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# create formatter and add it to the handlers
fh.setFormatter(formatter)
#ch.setFormatter(formatter)
self.console_logger.addHandler(ch)
def update(self, message):
"""
Trigerred by FacemovieThread.
Uses the Observer pattern to inform the user about the progress of the current job.
"""
if len(message) == 3:
# notifications
#self.console_logger.debug(message)
self.my_logger.debug(message)
if message[0] == "PROGRESS": # progress bar
# big steps performed
wx.MutexGuiEnter() # to avoid thread problems
self.progressgauge.SetValue(self.gaugerange * float(message[2]))
self.statusbar.SetStatusText(message[1], 0)
wx.MutexGuiLeave()
if float(message[2]) >= 1.0: # 100% of process
self.my_logger.debug("Reached end of facemovie process")
#self.console_logger.debug("Reached end of facemovie process")
self.process_running = False
elif message[0] == "STATUS": # status label
if message[1] == "Error":
wx.MutexGuiEnter() # to avoid thread problems
self.statusbar.SetStatusText("Error detected", 0)
self.progressgauge.SetValue(0)
wx.MutexGuiLeave()
self.process_running = False
wx.MutexGuiEnter() # to avoid thread problems
self.statusbar.SetStatusText(message[1], 1)
wx.MutexGuiLeave()
elif message[0] == "FILEADD":
item = wx.ListItem()
item.SetText(message[1])
wx.MutexGuiEnter() # to avoid thread problems
self.filelist.InsertItem(item)
wx.MutexGuiLeave()
elif message[0] == "FILEDONE":
for i in range(self.filelist.GetItemCount()):
if message[1] == self.filelist.GetItemText(i):
if message[2] == 1:
color = "green"
else:
color = "red"
wx.MutexGuiEnter() # to avoid thread problems
self.filelist.SetItemTextColour(i, color)
wx.MutexGuiLeave()
elif len(message) > 1: # system commands shall be ignored
self.console_logger.debug("Unrecognized command")
self.my_logger.debug("Unrecognized command")
self.console_logger.debug(message)
self.my_logger.debug(message)