#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    14
    Rep Power
    0

    A tkinter question about text placement


    Hi I am trying to run this code
    This displays a,b,c,d,e as a sorted item like this :
    0,1,2,3,4 in order from lowest, now what I need is the "f" number which is not sorted to list as this:
    0,1,2,3,4{ }15 and not printing the curly brackets just the space It doesn't print these {} I just put them in this post to rep... space and I don't need help with them.
    These are all random numbers however, I don't need help with this part.
    So the final out would be similar to this:
    1 20 25 32 45 ______15 note this 15 is not sorted
    excluding the underscore

    If i run this code now it displays like this :

    1 20 25 32 45
    15

    It is a lotto program and should display like this :

    1 20 25 32 45______ 15 : without underscore

    ex=[f,]
    g=[a,b,c,d,e,]
    g.sort()

    tkinter.Label (text = g,).pack()
    tkinter.Label (text =ex,).pack()

    thank you
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    14
    Rep Power
    0
    PS this is the code i am sorry it is very Sloppy code however it works for what it is
    thanks
    import sys
    import random

    a=0
    b=0
    c=0
    d=0
    e=0
    f=0
    g=0

    x=0
    z=0

    x=1
    z=59

    count=0

    a=random.randint(x,z)
    b=random.randint(x,z)
    c=random.randint(x,z)
    d=random.randint(x,z)
    e=random.randint(x,z)
    f=random.randint(x,z)



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


    while count != 6:

    if a == b:
    b=random.randint(x,z)

    elif a == c:
    c=random.randint(x,z)

    elif a == d:
    d=random.randint(x,z)

    elif a == e:
    e=random.randint(x,z)

    else:
    count = count + 1;(count - 1)

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


    if b == c:
    c=random.randint(x,z)

    elif b == d:
    d=random.randint(x,z)

    elif b == e:
    e=random.randint(x,z)


    else:
    count = count + 1

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

    if c == d:
    d=random.randint(x,z)

    elif c == e:
    e=random.randint(x,z)


    else:
    count = count + 1

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

    if d == e:
    e=random.randint(x,z)


    else:

    count = count + 1
    #
    count=0

    from tkinter import *

    app=Tk()
    app.geometry('450x300+120+120')
    app.title(" LOTTO ")

    import sys, tkinter

    tkinter.Label(text="Welcome").pack()
    tkinter.Label (text= " LOTTO ").pack()
    #
    ex=[f,]
    g=[a,b,c,d,e,]
    g.sort()

    tkinter.Label (text = g,).pack()
    tkinter.Label (text =ex,).pack()

    #####

    print (g[0],g[1],g[2],g[3],g[4],' ',f)

    tkinter.Button(text="exit", command=sys.exit).pack()











    tkinter.mainloop()

    app.mainloop()
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,851
    Rep Power
    481
    I do not understand your question. However it looks like you're trying to draw numbers without replacement. I've rewritten.
    Code:
    import sys, random, tkinter
    
    # sample items without replacement
    L = list(range(1,60))
    random.shuffle(L)
    
    g = L[:5]
    g.sort()
    f = L[5:6]
    
    #########end sample without replacement
    
    print(' '.join(str(G) for G in g),'    ',f[0])
    
    app=tkinter.Tk()
    app.geometry('450x300+120+120')
    app.title("       LOTTO       ")
    
    tkinter.Label(text="Welcome").pack()
    tkinter.Label (text= "             LOTTO              ").pack()
    
    tkinter.Label (text = g,).pack()
    tkinter.Label (text = f,).pack()
    
    tkinter.Button(text="exit", command=sys.exit).pack()
    tkinter.mainloop()
    app.mainloop()
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    14
    Rep Power
    0
    yes correct your code is much clearer however the last number should be like this 1 23 33 44 51 ____12 The last random number in this case (12 ) should be too the right

    this was my question sorry it was sloppy


    oK this seems to do it but the last random number (12) is not far enough too the right.
    also I can't get all the numbers toward the center of the panel. python3.3
    I could do it with a <place>, but then when I grab the corner of the frame to shrink it, the numbers just don't move with the frame.
    Code:
    label=tkinter.Label(text = g,).pack(padx=16,pady=30)
    label=tkinter.Label (text = f,).pack(padx=16,pady=30)
    #####
              
    
    
    tkinter.Button(text="exit", command=sys.exit).pack(side=RIGHT)

IMN logo majestic logo threadwatch logo seochat tools logo