473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Help with display placement

I am new to Python and am attempting to write a routine that will display a
five game selection for a power ball drawing. I think I have the random
drawing set to work ok, but I want to have the dialog box move in the center
of my screen. I can't seem to get the code correct to do this. Any help
would be appreciated.
Thanks,
S
This is the routine I have.
###########################

import random
from Tkinter import *
root = Tk()
frame = Label(root, width=50, height=2, background = 'white', text =
'PowerBall Numbers')
frame.pack()

def GetNumbers():

numbers = random.sample(xrange(53), 5)
numbers.sort()
numbers[0] = numbers[0] + 1

numbers[1] = numbers[1] + 1

numbers[2] = numbers[2] + 1

numbers[3] = numbers[3] + 1

numbers[4] = numbers[4] + 1
powerball = random.sample(xrange(42), 1)
powerball[0] = powerball[0] + 1

return numbers, powerball

y = 0
sp1 = sp2 = sp3 = sp4 = sp5 =' '
w = 0
for x in range(5):
y = y + 1
MyNumbers= GetNumbers()
x = MyNumbers

num1= str(x[0][0])

num2 = str(x[0][1])

num3 = str(x[0][2])

num4 = str(x[0][3])

num5 = str(x[0][4])

pbnum = str(MyNumbers[1][0])

root.title =('Powerball Numbers')
w = Label(root, width=50, height=2, background= 'white' , text='Game
'+str(y)+': Numbers: '+num1.zfill(2)+' '+num2.zfill(2)+' '+num3.zfill(2)+'
'+num4.zfill(2)+' '+num5.zfill(2)+' '+'PowerBall: '+pbnum.zfill(2))
w.pack()

root.mainloop()

#####################
Apr 4 '06 #1
4 1390
This code come up, fairly centered in my screen. What do you mean by
move?

Apr 4 '06 #2
I want to be able to control where the dialog is displayed . X,Y location
from the upper left corner of the screen.
S
<ak*********@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
This code come up, fairly centered in my screen. What do you mean by
move?

Apr 4 '06 #3
Ok so I'm not to bright sometimes

Well if you want this kinda control I suggest you go ahead and subclass
toplevel, but the simple answer before running

root.mainloop()
make a call to

root.geometry(geometryString)

geoometrystring is in the format WxH+X+Y - you may hve to do some
screen calcs first to get the right numbers. ie "50x100+50+50" create
a 50pix by 100 pix window offset 50 from the top and 50 from the left.

To my mind, better to subclass toplevel and set everything in there -
but's mostly stylistic preference for something this simple.

And while I'm making suggestions ;) Try wxPython. I used tKinter for
about 3 months before tossing it in frustration when I wanted to do
somtheing "slick" , but I have a lot of fondness for some quick and
dirty UI's I did in tKinter a ways back.

Apr 4 '06 #4
Thanks, think I have it now.
S
<ak*********@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Ok so I'm not to bright sometimes

Well if you want this kinda control I suggest you go ahead and subclass
toplevel, but the simple answer before running

root.mainloop()
make a call to

root.geometry(geometryString)

geoometrystring is in the format WxH+X+Y - you may hve to do some
screen calcs first to get the right numbers. ie "50x100+50+50" create
a 50pix by 100 pix window offset 50 from the top and 50 from the left.

To my mind, better to subclass toplevel and set everything in there -
but's mostly stylistic preference for something this simple.

And while I'm making suggestions ;) Try wxPython. I used tKinter for
about 3 months before tossing it in frustration when I wanted to do
somtheing "slick" , but I have a lot of fondness for some quick and
dirty UI's I did in tKinter a ways back.

Apr 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: radha | last post by:
Hai all, My problem not just releated to sql. My problem is releated to good logic. I should not this type of questions hear. But just i am trying. If any body gave suggestions, or help i am...
23
by: Giancarlo Niccolai | last post by:
Hello all. I have peeked through the FAQ and all relevant links, and also through Stroustrup book, but I have not been able to find an answer, so I have to post here as a last resort. It...
20
by: Ioannis Vranos | last post by:
When we use the standard placement new operator provided in <new>, and not a definition of owr own, isn't a call to placement delete enough? Consider the code: #include <new>
5
by: Lagarde Sébastien | last post by:
Hello, I write code to debug new call with following macro: #define new (MemoryManager::Get().setOwner (__FILE__, __LINE__, _FUNCTION-), FALSE) ? NULL : new The setOwner allow to save the...
4
by: tonsi | last post by:
I have a css menu that works great in IE7 and other browser but when you check it in IE 6 it only shows the first dropdown. I am not that great at css but ANY help would be greatly appreciated. ...
15
by: LuB | last post by:
I am constantly creating and destroying a singular object used within a class I wrote. To save a bit of time, I am considering using 'placement new'. I guess we could also debate this decision -...
9
by: karthikbalaguru | last post by:
Hi, I find that articles stating that 'placement new' constructs an object on a pre-allocated buffer and so takes less time. Actually, we have to consider the allocation of the buffer and then...
3
by: mandy335 | last post by:
public class Calculator { private long input = 0; // current input private long result = 0; // last input/result private String lastOperator = ""; // keeps track of...
5
krungkrung
by: krungkrung | last post by:
Hi everyone! Im new to vb.net. I'm currently recoding my vb6.0 codes to vb.net(for upgrading purposes), unfortunately some of the codes dont work/execute the way it executes in vb6.0, though I never...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.