Save Galley, I'm trying to do a program with Gtk + (python3) to save some information in a DB but I also want to identify the users by login, (Quick explanation on how the program works). The user executes the program (opens a screen), type the information and press the login button, in that the window closes, and the window where the data would appear appears, until then without problems however, I want to make a "close session "and as soon as it is pressed, the login window should be displayed again, but I am not sure how to do that, because if I put" self.set_visible (True) "shortly after the second window is opened, the login window returns to appear even though the data window has been closed. ps: The program is pretty raw yet because I want to solve this part first to continue dps.
Login.py
import gi
from Index import Index
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk
class LoginWin(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Contas")
self.set_size_request(400, 600)
self.set_gravity(Gdk.Gravity.CENTER)
self.set_resizable(False)
# Grid
grid = Gtk.Grid()
self.add(grid)
self.login_txt = Gtk.Entry()
self.login_txt.set_placeholder_text("Login")
self.senha_txt = Gtk.Entry()
self.senha_txt.set_placeholder_text("Senha")
self.login_btn = Gtk.Button(label="Login")
self.login_btn.connect("clicked", self.login)
self.set_focus(self.login_btn)
grid.add(self.login_txt)
grid.attach_next_to(self.senha_txt, self.login_txt, Gtk.PositionType.BOTTOM, 1, 2)
grid.attach_next_to(self.login_btn, self.senha_txt, Gtk.PositionType.BOTTOM, 1, 2)
# sqlite
def login(self, widget):
self.hide()
oi = Index()
def main():
win = LoginWin()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == '__main__':
main()
Index.py
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
class Index(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Table")
self.set_size_request(300, 200)
self.set_visible(True)
grid = Gtk.Grid()
self.add(grid)
self.button = Gtk.Button(label="Encerrar sessao")
self.button.connect("clicked", self.close)
grid.add(self.button)
self.show_all()
self.connect("destroy", Gtk.main_quit)
def close(self, widget):
self.destroy()