GUI starts to take interaction from user.

Lots of bugs to be corrected.
Signals still to be connected.
This commit is contained in:
2012-07-18 14:04:12 +02:00
parent 4477735d12
commit a2cff86080
4 changed files with 206 additions and 13 deletions

29
AboutDialog.py Normal file
View File

@@ -0,0 +1,29 @@
from gi.repository import Gtk
class AboutDialog(Gtk.AboutDialog):
def __new__(cls):
"""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("data/ui/AboutIvolutionDialog.glade")
new_object = builder.get_object("about_ivolution_dialog")
new_object.finish_initializing(builder)
return new_object
def finish_initializing(self, builder):
"""Called while initializing this instance in __new__
finish_initalizing should be called after parsing the ui definition
and creating a AboutDialog object with it in order
to finish initializing the start of the new AboutIvolutionDialog
instance.
Put your initialization code in here and leave __init__ undefined.
"""
# Get a reference to the builder and set up the signals.
print "in"

View File

@@ -2,19 +2,133 @@
from gi.repository import Gtk
class Ivolution(object):
def __init__(self):
builder = Gtk.Builder()
builder.add_from_file("data/ui/IvolutionWindow.glade")
#builder.connect_signals({ "on_window_destroy" : gtk.main_quit })
self.window = builder.get_object("ivolution_window")
self.window.show()
from AboutDialog import AboutDialog
def on_destroy(self, widget, data=None):
"""Called when the IvolutionWindow is closed."""
# Clean up code for saving application state should be added here.
Gtk.main_quit()
class Ivolution():
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file("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 parameters needed to run the FaceMovie
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 imaes are located
self.facemovie = None
self.AboutDialog = None # class
self.setup()
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")
# 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"
else:
self.mode = "conservative"
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"
def on_startbutton_pressed(self, widget):
"""
Sets all parameters and start processing
"""
self.set_parameters()
self.print_parameters()
def on_stopbutton_pressed(self, widget):
"""
Asks the Facemovie thread to terminate
"""
print "Stop"
def on_destroy(self, widget, data=None):
"""Called when the IvolutionWindow is closed."""
# Clean up code for saving application state should be added here.
Gtk.main_quit()
print "Gtk Exited"
def on_menu_about_activate(self, widget, data=None):
"""
Displays the about box for Ivolution
# FIXME : Not working !
"""
if self.AboutDialog is not None:
about = self.AboutDialog()
response = about.run()
about.destroy()
#Methods processing data
def set_parameters(self):
"""
Sets all needed parameters for create the movie.
"""
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
par_fo = os.path.join(self.root_fo, "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 self.in_fo
print self.out_fo
print self.param
print self.speed
print self.mode
print self.sort
if __name__ == "__main__":
app = Ivolution()
Gtk.main()
app = Ivolution()
Gtk.main()

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires about_ivolution_dialog 1.0 -->
<!-- interface-requires gtk+ 3.0 -->
<object class="AboutIvolutionDialog" 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="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

@@ -11,6 +11,7 @@
<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>
@@ -50,6 +51,7 @@
<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>
@@ -404,6 +406,7 @@ automatically generate a movie! </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>
@@ -503,6 +506,7 @@ automatically generate a movie! </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>
@@ -593,6 +597,7 @@ automatically generate a movie! </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>
@@ -617,6 +622,7 @@ automatically generate a movie! </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>