User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 397,818 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,611 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 1049 | Replies: 6
Reply
Join Date: Feb 2007
Posts: 55
Reputation: fredzik is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
fredzik fredzik is offline Offline
Junior Poster in Training

Positioning in GUI

  #1  
Apr 28th, 2007
Hi,

I'm puzzled by how one positions in Tkinter. Take a look at the following code:
  1. print "...................................Hello, world!"

This works fine in the Main Idle but when it comes to Tkinter I'm confused . The game I'm working on has about 30 "clues" dotted all about the screen. About four fifths of the "clues" are situated in one place and stay there. The other four or five "clues" change position on the right side of the screen as one scrolls down frame after frame with each frame divided by a line. The problem I'm having is that the Tkinter documentation is not to clear on how to position these 30
"clues" . Do I use "grid" or "place" or "pack" or do I use so many pixels to the left or right .
I'm still sticking by Tkinter come hell or high water I just hope someone can post me some code on how to achieve this type or a similar type of positioning...

One more thing, is it just my eyes or are the new smilies blurry. If they really are blurry then they should call them not smilies but blurries!!!

Thanks for helping,

fredzik.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,414
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 9
Solved Threads: 173
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
Kickbutt Moderator

Re: Positioning in GUI

  #2  
Apr 28th, 2007
Your program may be a good candidate for place(), see the Python/Tkinter code snippet at:
http://www.daniweb.com/code/snippet693.html
May 'the Google' be with you!
Reply With Quote  
Join Date: Jul 2006
Posts: 562
Reputation: jrcagle is on a distinguished road 
Rep Power: 4
Solved Threads: 72
jrcagle jrcagle is offline Offline
Posting Pro

Re: Positioning in GUI

  #3  
Apr 28th, 2007
Of the three layout managers, I find grid() to be the most user-friendly.

Jeff

(But Vega's advice is always sound, so go with place ... )
Last edited by jrcagle : Apr 28th, 2007 at 3:14 pm.
Reply With Quote  
Join Date: Feb 2007
Posts: 55
Reputation: fredzik is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
fredzik fredzik is offline Offline
Junior Poster in Training

Re: Positioning in GUI

  #4  
Apr 28th, 2007
Hi again,

Excellent!!! Excellent!!! And Excellent!!! And can I say another word of gratitude to Vegaseat...um, Excellent!!! (ah, can't think of another word)!!! Believe it or not THIS was the very reason that I was so VERY reluctant to take on Tkinter as the GUI of choice for my game as I'd been googling about for around two months for the answers to what I needed. What I needed was the "absolute co-ordinates" with "Label" and "place" and pixel placements. Being an absolute beginner at programming (I only started eight months ago) I wasn't too sure of the right terminology I should use to describe my needs.

Thanks also to Jeff for your input as well. I usually google for at least ten hours per each problem in search of answers before coming here. But I find my answers here in super quick time but I don't want to take up too much of anyone's time as there are others in just as desperate a need of solutions as I am.

To Mr. Vegaseat, please SIR, allow me to buy you lunch one time (not kidding this time!) as this has saved me a tremendous amount of time and effort, the only problem is that I'm in Australia and it might take some time to get over there and I might be late for lunch!

Thanks,

fredzik.
Reply With Quote  
Join Date: Sep 2005
Posts: 132
Reputation: mawe is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 33
mawe mawe is offline Offline
Junior Poster

Re: Positioning in GUI

  #5  
Apr 29th, 2007
place seems to be a nice and easy way for positioning, but it's not often used. e.g. think of what happens if you want to make some little changes to the GUI. You have to change all coordinates of (mostly) _everything_ you positioned

BTW, you can use a combination of layout managers. I often do the following: separate the main window into frames and position them with pack. Then, fill these frames with widgets using pack or grid, depending on the complexity of the layout.
Reply With Quote  
Join Date: Feb 2007
Posts: 55
Reputation: fredzik is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
fredzik fredzik is offline Offline
Junior Poster in Training

Re: Positioning in GUI

  #6  
Apr 29th, 2007
Hi Mawe,

Thanks for your suggestion, but I think it best if I don't refer to this GUI as a GUI anymore, it's more like a large list box that one can scroll up and down in. This game I'm working on has 50 turns which means that it has 50 frames with various "clues" given in them along the way. To solve a number problem on frame 32 might mean scrolling back to say frame, 12 because there are certain "clues" given at 32 which make more sense at frame 12. One has to play detective to solve the ten puzzling numbers.

The frame around the large list box may have a marble-like effect to give it a nice GUI - like look, but in reality it will be nothing more than a glorified list box similar to the Main Idle but of course with a different background and maybe coloured "clues". It may sound like a complicated game but in reality it's really fairly easy to play and takes about ten to fifteen minutes to play each game. Remind me Mawe to send you a free game later when it's finished.

But I agree with Mawe in this regard, as each new frame comes up some of the positions of the "clues" (remembering that there's 0 to 7 clues per frame) which will tend to fatten or squeeze the frame just as it does in the Main Idle when I play it there. Is there some way to automatically update the window so it won't throw out the other functions of the window, that is, if I'm using labels or whatever? Or will this glorified list box be more suited to something other than labels?

To give you a clear idea of what this list box (if indeed it should be called a list box) should look like please refer to my earlier post which has that "game" with 5 entry numbers and simply multiply by ten and this'll give you the length of the game. BTW that "game" is completely different to the one I'm working on now and only the list box? and postioning of numbers etc is similar.

Thanks,

fredzik.
Reply With Quote  
Join Date: Feb 2007
Posts: 55
Reputation: fredzik is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
fredzik fredzik is offline Offline
Junior Poster in Training

Re: Positioning in GUI

  #7  
Apr 29th, 2007
Hi again,

When one thinks of a game it is usually in a GUI type of window stuck in one place and things have to be done in it or to it (such as chess etc) it is not usually moveable. Conversely a game can be like a Pygame where things move about the screen and one shoots at them or whatever.

Neither applies to my game. I have not seen a game where one scrolls down a UI to play a game. I could be wrong, and am by no means an expert in this matter, this is just my humble opinion on what I've seen on the games market. If I'm wrong please email me.

My game should have the following or it won't work:

No.1 It has to be scrollable.
No.2 It has to come up on screen as large as Python's Main Idle.
No.3 It has to have pretty coloured words and numbers so it's nice to look at .

I think the confusion might lie in the fact that in most people's minds they have preconcieved ideas of what a game is and should conform to, ideas already known, tried, and trusted. Maybe I'm stepping out into the unknown with a scrollable game like this but I find it fun to play and I don't mind the scrolling part as long as it gets to the answers I need. As each frame is numbered one can make a mental note of when this or that particular "clue" was seen and the scrolling part is really a minor inconvenience.

Thanks,

fredzik.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Python Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 6:40 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC