473,625 Members | 3,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1691
On Sun, Sep 14, 2008 at 7:32 AM, Francesco Bochicchio
<bo*****@virgil io.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_ex ec = 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(mas ter)
results_cmp = Checkbutton(mas ter)
tolerance = Entry(master, width=4)
lbl_analysis = Label(master, text="Analysis Library")
analysis_lib = Entry(master, width=30)

lbl_testcase_ex ec.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.g rid(row=0, column=4, padx=20, pady=12, sticky='wn')
lbl_analysis.gr id(row=1, column=0, sticky='w', padx=column0_pa dx)
analysis_lib.gr id(row=1, column=1, sticky='w')
testcase_exec.g rid(row=1, column=2, padx=20, sticky='w')
results_cmp.gri d(row=1, column=3, sticky='w')
tolerance.grid( row=1, column=4, padx=20, sticky='w')

#Label 2
lbl_ref_analysi s = Label(
master, text="Reference Analysis Libary Version",
wraplength=150, justify='left', pady=row_pady)
ref_analysis_li b = Entry(master, width=30)
lbl_ref_analysi s.grid(row=2, column=0, sticky='w', padx=column0_pa dx)
ref_analysis_li b.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.gri d(row=3, column=0, sticky='w', padx=column0_pa dx)
version.grid(ro w=3, column=1, sticky='w')

# test all
lbl_testall = Label(master, text="Test All")
testall = Checkbutton(mas ter)
lbl_testall.gri d(row=4, column=0, pady=row_pady, padx=column0_pa dx,
sticky='w')
testall.grid(ro w=4, column=1, sticky='w')

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

btn_start = Button(bottom_f rame, text = "Go", width=7)
btn_start.pack( side='left')
btn_commit = Button(bottom_f rame, text="Commit", width=7)
btn_commit.pack (side='left', padx=80)
btn_exit = Button(bottom_f rame, text="Exit", width=7)
btn_exit.pack(s ide='left')
root = Tk()
root.title("Tes t Automation")
root.minsize(80 0, 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
5967
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 bar at the top and a grid of colored rectangles filling the remainder of the window. Mind you, this is a contrived test application to help me understand Tkinter and Python, not an actual application yet. I've trivially subclassed Tkinter.Canvas into ColorCanvas, added a bunch of ColorCanvases...
0
3060
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 when a child thread pops up a Pmw dialog window in the context of a main window. The problem does not occur on HPUX or Linux. The following simple example code illustrates the problem and the work around I've come up with; However, I'd like, very much, to get rid of the kludgy work around....
2
4701
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 instances: def initVariables(self): self.e = IntVar() for part, list in info.masterList.items():
3
2144
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 with Label widgets to the left of each one, using the grid layout. If I make and grid the Label *before* the Entry then the Entry widget doesn't seem to work - it lets me put the cursor in it, but I can't type! See example code below. Is this just me doing something really really silly, or is...
3
3601
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 very novice with Tk (I started with it yesterday), so I am sure I am overlooking something simple. The basic idea is that my application will consist of a series of modal dialogs, that are chained together in "wizard" fashion. There will be some processing in between dialogs, but for the most...
4
3042
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 wrote to display an image in a fixed size canvas widget. If a checkbox was set then the image should be shrunk as necessary to fit the canvas while if cleared it should appear full size with scrollbars if necessary. The code worked fine under Linux (where it was developed). But under Windows,...
4
4158
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 before bugging the Tcl folks. I am having a terrible time trying to get a pack() layout working. I have three frames stacked top to bottom and stretching across the master window from edge to edge.
2
3519
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 should be. how can i make the 4 column of buttons have the same distance and size between them as the other 3 columns? and how can i make the top entry end where the 2nd row entry ends(meaning the top entry will be longer)? why are the 4th row split from the others? hard to fix the problems...
0
1498
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 help. You are supposed to post some minimal code that demonstrates the problem. Anyway, this demonstrates what you are getting (independent of python version): import Tkinter
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6118
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.