Ejemplo n.º 1
0
class PanelCompiler(
        wx.Panel, ):
    def __init__(self, parent):

        wx.Panel.__init__(self, parent)
        self.SetBackgroundColour("3399FF")

        self.button = wx.Button(self,
                                label="Compilar",
                                pos=(35, 110),
                                size=(80, 50))
        self.Bind(wx.EVT_BUTTON, self.Compilar, self.button)

        self.button_2 = wx.Button(self,
                                  wx.ID_OK,
                                  label="Enviar",
                                  pos=(35, 170),
                                  size=(80, 50))
        self.Bind(wx.EVT_BUTTON, self.Enviar, self.button_2)

        self.grid_panel = wx.Panel(self, pos=(200, 20), size=(620, 300))

        self.shell = PyShell(self.grid_panel)
        self.shell.write("prueba")
        dimensionador = wx.BoxSizer(wx.VERTICAL)
        dimensionador.Add(self.shell, 1, wx.EXPAND | wx.ALL, border=10)
        self.grid_panel.SetSizer(dimensionador)

    def Compilar(self, event):
        print "Compilando"

    def Enviar(self, event):
        print "Enviado"
Ejemplo n.º 2
0
class PanelCompiler(wx.Panel,):
    def __init__(self, parent):
        
        wx.Panel.__init__(self, parent)
	self.SetBackgroundColour("3399FF")
                
        self.button = wx.Button(self, label="Compilar", pos=(35, 110), size=(80,50))
        self.Bind(wx.EVT_BUTTON, self.Compilar,self.button)

        self.button_2 = wx.Button(self, wx.ID_OK, label="Enviar", pos=(35, 170),size=(80,50))
        self.Bind(wx.EVT_BUTTON, self.Enviar,self.button_2)
        
        self.grid_panel = wx.Panel(self,pos=(200,20),size=(620,300))
         
        self.shell = PyShell(self.grid_panel)
        self.shell.write("prueba")
        dimensionador = wx.BoxSizer(wx.VERTICAL) 
        dimensionador.Add(self.shell,1 ,wx.EXPAND| wx.ALL,border=10)
        self.grid_panel.SetSizer(dimensionador)
     

    def Compilar(self,event):
        print "Compilando"

       

    def Enviar(self,event):
        print "Enviado"
Ejemplo n.º 3
0
class ConsoleDlg(wx.Frame):
    def __init__(self, parent):
        self.__layout_frame = parent
        self.__context = parent.GetContext()

        # create GUI
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          'Python Console',
                          size=(500, 300),
                          style=wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.CAPTION
                          | wx.CLOSE_BOX | wx.SYSTEM_MENU)

        menu_bar = wx.MenuBar()
        menu = wx.Menu()
        menu_run_script = menu.Append(wx.NewId(), '&Run Script\tAlt-R',
                                      'Run a script in the console.')
        menu_bar.Append(menu, '&Shell')
        self.SetMenuBar(menu_bar)

        self.__shell = Shell(self)

        # set up what user is given to work with
        self.__shell.interp.locals = {'context': self.__context}

        self.Bind(wx.EVT_CLOSE,
                  lambda evt: self.Hide())  # Hide instead of closing
        self.Bind(wx.EVT_MENU, self.OnRunScript)

    def OnRunScript(self, evt):
        # Loop until user saves or cancels
        dlg = wx.FileDialog(self,
                            'Run Python Script',
                            wildcard='Python Scripts (*.py)|*.py',
                            style=wx.FD_OPEN | wx.FD_CHANGE_DIR)
        dlg.ShowModal()
        ret = dlg.GetReturnCode()
        fp = dlg.GetPath()
        dlg.Destroy()

        if ret == wx.ID_CANCEL:
            return
        self.__shell.write('Running Script... ' + fp)
        self.__shell.run('execfile(\'%s\')' % fp)
Ejemplo n.º 4
0
class PanelScript(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.intro = "Interactive Phase Retrieval Suite"
        self.shell = Shell(parent=self, id=wx.ID_ANY, introText=self.intro)
        self.shell.zoom(2)
        self.shell.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown, self.shell)
        self.ih = 0
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.shell,
                  1,
                  flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP,
                  border=2)
        sizer.Fit(self)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        self.Layout()

    def OnKeyDown(self, event):
        if self.shell.AutoCompActive():
            event.Skip()
            return
        key = event.GetKeyCode()
        if key == wx.WXK_RETURN:
            self.ih = 0
            self.shell.processLine()
            self.shell.clearCommand()
        elif key == wx.WXK_UP:
            if self.ih < len(self.shell.history):
                self.ih += 1
                self.shell.clearCommand()
                self.shell.write(self.shell.history[(self.ih - 1)])
        elif key == wx.WXK_DOWN:
            self.shell.clearCommand()
            self.ih -= 1
            if self.ih > 0:
                self.shell.write(self.shell.history[self.ih - 1])
            else:
                self.ih = 0
        else:
            event.Skip()