Search code examples
python-3.xuser-interfacecrossword

Python, CrossWord, Gui


I am very beginner on Python and I want to create crossworld template, like this. How can I create gui exactly like this on python ? Are there any tools or libraries ? I made lots of research but ı could not find anything.

Thanks!!!

enter image description here


Solution

  • Since you're a beginner, try out PySimpleGUI.

    Here's a little program to get you started...

    import sys
    if sys.version_info[0] >= 3:
        import PySimpleGUI as sg
    else:
        import PySimpleGUI27 as sg
    import random
    
    BOX_SIZE = 25
    
    layout = [
                [sg.Text('Crossword Puzzle Using PySimpleGUI'), sg.Text('', key='_OUTPUT_')],
                [sg.Graph((800,800), (0,450), (450,0), key='_GRAPH_')],
                [sg.Button('Show'), sg.Button('Exit')]
             ]
    
    window = sg.Window('Window Title').Layout(layout).Finalize()
    
    g = window.FindElement('_GRAPH_')
    
    for row in range(16):
        for i in range(16):
            if random.randint(0,100) > 10:
                g.DrawRectangle((i*BOX_SIZE+5,row*BOX_SIZE+3), (i*BOX_SIZE+BOX_SIZE+5,row*BOX_SIZE+BOX_SIZE+3), line_color='black')
            else:
                g.DrawRectangle((i*BOX_SIZE+5,row*BOX_SIZE+3), (i*BOX_SIZE+BOX_SIZE+5,row*BOX_SIZE+BOX_SIZE+3), line_color='black', fill_color='black')
    
            g.DrawText('{}'.format(row*6+i+1),(i*BOX_SIZE+10,row*BOX_SIZE+8))
    
    while True:             # Event Loop
        event, values = window.Read()
        print(event, values)
        if event is None or event == 'Exit':
            break
    
    window.Close()
    

    enter image description here