Terminal in a Python / Tkinter program. The text disappears below

0

I am doing my first program in tkinter and I want to incorporate the linux terminal, as for example it has the Atom editor. I have managed to incorporate it, but when executing an order the text disappears inside the frame and you can only see the command line doing a clear.

The GUI code is as follows, leaving the terminal built into Frame2:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tkinter import *
from tkinter import ttk
import tkinter as tk

from conectar import Conecta
from venta import TabVenta
from stock import TabStock
from emailTab import TabEmail
from altaTab import AltaProductos
import os
root = Tk()
class GUI(Frame):
def btn_press(self,event):
    x, y, widget = event.x, event.y, event.widget
    elem = widget.identify(x, y)
    index = widget.index("@%d,%d" % (x, y))
    if "close" in elem:
        widget.state(['pressed'])
        widget.pressed_index = index
def btn_release(self,event):
    x, y, widget = event.x, event.y, event.widget
    if not widget.instate(['pressed']):
        return
    elem =  widget.identify(x, y)
    index = widget.index("@%d,%d" % (x, y))
    if "close" in elem and widget.pressed_index == index:
        widget.forget(index)
        widget.event_generate("<<NotebookClosedTab>>")
    widget.state(["!pressed"])
    widget.pressed_index = None
def __init__(self, master):
    master.geometry("{0}x{1}+0+0".format(master.winfo_screenwidth(), master.winfo_screenheight()))
    master.update()
    self.ancho = master.winfo_width()
    self.alto = master.winfo_height()

    def formulario(alto,ancho):
        nuevatab = ttk.Frame(note)
        TabVenta(nuevatab,Frame3,alto,ancho)
        note.add(nuevatab, text = "Formulario venta", compound=TOP)
        note.pack(fill="both", expand=True)
    def stock():
        nuevatab = ttk.Frame(note)
        TabStock(nuevatab,Frame3,self.alto,self.ancho)
        note.add(nuevatab, text = "Gestión de Stock", compound=TOP)
        note.pack(fill="both", expand=True)
    def email():
        nuevatab = ttk.Frame(note)
        TabEmail(nuevatab,Frame3,self.alto,self.ancho)
        note.add(nuevatab, text = "Envío de emails", compound=TOP)
        note.pack(fill="both", expand=True)
    def alta():
        nuevatab = ttk.Frame(note)
        AltaProductos(nuevatab,Frame3,self.alto,self.ancho)
        note.add(nuevatab, text = "Alta de productos", compound=TOP)
        note.pack(fill="both", expand=True)
    PhotoImage
    i1 = tkinter.PhotoImage("img_close", file="/home/manu/Escritorio/mc/ICONOS/close.png")
    i2 = tkinter.PhotoImage("img_closeactive",file="/home/manu/Escritorio/mc/ICONOS/close.png")
    i3 = tkinter.PhotoImage("img_closepressed",file="/home/manu/Escritorio/mc/ICONOS/close.png")
    style = ttk.Style()
    style.element_create("close", "image", "img_close",
        ("active", "pressed", "!disabled", "img_closepressed"),
        ("active", "!disabled", "img_closeactive"), border=8, sticky='')
    style.layout("ButtonNotebook", [("ButtonNotebook.client", {"sticky": "nswe"})])
    style.layout("ButtonNotebook.Tab", [
        ("ButtonNotebook.tab", {"sticky": "nswe", "children":
            [("ButtonNotebook.padding", {"side": "top", "sticky": "nswe",
                                         "children":
                [("ButtonNotebook.focus", {"side": "top", "sticky": "nswe",
                                           "children":
                    [("ButtonNotebook.label", {"side": "left", "sticky": ''}),
                     ("ButtonNotebook.close", {"side": "left", "sticky": ''})]
                })]
            })]
        })]
    )
    Frame.__init__(self, master, relief=SUNKEN, bd=2)
    # no incluido self.menubar = Menu(self)
            Frame.__init__(self, master)
    Frame1 = Frame(master, bg="white")
    Frame1.place(x=0,y=0,width=3*self.ancho/4,height=3*self.alto/4)

    #Frame2 = Frame(master, bg="black")
    #Frame2.place(x=0,y=3*self.alto/4,width=3*self.ancho/4,height=self.alto/4)

    Frame2 = Frame(master,padx=10, pady=50)

    Frame2.place(x=0,y=3*self.alto/4,width=3*self.ancho/4,height=self.alto/4)
    wid = Frame2.winfo_id()
    os.system('xterm -into %d -geometry 300x10 -sb &' % wid)


    Frame3 = Frame(master, bg="#b3b6bc")
    Frame3.place(x=3*self.ancho/4,y=0,width=self.ancho/4,height=self.alto)
    label = Label(Frame3, text="OUTPUT QUE MUESTRA INFO").pack()
    self.master.bind_class("TNotebook", "<ButtonPress-1>", self.btn_press, True)
    self.master.bind_class("TNotebook", "<ButtonRelease-1>", self.btn_release)
    note = ttk.Notebook(Frame1, style="ButtonNotebook")
    note.pressed_index = None

    Frame1.update()
    alto1 = Frame1.winfo_height()
    ancho1 = Frame1.winfo_width()
    formulario(alto1,ancho1)
    #stock()
    email()
    alta()
    datos = Conecta()
    #datos.insertaTipo('bebidas')
    #datos.insertaProducto('BEBIDAS',17283,'CocaCola',1,50)
    #datos.insertaProducto('BEBIDAS',17284,'VollDamm',1,35)
#root.geometry('500x1000+0+0')
root.attributes('-zoomed', True)
app = GUI(root)
root.mainloop()
    
asked by Universal_learner 29.04.2018 в 11:28
source

1 answer

0

I solved it by reducing the size of the frame, the key remaining one eighth of the height of the screen at the time of doing the place of Frame2 that contains the terminal.

Frame2.place(x=0,y=3*self.alto/4,width=3*self.ancho/4,height=(self.alto/4)-self.alto/8)
wid = Frame2.winfo_id()
os.system('xterm -into %d -geometry 300x10 -sb &' % wid)
    
answered by 29.04.2018 в 12:15