packer and placer together.py :  » 3.1.2-Python » Demo » Demo » tkinter » matt » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » 3.1.2 Python » Demo 
Demo » Demo » tkinter » matt » packer-and-placer-together.py
from tkinter import *

# This is a program that tests the placer geom manager in conjunction with
# the packer. The background (green) is packed, while the widget inside is placed


def do_motion(event):
    app.button.place(x=event.x, y=event.y)

def dothis():
    print('calling me!')

def createWidgets(top):
    # make a frame. Note that the widget is 200 x 200
    # and the window containing is 400x400. We do this
    # simply to show that this is possible. The rest of the
    # area is inaccesssible.
    f = Frame(top, width=200, height=200, background='green')

    # note that we use a different manager here.
    # This way, the top level frame widget resizes when the
    # application window does.
    f.pack(fill=BOTH, expand=1)

    # now make a button
    f.button = Button(f, foreground='red', text='amazing', command=dothis)

    # and place it so that the nw corner is
    # 1/2 way along the top X edge of its' parent
    f.button.place(relx=0.5, rely=0.0, anchor=NW)

    # allow the user to move the button SUIT-style.
    f.bind('<Control-Shift-Motion>', do_motion)

    return f

root = Tk()
app = createWidgets(root)
root.geometry("400x400")
root.maxsize(1000, 1000)
root.mainloop()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.