468,140 Members | 1,641 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

Re: Windows / Tkinter - problem with grid - not able to placewidgets atdesired places

Il Mon, 18 Aug 2008 12:15:10 +0100, dudeja.rajat ha scritto:

>>Hi,

I'm learning Python and Tkinter. I've started programming in Eclipse
with PyDev. I'm intending to create a GUI. I'm not able to understand
the Grid manager perhaps because there is quite a less documentation
available for it on the net.

My desired GUI is attached in the mail. Although I've tried writing a
class module for this GUI but I'm not able to set all things right in
the GUI. The Biggest problem seems to be with the Grid Manager in terms
how it divides a window in Rows / columns. etc. I'm not able to place
none of the widgets correctly in the GUI.

For your convenience, I'm attaching this code also as myModule1.py .
Please some one review it and help create me this GUI.
Uhm, I don't think you should use the grid manager to obtain a window
like that. The grid manager is for equally distributing widgets both
horizontally and vertically.
And I'm not sure that you can realize that window look with Tkinter.
You could get close by horizontally packing each widget row in a frame
and then vertically packing the frames in the window. But the look will be
quite different than your target. If you are not satisfied with that I
suggest you move to other toolkits which have more complex geometry
managers than .pack and .grid.

Ciao
-----
FB
Sep 14 '08 #1
1 1482
On Sun, Sep 14, 2008 at 7:32 AM, Francesco Bochicchio
<bo*****@virgilio.itwrote:
Il Mon, 18 Aug 2008 12:15:10 +0100, dudeja.rajat ha scritto:

>>>Hi,

I'm learning Python and Tkinter. I've started programming in Eclipse
with PyDev. I'm intending to create a GUI. I'm not able to understand
the Grid manager perhaps because there is quite a less documentation
available for it on the net.

My desired GUI is attached in the mail. Although I've tried writing a
class module for this GUI but I'm not able to set all things right in
the GUI. The Biggest problem seems to be with the Grid Manager in terms
how it divides a window in Rows / columns. etc. I'm not able to place
none of the widgets correctly in the GUI.

For your convenience, I'm attaching this code also as myModule1.py .
Please some one review it and help create me this GUI.

Uhm, I don't think you should use the grid manager to obtain a window
like that. The grid manager is for equally distributing widgets both
horizontally and vertically.
And I'm not sure that you can realize that window look with Tkinter.
Yes you can.
You could get close by horizontally packing each widget row in a frame
and then vertically packing the frames in the window. But the look will be
quite different than your target. If you are not satisfied with that I
suggest you move to other toolkits which have more complex geometry
managers than .pack and .grid.
Uhm.. I'm sure it is more a question of learning how to use them properly.
The following code should be very close to the original request,
depending on the tk version some minor modifications may be needed.

from Tkinter import Tk, Button, Checkbutton, Label, Entry, Frame

class App:
def __init__(self, master):
column0_padx = 24
row_pady = 36

#Label 1
lbl_testcase_exec = Label(master, text="Test case execution",
wraplength=100, anchor='w', justify='left')
lbl_results_cmp = Label(master, text="Results comparison",
wraplength=100, justify='left')
lbl_tolerance = Label(master, text="Tolerance (5%)", wraplength=100)
testcase_exec = Checkbutton(master)
results_cmp = Checkbutton(master)
tolerance = Entry(master, width=4)
lbl_analysis = Label(master, text="Analysis Library")
analysis_lib = Entry(master, width=30)

lbl_testcase_exec.grid(row=0, column=2, padx=20, pady=12, sticky='w')
lbl_results_cmp.grid(row=0, column=3, pady=12, sticky='w')
lbl_tolerance.grid(row=0, column=4, padx=20, pady=12, sticky='wn')
lbl_analysis.grid(row=1, column=0, sticky='w', padx=column0_padx)
analysis_lib.grid(row=1, column=1, sticky='w')
testcase_exec.grid(row=1, column=2, padx=20, sticky='w')
results_cmp.grid(row=1, column=3, sticky='w')
tolerance.grid(row=1, column=4, padx=20, sticky='w')

#Label 2
lbl_ref_analysis = Label(
master, text="Reference Analysis Libary Version",
wraplength=150, justify='left', pady=row_pady)
ref_analysis_lib = Entry(master, width=30)
lbl_ref_analysis.grid(row=2, column=0, sticky='w', padx=column0_padx)
ref_analysis_lib.grid(row=2, column=1, sticky='w')

# version
lbl_version = Label(master, text="Version under Test")
version = Label(master, text="vA.B.C.D")
lbl_version.grid(row=3, column=0, sticky='w', padx=column0_padx)
version.grid(row=3, column=1, sticky='w')

# test all
lbl_testall = Label(master, text="Test All")
testall = Checkbutton(master)
lbl_testall.grid(row=4, column=0, pady=row_pady, padx=column0_padx,
sticky='w')
testall.grid(row=4, column=1, sticky='w')

# buttons
bottom_frame = Frame(master)
bottom_frame.grid(row=5, column=1, columnspan=3, sticky='w')

btn_start = Button(bottom_frame, text = "Go", width=7)
btn_start.pack(side='left')
btn_commit = Button(bottom_frame, text="Commit", width=7)
btn_commit.pack(side='left', padx=80)
btn_exit = Button(bottom_frame, text="Exit", width=7)
btn_exit.pack(side='left')
root = Tk()
root.title("Test Automation")
root.minsize(800, 400)
app = App(root)
root.mainloop()
>
Ciao
-----
FB
--
http://mail.python.org/mailman/listinfo/python-list


--
-- Guilherme H. Polo Goncalves
Sep 14 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Bruce Davis | last post: by
3 posts views Thread by Matt Hammond | last post: by
3 posts views Thread by dwelch91 | last post: by
4 posts views Thread by Simon Forman | last post: by
2 posts views Thread by skanemupp | last post: by
reply views Thread by Guilherme Polo | last post: by
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.