OpenCores
URL https://opencores.org/ocsvn/phr/phr/trunk

Subversion Repositories phr

[/] [phr/] [trunk/] [codigo/] [gui/] [windows/] [minimal python2.7.6/] [wx_simple_gui_events/] [phr-gui.py] - Rev 405

Go to most recent revision | Compare with Previous | Blame | View Log

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Tue Mar 18 21:30:25 2014
 
import wx
# imports by maximiq
import os          # se usa para el dialogo de abrir fichero
import subprocess  # para interactuar con el shell
 
# begin wxGlade: extracode
# end wxGlade
 
 
 
class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.frame_1_statusbar = self.CreateStatusBar(1, 0)
        self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("imagen.jpg", wx.BITMAP_TYPE_ANY))
        self.label_1 = wx.StaticText(self, -1, "Aca puede ir algo de texto para aclarar como es el \nprocedimiento para hacer andar el programa.")
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
        self.button_3 = wx.Button(self, -1, "Elegir fichero")
        self.button_4 = wx.Button(self, -1, "Grabar")
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER|wx.TE_MULTILINE)
 
        self.__set_properties()
        self.__do_layout()
 
        self.Bind(wx.EVT_BUTTON, self.choose_file_button, self.button_3)
        self.Bind(wx.EVT_BUTTON, self.action_button, self.button_4)
        # end wxGlade
 
    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("Titulo de la ventana")
        self.frame_1_statusbar.SetStatusWidths([-1])
        # statusbar fields
        frame_1_statusbar_fields = ["frame_1_statusbar"]
        for i in range(len(frame_1_statusbar_fields)):
            self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
        self.text_ctrl_2.SetMinSize((350, 135))
        # end wxGlade
 
    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.FlexGridSizer(5, 1, 0, 0)
        grid_sizer_2 = wx.FlexGridSizer(1, 3, 0, 0)
        grid_sizer_1.Add(self.bitmap_1, 0, wx.ALL, 5)
        grid_sizer_1.Add(self.label_1, 0, wx.ALL, 5)
        grid_sizer_2.Add(self.text_ctrl_3, 0, wx.ALL|wx.EXPAND, 5)
        grid_sizer_2.Add(self.button_3, 0, wx.RIGHT|wx.TOP|wx.BOTTOM, 5)
        grid_sizer_2.Add(self.button_4, 0, wx.RIGHT|wx.TOP|wx.BOTTOM, 5)
        grid_sizer_2.AddGrowableCol(0)
        grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
        grid_sizer_1.Add(self.text_ctrl_2, 0, wx.ALL|wx.EXPAND, 5)
        sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        self.Centre()
        # end wxGlade
 
    def choose_file_button(self, event): # wxGlade: MyFrame.<event_handler>
        #funcion editada por maximiq
        #self.text_ctrl_3.SetValue("Hola")
 
        wildcard = "Python source (*.py)|*.py|" \
                   "Compiled Python (*.pyc)|*.pyc|" \
                   "All files (*.*)|*.*"
        dialog = wx.FileDialog(None, "Titulo de la ventana", os.getcwd(), "", wildcard, wx.OPEN)
        if dialog.ShowModal() == wx.ID_OK:
            self.text_ctrl_3.SetValue(dialog.GetPath())
 
        dialog.Destroy()
 
        event.Skip()
 
    def action_button(self, event): # wxGlade: MyFrame.<event_handler>
        #print "Event handler `action_button' not implemented"
        # by maximiq
 
        # preparar entorno
        self.button_4.Disable()
        self.frame_1_statusbar.SetFields(["Espere ..."])
 
        self.text_ctrl_2.WriteText("\n======================================\n" \
                                   + "El fichero elegido es:\n" \
                                   + self.text_ctrl_3.GetValue() \
                                   + "\n\nEjecucion de un comando (dir c:):\n")
 
        command = "dir c:"  # the shell command
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
 
        for line in iter(process.stdout.readline, ''):
            self.text_ctrl_2.WriteText(line)
        process.stdout.close()
 
        # finalizando 
        self.button_4.Enable()
        self.frame_1_statusbar.SetFields(["Listo"])
 
        event.Skip()
 
# end of class MyFrame
 
 
if __name__ == "__main__":
    app = wx.App(False)
    #wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.