intégration d' un script dans Frame ou Panedwindow
Bonjour,
j'ai deux script que j'aimerais intégrer dans la même fenêtre (root) au travers soit de "Frame" soit de "PanedWindows"
pourriez vous me "demarrer" car je n' y arrive pas .
que me conseillez vous ?
merci d' avance
voici les 3 scripts
mode Paned:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| from Tkinter import *
#from tkinter import Tk, PanedWindow, Label
root = Tk()
root.title('Hello')
paned = PanedWindow(root, handlesize=10, showhandle=True, sashrelief='sunken')
l1 = Label(paned, text='gauche', height=500, background="white")
l2 = Label(paned, text='droite', height=500, background="white")
paned.add(l1, height=600, width=500, sticky="ew")
paned.add(l2, height=600, width=500, sticky="ew")
paned.grid(sticky="ew", row=1, column=1)
root.grid_columnconfigure(1, weight=1)
root.mainloop() |
mode "Frame1"
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| from Tkinter import *
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.master.title("Grid Manager")
for r in range(6):
self.master.rowconfigure(r, weight=1)
for c in range(5):
self.master.columnconfigure(c, weight=1)
Button(master, text="Button {0}".format(c)).grid(row=6,column=c,sticky=E+W)
Frame1 = Frame(master, bg="red")
Frame1.grid(row = 0, column = 0, rowspan = 6, columnspan = 2, sticky = W+E+N+S)
#Frame2 = Frame(master, bg="blue")
#Frame2.grid(row = 3, column = 0, rowspan = 3, columnspan = 2, sticky = W+E+N+S)
Frame3 = Frame(master, bg="green")
Frame3.grid(row = 0, column = 2, rowspan = 6, columnspan = 3, sticky = W+E+N+S)
root = Tk()
app = Application(master=root)
app.mainloop() |
script à intégrer dans l' une ou l' autre des fenétres:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| from Tkinter import *
root = Tk()
def hello():
print "hello!"
# create a toplevel menu
menubar = Menu(root)
menubar.add_command(label="Hello!", command=hello)
menubar.add_command(label="Quit!", command=root.quit)
# display the menu
root.config(menu=menubar)
root.mainloop() |