1 Replies - 472 Views - Last Post: 05 July 2013 - 05:32 PM Rate Topic: -----

#1 njjmfm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 04-February 13

Which window to choose?

Posted 30 June 2013 - 08:47 PM

I'm making an astronomy observation record application through Python 2.7.5 (using Tkinter). And I want it to have multiple screens. I'm thinking logic like this:

if object is clicked:
   #Go to this screen

 elif this_object is clicked:
   #Go to that screen

And stuff like that. My question is, how would I create the different screens and then switch them? I am using the Notebook feature now in Tkinter , but is there a different way to do this? In essence, I want a main screen that can transform into different screens. I need, not code, but a direction or website or another resource so that I can figure this out myself.

I just passed my programming course in Python, and we didn't do this type of multiwindow programming. So please be patient, I can ask many questions :)

Is This A Good Question/Topic? 0
  • +

Replies To: Which window to choose?

#2 Dietrich  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-March 13

Re: Which window to choose?

Posted 05 July 2013 - 05:32 PM

You can use a number of toplevel windows. Here is an example ...
''' tk_Toplevel2.py
a toplevel child window has options like color, height, and width
size and position it with geometry()
lift and lower it with respect to other windows
you can exit a toplevel window alone
or it will exit as the main/root window exits
tested with Python27 and Python33
'''

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def lift_win1():
    win1.lift(aboveThis=root)

def lower_win1():
    win1.lower(belowThis=root)

root = tk.Tk()

root.title('root win')
root.geometry("200x100+30+30")
root.configure(bg='yellow')

# create a child/top window
win1 = tk.Toplevel(bg='red')
win1.title('top/child window win1')
win1.geometry("300x150+120+120")

btn_lift = tk.Button(win1, text="Lift win1", command=lift_win1)
btn_lift.pack(padx=30, pady=5)
btn_lower = tk.Button(win1, text="Lower win1", command=lower_win1)
btn_lower.pack(pady=5)

win1.mainloop()



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1