[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

message entry box at center

asit

2/28/2008 1:53:00 PM

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 ??
3 Answers

Peter Otten

2/28/2008 2:54:00 PM

0

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

asit

2/28/2008 5:43:00 PM

0

On Feb 28, 7:53 pm, Peter Otten <__pete...@web.de> 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. !!

Peter Otten

2/28/2008 6:53:00 PM

0

asit wrote:

> On Feb 28, 7:53 pm, Peter Otten <__pete...@web.de> 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