mirror of
https://github.com/jlengrand/Ivolution.git
synced 2026-03-10 08:21:18 +00:00
Struggling to get the status bar working
This commit is contained in:
@@ -1,34 +1,33 @@
|
||||
"""
|
||||
.. module:: Facemovie
|
||||
:platform: Unix, Windows
|
||||
:synopsis: Main class of the application. Contains the core image processing functions.Plays the role of a controller for the application, as it supports the communication layer with the end user interface.
|
||||
:synopsis: Main class of the application. Contains the core image processing functions.Plays the role of a controller for the application, as it supports the communication layer.
|
||||
|
||||
.. moduleauthor:: Julien Lengrand-Lambert <jlengrand@gmail.com>
|
||||
|
||||
"""
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
import logging
|
||||
|
||||
import Facemovie_lib
|
||||
|
||||
from util.Notifier import Observer
|
||||
from util.Notifier import Observer
|
||||
from util.Notifier import Observable
|
||||
|
||||
|
||||
class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
'''
|
||||
Creates a Thread version of Facemovie using the facemovie_lib.
|
||||
This class can then be run anywhere, from a GUI, script, ...
|
||||
'''
|
||||
'''
|
||||
def __init__(self, face_params):
|
||||
"""
|
||||
Initializes all parameters of the application. Input and output folders
|
||||
are defined, together with the classifier profile.
|
||||
|
||||
:param face_params: A faceparams object that contains all needed information to run the Facemovie.
|
||||
:type face_params: FaceParams
|
||||
:type face_params: FaceParams
|
||||
"""
|
||||
threading.Thread.__init__(self)
|
||||
Observable.__init__(self)
|
||||
@@ -38,18 +37,18 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
|
||||
self.face_params = face_params
|
||||
self.facemovie = Facemovie_lib.FaceMovie(self.face_params)
|
||||
self.facemovie.subscribe(self) # Subscribing to facemovie reports
|
||||
self.subscribe(self.facemovie) # Used to send request to stop
|
||||
self.facemovie.subscribe(self) # Subscribing to facemovie reports
|
||||
self.subscribe(self.facemovie) # Used to send request to stop
|
||||
|
||||
self.my_logger = logging.getLogger('FileLog')
|
||||
self.console_logger = logging.getLogger('ConsoleLog')
|
||||
|
||||
def update(self, message):
|
||||
"""
|
||||
Trigerred by IvolutionWindow.
|
||||
Trigerred by IvolutionWindow.
|
||||
Uses the Observer pattern to inform the user about the progress of the GUI.
|
||||
"""
|
||||
if len(message) == 1 :
|
||||
if len(message) == 1:
|
||||
# system commands
|
||||
if message[0] == "STOP":
|
||||
self.console_logger.debug("Facemovie is going to stop")
|
||||
@@ -57,11 +56,11 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
|
||||
self.stop_process = True
|
||||
self.notify(["STOP"])
|
||||
else :
|
||||
else:
|
||||
self.console_logger.debug("Unrecognized system command")
|
||||
self.my_logger.debug("Unrecognized system command")
|
||||
#self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
elif len(message) == 2:
|
||||
# notifications
|
||||
#self.console_logger.debug(message)
|
||||
@@ -73,7 +72,7 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
self.console_logger.debug("Unrecognized command")
|
||||
self.my_logger.debug("Unrecognized command")
|
||||
self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
|
||||
def run(self):
|
||||
|
||||
@@ -87,17 +86,17 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
if not self.stop_process:
|
||||
self.my_logger.debug("Detecting Faces")
|
||||
self.notify(["PROGRESS", "Detecting Faces", 0.2])
|
||||
self.facemovie.prepare_faces() # I want to search for the faces, and characteristics of the images
|
||||
self.facemovie.prepare_faces() # I want to search for the faces, and characteristics of the images
|
||||
|
||||
if not self.stop_process:
|
||||
self.my_logger.debug("Calculating video requirements")
|
||||
self.notify(["PROGRESS", "Calculating video requirements", 0.6])
|
||||
self.facemovie.find_final_dimensions() # finds output size for desired mode.
|
||||
self.facemovie.find_final_dimensions() # finds output size for desired mode.
|
||||
|
||||
if not self.stop_process:
|
||||
self.my_logger.debug("Generating movie")
|
||||
self.notify(["PROGRESS", "Generating movie", 0.8])
|
||||
self.facemovie.save_movie()
|
||||
self.facemovie.save_movie()
|
||||
self.my_logger.debug("Movie saved")
|
||||
self.notify(["PROGRESS", "Movie saved, Finished!", 1.0])
|
||||
# updating status to avoid remanent messages
|
||||
@@ -107,4 +106,4 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
self.my_logger.debug("Thread terminated")
|
||||
|
||||
if self.stop_process:
|
||||
self.notify(["PROGRESS", "Process cancelled!", 1.0])
|
||||
self.notify(["PROGRESS", "Process cancelled!", 1.0])
|
||||
|
||||
@@ -63,7 +63,7 @@ class IvolutionWindow(wx.Frame, Observer, Observable):
|
||||
# Creating the buttons layout
|
||||
buttons = self.setup_buttonslayout()
|
||||
# Creating the status bar
|
||||
# self.statusbar = self.setup_statusbar()
|
||||
self.statusbar = self.setup_statusbar()
|
||||
|
||||
# Creating the main grid
|
||||
maingrid = self.setup_maingrid(title, settings, buttons)
|
||||
@@ -114,7 +114,7 @@ class IvolutionWindow(wx.Frame, Observer, Observable):
|
||||
inputtext = wx.StaticText(self.panel, label="Choose your input folder:")
|
||||
|
||||
inputchooserbox = wx.FlexGridSizer(1, 2, 0, 0)
|
||||
self.inputchoosertext = wx.StaticText(self.panel, label="~/Pictures")
|
||||
self.inputchoosertext = wx.StaticText(self.panel, label="/home/jll/Documents/Ivolution/ivolution/data/samples/")
|
||||
inputchooserbutton = wx.Button(self.panel, label="..")
|
||||
inputchooserbutton.Bind(wx.EVT_BUTTON, self.on_input)
|
||||
#inputchooser = wx.DirDialog(self.panel, "Please choose your project directory:", style=1 ,defaultPath=os.getcwd())
|
||||
@@ -240,10 +240,12 @@ class IvolutionWindow(wx.Frame, Observer, Observable):
|
||||
maingrid.AddMany([title, settings, buttons])
|
||||
return maingrid
|
||||
|
||||
# def setup_statusbar(self):
|
||||
# """
|
||||
# Sets up all elements of the status bar
|
||||
# """
|
||||
def setup_statusbar(self):
|
||||
"""
|
||||
Sets up all elements of the status bar
|
||||
"""
|
||||
self.sb = self.CreateStatusBar()
|
||||
|
||||
def setup_filemenu(self):
|
||||
"""
|
||||
Sets up all elements of the file menu
|
||||
@@ -480,7 +482,10 @@ class IvolutionWindow(wx.Frame, Observer, Observable):
|
||||
# TODO : status bar here
|
||||
# intermediate results
|
||||
#GLib.idle_add(self.statuslabel.set_text, message[1])
|
||||
pass
|
||||
#self.sb.SetStatusText(message[1])
|
||||
wx.CallAfter( self.sb.SetStatusText , message[1])
|
||||
#self.sb.Update()
|
||||
#wx.Yield()
|
||||
|
||||
elif len(message) > 1: # system commands shall be ignored
|
||||
self.console_logger.debug("Unrecognized command")
|
||||
|
||||
Reference in New Issue
Block a user