#!/usr/bin/env python # -*- coding: utf-8 -*- # generated by wxGlade 0.6.3 on Fri Jan 8 23:17:51 2010 import wx # begin wxGlade: extracode import subprocess # end wxGlade class MyTaskBarIcon(wx.TaskBarIcon): def __init__(self, frame): wx.TaskBarIcon.__init__(self) self.frame = frame self.SetIcon(wx.Icon('icono.png', wx.BITMAP_TYPE_PNG), 'Grabar Pantalla') self.Bind(wx.EVT_MENU, self.OnTaskBarActivate, id=1) self.Bind(wx.EVT_MENU, self.OnTaskBarDeactivate, id=2) self.Bind(wx.EVT_MENU, frame.on_boton_ok, id=3) self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=4) def CreatePopupMenu(self): menu = wx.Menu() menu.Append(1, 'Mostrar opciones') menu.Append(2, 'Ocultar') menu.Append(3, 'Comenzar a grabar') menu.Append(4, 'Cerrar') return menu def OnTaskBarClose(self, event): self.frame.Close() def OnTaskBarActivate(self, event): if not self.frame.IsShown(): self.frame.Show() def OnTaskBarDeactivate(self, event): if self.frame.IsShown(): self.frame.Hide() class Principal(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: Principal.__init__ self.tskic = MyTaskBarIcon(self) wx.Frame.__init__(self, *args, **kwds) self.Bind(wx.EVT_CLOSE, self.OnClose) kwds["style"] = wx.FRAME_NO_TASKBAR self.label_fichero = wx.StaticText(self, -1, "Fichero:") self.text_ctrl_fichero = wx.TextCtrl(self, -1, "") self.label_tiempo = wx.StaticText(self, -1, u"Tiempo de grabación:") self.spin_ctrl_tiempo = wx.SpinCtrl(self, -1, "1", min=0, max=100) self.label_espera = wx.StaticText(self, -1, "Esperar:") self.spin_ctrl_esperar = wx.SpinCtrl(self, -1, "1", min=0, max=100) self.label_area = wx.StaticText(self, -1, "Area a grabar:") self.checkbox_area = wx.CheckBox(self, -1, "Pantalla completa") self.label_posx = wx.StaticText(self, -1, u"Posición X:") self.spin_ctrl_posx = wx.SpinCtrl(self, -1, "0", min=0, max=3000) self.label_posy = wx.StaticText(self, -1, u"Posición Y:\n") self.spin_ctrl_posy = wx.SpinCtrl(self, -1, "0", min=0, max=3000) self.label_ancho = wx.StaticText(self, -1, "Ancho:") self.spin_ctrl_ancho = wx.SpinCtrl(self, -1, "100", min=0, max=3000) self.label_alto = wx.StaticText(self, -1, "Altura:") self.spin_ctrl_alto = wx.SpinCtrl(self, -1, "100", min=0, max=3000) self.checkbox_cursor = wx.CheckBox(self, -1, "Mostrar cursor") #self.checkbox_loop = wx.CheckBox(self, -1, "Loop") self.checkbox_cerrar = wx.CheckBox(self, -1, "Cerrar al terminar") self.button_grabar = wx.Button(self, wx.ID_OK, "") self.button_salir = wx.Button(self, wx.ID_EXIT, "") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.on_boton_ok, self.button_grabar) self.Bind(wx.EVT_BUTTON, self.on_boton_salir, self.button_salir) # end wxGlade def __set_properties(self): # begin wxGlade: Principal.__set_properties self.SetTitle("Grabador de pantalla byzanx") self.SetSize((366, 350)) self.SetBackgroundColour(wx.Colour(255, 255, 255)) _icon = wx.EmptyIcon() _icon.CopyFromBitmap(wx.Bitmap("icono.png", wx.BITMAP_TYPE_ANY)) self.SetIcon(_icon) self.text_ctrl_fichero.SetMinSize((200, 27)) self.text_ctrl_fichero.SetToolTipString("Nombre de fichero .gif para Imagen, .ogv para Video") self.spin_ctrl_tiempo.SetToolTipString("Tiempo") self.spin_ctrl_esperar.SetToolTipString("Tiempo a esperar antes de empezar a grabar") self.checkbox_area.SetToolTipString("Grabar toda la pantalla") self.spin_ctrl_posx.SetToolTipString(u"Posición X") self.spin_ctrl_posy.SetToolTipString(u"Posición Y") self.spin_ctrl_ancho.SetToolTipString(u"Ancho del área") self.spin_ctrl_alto.SetToolTipString(u"Altura del área") self.checkbox_cursor.SetToolTipString("Mostrar cursor") #self.checkbox_loop.SetToolTipString("Reproducir en lazo") self.checkbox_cerrar.SetToolTipString("Cerrar al terminar de grabar") self.button_grabar.SetToolTipString(u"Iniciar grabación") self.button_salir.SetToolTipString("Salir") # end wxGlade def __do_layout(self): # begin wxGlade: Principal.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) sizer_2 = wx.BoxSizer(wx.VERTICAL) grid_sizer_1 = wx.FlexGridSizer(2, 4, 2, 2) sizer_2.Add(self.label_fichero, 0, 0, 0) sizer_2.Add(self.text_ctrl_fichero, 0, 0, 0) sizer_2.Add(self.label_tiempo, 0, 0, 0) sizer_2.Add(self.spin_ctrl_tiempo, 0, 0, 0) sizer_2.Add(self.label_espera, 0, 0, 0) sizer_2.Add(self.spin_ctrl_esperar, 0, 0, 0) sizer_2.Add(self.label_area, 0, 0, 0) sizer_2.Add(self.checkbox_area, 0, 0, 0) grid_sizer_1.Add(self.label_posx, 0, 0, 0) grid_sizer_1.Add(self.spin_ctrl_posx, 0, 0, 0) grid_sizer_1.Add(self.label_posy, 0, 0, 0) grid_sizer_1.Add(self.spin_ctrl_posy, 0, 0, 0) grid_sizer_1.Add(self.label_ancho, 0, 0, 0) grid_sizer_1.Add(self.spin_ctrl_ancho, 0, 0, 0) grid_sizer_1.Add(self.label_alto, 0, 0, 0) grid_sizer_1.Add(self.spin_ctrl_alto, 0, 0, 0) sizer_2.Add(grid_sizer_1, 1, wx.EXPAND, 0) sizer_2.Add(self.checkbox_cursor, 0, 0, 0) #sizer_2.Add(self.checkbox_loop, 0, 0, 0) sizer_2.Add(self.checkbox_cerrar, 0, 0, 0) sizer_2.Add(self.button_grabar, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) sizer_2.Add(self.button_salir, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) self.SetSizer(sizer_1) self.Layout() # end wxGlade def on_boton_ok(self, event): # wxGlade: Principal. if self.checkbox_area.IsChecked(): area = ' --display= ' else: area = ' --x=' + str(self.spin_ctrl_posx.GetValue()) + ' --y=' + str(self.spin_ctrl_posy.GetValue()) + ' --width=' + str(self.spin_ctrl_ancho.GetValue()) + ' --height=' + str(self.spin_ctrl_alto.GetValue()) if self.checkbox_cursor.IsChecked(): cursor = ' -c ' else: cursor = '' #if self.checkbox_loop.IsChecked(): # loop = ' -l ' #else: # loop = '' tiempo = ' -d ' + str(self.spin_ctrl_tiempo.GetValue()) if self.text_ctrl_fichero.GetValue(): fichero = ' ' + self.text_ctrl_fichero.GetValue() else: fichero = ' pantalla.gif' delay = ' --delay=' + str(self.spin_ctrl_esperar.GetValue()) #comando = 'byzanz-record' + delay + tiempo + loop + cursor + area + fichero comando = 'byzanz-record -v' + delay + tiempo + cursor + area + fichero print 'Ejecutando: ' + comando result = subprocess.Popen(comando, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() if result: print result[0] if self.checkbox_cerrar.IsChecked(): self.Close() def on_boton_salir(self, event): # wxGlade: Principal. self.Close() def OnClose(self, event): self.tskic.Destroy() self.Destroy() # end of class Principal if __name__ == "__main__": app = wx.PySimpleApp(0) wx.InitAllImageHandlers() frame_principal = Principal(None, -1, "") app.SetTopWindow(frame_principal) frame_principal.Show() app.MainLoop()