472,353 Members | 1,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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 1608
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu...
0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition...
2
by: Marc | last post by:
Hi all, I was using Tkinter.IntVar() to store values from a large list of parts that I pulled from a list. This is the code to initialize the...
3
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets...
3
by: dwelch91 | last post by:
I'm trying unsuccessfully to do something in Tk that I though would be easy. After Googling this all day, I think I need some help. I am admittedly...
4
by: peter | last post by:
I've come across a weird difference between the behaviour of the Tkinter checkbox in Windows and Linux. The issue became apparent in some code I...
4
by: Simon Forman | last post by:
Hi all, I realize this is more of a Tk question than a python one, but since I'm using python and don't know Tcl/Tk I figured I'd ask here first...
2
by: skanemupp | last post by:
so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.