R
R
Roman2018-12-22 10:54:04
Python
Roman, 2018-12-22 10:54:04

How to make and attach an interface to this code using wxPython (see below)?

One forum suggested several python extensions for creating a user interface. I installed wxPython, how to create a window - I sort of understood, but here's how to attach this code to it and add a field for entering these very numbers and display the text of these answers and "the hidden number is more / less" - I don’t understand ... please help. The code itself is shown below:

answers = ["Верно", "Правильно", "Молодец!"] #Ответы. В будущем будут изменены
import random
num = random.randint (1, 100)
while True: #Создание цикла самой игры
    print ('Введите число от 1 до 100')
    guess = input()
    i = int (guess)
    if i == num:
        print (random.choice (answers)) #Вывод случайно выбранного ответа
        break
    elif i < num:
        print ('Загаданное число больше')
    elif i > num:
        print ('Загаданное число меньше')

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question