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_dist/] [phr-gui.py] - Blame information for rev 242

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

Line No. Rev Author Line
1 172 maximiq
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# generated by wxGlade 0.6.3 on Tue Mar 18 21:30:25 2014
4
 
5
import wx
6
# imports by maximiq
7
import os          # se usa para el dialogo de abrir fichero
8
import subprocess  # para interactuar con el shell
9
 
10
# begin wxGlade: extracode
11
# end wxGlade
12
 
13
 
14
 
15
class MyFrame(wx.Frame):
16
    def __init__(self, *args, **kwds):
17
        # begin wxGlade: MyFrame.__init__
18
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
19
        wx.Frame.__init__(self, *args, **kwds)
20
        self.frame_1_statusbar = self.CreateStatusBar(1, 0)
21
        self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("imagen.jpg", wx.BITMAP_TYPE_ANY))
22
        self.label_1 = wx.StaticText(self, -1, "Aca puede ir algo de texto para aclarar como es el \nprocedimiento para hacer andar el programa.")
23
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
24
        self.button_3 = wx.Button(self, -1, "Elegir fichero")
25
        self.button_4 = wx.Button(self, -1, "Grabar")
26
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER|wx.TE_MULTILINE)
27
 
28
        self.__set_properties()
29
        self.__do_layout()
30
 
31
        self.Bind(wx.EVT_BUTTON, self.choose_file_button, self.button_3)
32
        self.Bind(wx.EVT_BUTTON, self.action_button, self.button_4)
33
        # end wxGlade
34
 
35
    def __set_properties(self):
36
        # begin wxGlade: MyFrame.__set_properties
37
        self.SetTitle("Titulo de la ventana")
38
        self.frame_1_statusbar.SetStatusWidths([-1])
39
        # statusbar fields
40
        frame_1_statusbar_fields = ["frame_1_statusbar"]
41
        for i in range(len(frame_1_statusbar_fields)):
42
            self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
43
        self.text_ctrl_2.SetMinSize((350, 135))
44
        # end wxGlade
45
 
46
    def __do_layout(self):
47
        # begin wxGlade: MyFrame.__do_layout
48
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
49
        grid_sizer_1 = wx.FlexGridSizer(5, 1, 0, 0)
50
        grid_sizer_2 = wx.FlexGridSizer(1, 3, 0, 0)
51
        grid_sizer_1.Add(self.bitmap_1, 0, wx.ALL, 5)
52
        grid_sizer_1.Add(self.label_1, 0, wx.ALL, 5)
53
        grid_sizer_2.Add(self.text_ctrl_3, 0, wx.ALL|wx.EXPAND, 5)
54
        grid_sizer_2.Add(self.button_3, 0, wx.RIGHT|wx.TOP|wx.BOTTOM, 5)
55
        grid_sizer_2.Add(self.button_4, 0, wx.RIGHT|wx.TOP|wx.BOTTOM, 5)
56
        grid_sizer_2.AddGrowableCol(0)
57
        grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
58
        grid_sizer_1.Add(self.text_ctrl_2, 0, wx.ALL|wx.EXPAND, 5)
59
        sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
60
        self.SetSizer(sizer_1)
61
        sizer_1.Fit(self)
62
        self.Layout()
63
        self.Centre()
64
        # end wxGlade
65
 
66
    def choose_file_button(self, event): # wxGlade: MyFrame.<event_handler>
67
        #funcion editada por maximiq
68
        #self.text_ctrl_3.SetValue("Hola")
69
 
70
        wildcard = "Python source (*.py)|*.py|" \
71
                   "Compiled Python (*.pyc)|*.pyc|" \
72
                   "All files (*.*)|*.*"
73
        dialog = wx.FileDialog(None, "Titulo de la ventana", os.getcwd(), "", wildcard, wx.OPEN)
74
        if dialog.ShowModal() == wx.ID_OK:
75
            self.text_ctrl_3.SetValue(dialog.GetPath())
76
 
77
        dialog.Destroy()
78
 
79
        event.Skip()
80
 
81
    def action_button(self, event): # wxGlade: MyFrame.<event_handler>
82
        #print "Event handler `action_button' not implemented"
83
        # by maximiq
84
 
85
        # preparar entorno
86
        self.button_4.Disable()
87
        self.frame_1_statusbar.SetFields(["Espere ..."])
88
 
89
        self.text_ctrl_2.WriteText("\n======================================\n" \
90
                                   + "El fichero elegido es:\n" \
91
                                   + self.text_ctrl_3.GetValue() \
92
                                   + "\n\nEjecucion de un comando (dir c:):\n")
93
 
94
        command = "dir c:"  # the shell command
95
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
96
 
97
        for line in iter(process.stdout.readline, ''):
98
            self.text_ctrl_2.WriteText(line)
99
        process.stdout.close()
100
 
101
        # finalizando 
102
        self.button_4.Enable()
103
        self.frame_1_statusbar.SetFields(["Listo"])
104
 
105
        event.Skip()
106
 
107
# end of class MyFrame
108
 
109
 
110
if __name__ == "__main__":
111
    app = wx.App(False)
112
    #wx.InitAllImageHandlers()
113
    frame_1 = MyFrame(None, -1, "")
114
    app.SetTopWindow(frame_1)
115
    frame_1.Show()
116
    app.MainLoop()

powered by: WebSVN 2.1.0

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