message entry box at center

Discussion in 'Python' started by asit, Feb 28, 2008.

  1. asit

    asit Guest

    from Tkinter import *


    def callback():
    print e.get()


    master=Tk()
    e=Entry(master)
    e.pack(anchor=CENTER)
    e.focus_set()


    b=Button(master,text="get",width=10,command=callback)
    b.pack(anchor=CENTER)

    master.mainloop()


    i want to show the entry button at the center of the window. How is it
    possible ??
     
    asit, Feb 28, 2008
    #1
    1. Advertising

  2. asit

    Peter Otten Guest

    asit wrote:

    > i want to show the entry button at the center of the window. How is it
    > possible ??


    > from Tkinter import *
    >
    >
    > def callback():
    > print e.get()
    >
    >
    > master=Tk()
    > e=Entry(master)


    e.pack(expand=True)

    > e.focus_set()
    >
    >
    > b=Button(master,text="get",width=10,command=callback)
    > b.pack(anchor=CENTER)
    >
    > master.mainloop()


    For more complex layouts have a look at the grid geometry manager.

    Peter
     
    Peter Otten, Feb 28, 2008
    #2
    1. Advertising

  3. asit

    asit Guest

    On Feb 28, 7:53 pm, Peter Otten <> wrote:
    > asit wrote:
    > > i want to show the entry button at the center of the window. How is it
    > > possible ??
    > > from Tkinter import *

    >
    > > def callback():
    > > print e.get()

    >
    > > master=Tk()
    > > e=Entry(master)

    >
    > e.pack(expand=True)
    >
    > > e.focus_set()

    >
    > > b=Button(master,text="get",width=10,command=callback)
    > > b.pack(anchor=CENTER)

    >
    > > master.mainloop()

    >
    > For more complex layouts have a look at the grid geometry manager.
    >
    > Peter


    but here there is another problem. there is a huge gap between get
    button and message entry button when maximized.

    pl z help. !!
     
    asit, Feb 28, 2008
    #3
  4. asit

    Peter Otten Guest

    asit wrote:

    > On Feb 28, 7:53 pm, Peter Otten <> wrote:
    >> asit wrote:
    >> > i want to show the entry button at the center of the window. How is it
    >> > possible ??
    >> > from Tkinter import *

    >>
    >> > def callback():
    >> > print e.get()

    >>
    >> > master=Tk()
    >> > e=Entry(master)

    >>
    >> e.pack(expand=True)
    >>
    >> > e.focus_set()

    >>
    >> > b=Button(master,text="get",width=10,command=callback)
    >> > b.pack(anchor=CENTER)

    >>
    >> > master.mainloop()

    >>
    >> For more complex layouts have a look at the grid geometry manager.


    > but here there is another problem. there is a huge gap between get
    > button and message entry button when maximized.


    Here are two more variants:

    # large Entry widget
    from Tkinter import *

    master = Tk()
    e = Entry(master)
    e.pack(expand=1, fill=BOTH)
    b = Button(master, text="get")
    b.pack()

    master.mainloop()

    # nested Frame widget
    from Tkinter import *

    master = Tk()
    panel = Frame(master)
    panel.pack(expand=1)
    e = Entry(panel)
    e.pack()
    b = Button(panel, text="get")
    b.pack()

    master.mainloop()

    Peter
     
    Peter Otten, Feb 28, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Quijote

    Center Box with CSS

    Quijote, May 8, 2004, in forum: HTML
    Replies:
    2
    Views:
    731
    Gnarlodious
    May 8, 2004
  2. Gnarlodious
    Replies:
    4
    Views:
    17,712
    elizas
    May 5, 2010
  3. AtomicBob
    Replies:
    14
    Views:
    966
    Toby Inkster
    May 2, 2006
  4. Mike Owen

    Allowing entry of a Carriage Return during data entry

    Mike Owen, Jul 27, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    797
    Alessandro Zifiglio
    Jul 27, 2006
  5. Noozer
    Replies:
    2
    Views:
    303
    Dr John Stockton
    Aug 1, 2005
Loading...

Share This Page