1

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

4

1 回答 1

1

由于您是初学者,请尝试PySimpleGUI

这里有一个小程序可以帮助您入门...

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

在此处输入图像描述

于 2018-11-04T16:04:18.783 回答