Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100346 > unrolled thread

tkinter: Switch between two grids

Started bysms <amicale.salmson@free.fr>
First post2015-12-12 19:24 +0100
Last post2015-12-12 15:29 -0500
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  tkinter: Switch between two grids sms <amicale.salmson@free.fr> - 2015-12-12 19:24 +0100
    Re: tkinter: Switch between two grids Terry Reedy <tjreedy@udel.edu> - 2015-12-12 15:29 -0500

#100346 — tkinter: Switch between two grids

Fromsms <amicale.salmson@free.fr>
Date2015-12-12 19:24 +0100
Subjecttkinter: Switch between two grids
Message-ID<566c664e$0$3071$426a74cc@news.free.fr>
Hello all,

I'm sorry to ask this question, but I am a very beginer.

What I need:
1. Fullscreen application
2. On the home screen: Three row
3. When I click on the main screen, it switches to one row only.

Actually, I am not able to switch from Window1 to Window2, Window2 comes 
under Window1

Any help would be greatly appreciated.

Please, find my shameful code :

import sys
if sys.version_info[0] < 3:
     import Tkinter as Tk
else:
     import tkinter as Tk


def destroy(e): sys.exit()

class Window1():
     def __init__(self, master):
         self.frame=Tk.Frame(master, bg="Green", borderwidth=10)

         sticky=Tk.N+Tk.S+Tk.E+Tk.W
         self.frame.grid(sticky=sticky)

         self.frame.columnconfigure(0, weight=1)
         self.frame.rowconfigure(0, weight=1)
         self.frame.rowconfigure(1, weight=1)
         self.frame.rowconfigure(2, weight=1)

         self.v = Tk.StringVar()
         text = Tk.Label(self.frame, text="Text1")
         text.grid(column=0, row=0, sticky=sticky)

         self.h = Tk.StringVar()
         text = Tk.Label(self.frame, text="Text2")
         text.grid(column=0, row=1, sticky=sticky)

         self.d = Tk.StringVar()
         text = Tk.Label(self.frame, text="Text3")
         text.grid(column=0, row=2, sticky=sticky)


class Window2:
     def __init__(self, master):

         self.frame = Tk.Frame(master, bg="black", borderwidth=10)
         sticky=Tk.N+Tk.S+Tk.E+Tk.W
         self.frame.grid(sticky=sticky)

         self.v = Tk.StringVar()
         text = Tk.Label(self.frame, text="Prout")
         text.grid(column=0, row=0, sticky=sticky)

class VGui:
     def __init__(self):
         self.root = Tk.Tk()
         self.root.attributes("-fullscreen", True)
         Tk.Grid.rowconfigure(self.root, 0, weight=1)
         Tk.Grid.columnconfigure(self.root, 0, weight=1)
         self.Window1 = Window1(self.root)
         self.Window2 = Window2(self.root)

         self.root.bind("<Button-1>", self.Callback)

     def Start(self):
         Tk.mainloop()

     def Callback(self, event):
         self.Window2.frame.tkraise()

if __name__ == '__main__' :
     gui=VGui()
     gui.Start()

Thanks for reading.

[toc] | [next] | [standalone]


#100350

FromTerry Reedy <tjreedy@udel.edu>
Date2015-12-12 15:29 -0500
Message-ID<mailman.189.1449952183.12405.python-list@python.org>
In reply to#100346
On 12/12/2015 1:24 PM, sms wrote:

> What I need:
> 1. Fullscreen application

Not directly relevant to the below.

> 2. On the home screen: Three row
> 3. When I click on the main screen, it switches to one row only.

Create homescreen Frame(master=root) or subclasses thereof. Pack the 
homescreen.  When click, homescreen.pack_forget(), then create and and 
pack the other screen (with root as master).

-- 
Terry Jan Reedy

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web