Help with display placement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Samantha

    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(x range(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(x range(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()

    ############### ######


  • akameswaran@gmail.com

    #2
    Re: Help with display placement

    This code come up, fairly centered in my screen. What do you mean by
    move?

    Comment

    • Samantha

      #3
      Re: Help with display placement

      I want to be able to control where the dialog is displayed . X,Y location
      from the upper left corner of the screen.
      S
      <akameswaran@gm ail.com> wrote in message
      news:1144163990 .760020.312370@ g10g2000cwb.goo glegroups.com.. .[color=blue]
      > This code come up, fairly centered in my screen. What do you mean by
      > move?
      >[/color]


      Comment

      • akameswaran@gmail.com

        #4
        Re: Help with display placement

        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(g eometryString)



        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.

        Comment

        • Samantha

          #5
          Re: Help with display placement

          Thanks, think I have it now.
          S
          <akameswaran@gm ail.com> wrote in message
          news:1144170334 .755700.221220@ u72g2000cwu.goo glegroups.com.. .[color=blue]
          > 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(g eometryString)
          >
          >
          >
          > 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.
          >[/color]


          Comment

          Working...