Пример #1
0
def new_tournament(main):
    top = Toplevel(main)
    top.title("New Tournament")
    center_size(top, 320, 150)
    v = IntVar()
    Label(top, text="Select type:").grid(row=0, column=1)
    Radiobutton(top, text="Random Single Swiss", variable=v, value=1).grid(row=1, column=1)
    Radiobutton(top, text="!Rated Single Swiss!", variable=v, value=2).grid(row=2, column=1)
    Radiobutton(top, text="!Random Double Swiss!", variable=v, value=3).grid(row=3, column=1)
    Radiobutton(top, text="!Rated Double Swiss!", variable=v, value=4).grid(row=4, column=1)
    Radiobutton(top, text="!Round Robin!", variable=v, value=5).grid(row=5, column=1)
    Button(top, text="Okay", command=lambda: chosen(v, main)).grid(row=6, column=2)
    Button(top, text="Cancel", command=top.destroy).grid(row=6, column=0)
Пример #2
0
def new_random_swiss(main):
    players = []
    def add_player(event):
        if e.get() is "":
            return
        players.append(e.get())
        Lb.delete(0,END)
        for x in players:
            Lb.insert(0,x)
        e.delete(0,END)

    def remove_player():
        l=len(players)-1
        if Lb.curselection():
            for x in Lb.curselection():
                Lb.delete(x)
                players.pop(l-x)
        else:
            Lb.delete(0)
            players.pop(-1)
        Lb.delete(0,END)
        for x in players:
            Lb.insert(0,x)


    top = Toplevel(main)
    top.title("New Random Swiss")
    top.bind("<Return>",add_player)
    center_size(top,360,180)
    Label(top, text='Name:').grid(row=0,column=0)
    e = Entry(top,width=12)
    e.grid(row=0,column=1)
    e.focus_force()
    Button(top,text='Add',	command=lambda:add_player(None)			).grid(row=1,column=0)
    Button(top,text='Remove',	command=remove_player				).grid(row=1,column=1)
    Button(top,text='Cancel',	command=top.destroy				).grid(row=2,column=0)
    Button(top,text='Finish',	command=lambda:create_single_swiss(players,main)).grid(row=2,column=1)
    Sb = Scrollbar(top)
    Sb.grid(row=0,column=3,rowspan=3)
    Lb = Listbox(top,selectmode=EXTENDED,yscrollcommand=Sb.set)
    Lb.grid(row=0,rowspan=3,column=2)
    Sb.config(command=Lb.yview)
Пример #3
0
from tkinter import Tk, Menu
from new_tournament import new_tournament
from window_functions import center_size

main = Tk()

main.title("LibreSwiss")
center_size(main,640,480)

menu_bar = Menu(main)
menu_file = Menu(menu_bar,tearoff=0)
menu_edit = Menu(menu_bar,tearoff=0)

menu_bar.add_cascade(label="File", menu = menu_file)
menu_file.add_command(label="New", command = lambda:new_tournament(main))
menu_file.add_command(label="Save")
menu_file.add_command(label="Quit", command=main.destroy)

menu_bar.add_cascade(label="Edit", menu = menu_edit)
menu_edit.add_command(label="Scramble")

main.config(menu=menu_bar)
main.mainloop()