How to leave the focus on the ttk.Treeview screen, freezing the previous screens?

0

I made an application in Python 3.6 that calls another python script to mount a ttk.Treeview screen with the database information and this presented data can be manipulated (change and delete).

It turns out that I can not leave this ttk.Treeview screen with the permanent focus, since when the "alt + tab" key focus changes to the previous screen that called this script.

Can anyone help me? I tried to use transient but I'm not succeeding.

Part of the script that calls the other python script:

def consultacadastro( posi ):
    if str(nrbancoget) != "":
        a = ConsultaCadastroGeral.Inicio()

Part of the program that displays the information ttk.Treeview:

Starting the program

from tkinter import * from tkinter import Tk, Button, ttk, Frame, Toplevel, Label, Entry, StringVar from tkinter import messagebox from Manager import Manager from PgmFuncoes import PgmFuncoes

class GeneralCountryReview:     def Home ():         root = Tk ()         root.title ("Users Query - General")         CustomTree (root) .pack (expand = 1, fill="both")

class CustomTree (Frame):     def init (self, master, * args, ** kwargs):          init (self, master, * args, ** kwargs)

    # Define tamanhos mínimos e máximos da tela
    master.minsize( width = 500, height= 200)       
    master.maxsize( width = 500, height= 200)

    self.focus_force()

    # Define botão de sair da tela
    self.top = Frame(self)
    self.edit_button = Button(self.top, text="Sair", font = "bold", fg = "blue", command=master.destroy)
    self.edit_button.pack(side="top")
    self.top.pack(fill="x")

    self.tree = ttk.Treeview(self)

    # Define tamanho da coluna
    self.tree.column("#0",minwidth=0,width=0)

    # Cria barra de rolagem      
    barra = Scrollbar(self, orient='vertical', command=self.tree.yview)

    # Adiciona barra de rolagem
    self.tree.configure(yscroll=barra.set)
    barra.pack( side = RIGHT, fill=Y )

    self.tree["columns"] = ("one", "two", "tree", "four", "five")
    self.tree.column("one", width=100, anchor="se")
    self.tree.column("two", width=100, anchor="se")
    self.tree.column("tree",width=100, anchor="se")
    self.tree.column("four",width=100, anchor="se")
    self.tree.column("five",width=100, anchor="center")
    self.tree.heading("one", text="Número Banco")
    self.tree.heading("two", text="Número Agência")
    self.tree.heading("tree", text="Conta Corrente")
    self.tree.heading("four", text="Saldo Inicial (R$)")
    self.tree.heading("five", text="Data Inicial")

"

Thank you in advance.

    
asked by anonymous 24.07.2017 / 16:02

1 answer

0

Well folks, as I did not get help from the most experienced in the subject, I decided to research a lot and I ended up finding the solution to my problem. I removed the call from the other script in python and put its logic into a class in the main script where the variable of class Tk is defined: root = Tk () Window (root) root.mainloop () and I used "transient" reporting to the "root".

It seems like a simple solution now, so here's the tip: when you need to call a script from another python script, which will display a screen (Treeview or not), you'd prefer to include within a class your " logic of this script that would be called, avoiding this call and being able to manipulate the frames with "transient"; I do not know if it was clear, because I have a lot to walk in the Python language and in OOP, but I emphasize that it is only to run after the loss and to have patience to search the Internet, because there is always someone who ends up helping you in some way, even sometimes nor knowing that it is.

    
23.08.2017 / 22:30