GUI с python для консольной программы - PullRequest
0 голосов
/ 22 декабря 2019

Я новичок в Python GUI, поэтому прошу прощения за любые подобные нубу ошибки

Я написал следующий код:

import time
import random
from better_profanity import profanity


profanity.load_censor_words() 




swear = False

i = 0
z = i+1


names=[]
Swearer=[]
text = 1
swearState = False
names.insert(1,"People: ")
print("TechMaster Industries Service Ticket Manager Vb1.4.2")
time.sleep(3)
print("Loading... Please wait")
time.sleep(random.randint(0,5))
t = 1
while True:
    waitTime=random.randint(5,15)
    rand = random.randint(0,25)
    currentName = input ("Welcome to the TechMaster Industries TechHelp Desk. Please input your name, followed by the ENTER key to reserve a spot in the queue:")
    swearState = profanity.contains_profanity(currentName)
    if swearState == True:
      print("That's not nice. And yes, we did implement swear detection. Please Try Again")
      swear = True
    elif currentName == "remove":
        print("Hello TechMaster, I've been expecting you. I'll remove the first person on the list shortly")
        print("")
        names.pop(1)
        i = i-1
    elif currentName == "TechMaster":
        print("Hello TechMaster! How's the day going? You've got quite the queue ahead of you. I'll print out the queue now")
        print("There is this many people:",len(names),"in the queue")
        for x in names:
            print(x)
            time.sleep(0.5)
            print("")
    elif currentName == "Show me the money":
      print("Hello. Now I will print all the touble makers")
      for q in Swearer:
        print(q)
        time.sleep(0.5)
        print("")

    else :
      if swear == True:
        Swearer.insert(z+1,currentName)      
      names.insert(z+1,currentName)


      i= i+1

      print("Hello",currentName,"! Welcome to TechMaster! You are currently number",i," in line")
      time.sleep(2)


      print("The queue is currently:")
      for x in names:
          print(x)
          time.sleep(0.5)
          print("")
      if swear == True:
        print("Estimated wait time is 99999 minutes. Maybe be nicer next time and you'll get better service")
      else:
        print("Estimated Wait Time is:",i*waitTime,"minutes")
      print("")
      time.sleep(5)
      if rand == 25:
          print("You're our lucky customer!")
      z = z+1
    swear = False

После того, как меня атаковали и атаковали за помощью во время технического занятия. (Это чтобы отслеживать линию людей). К сожалению, меня не устраивает внешний вид только для консоли, и я хочу улучшить его, добавив графический интерфейс. Тем не менее, я абсолютно не знаю, с чего начать, или если мой код даже можно перенести в интерфейс типа GUI. хотите файлы кодов, их можно найти здесь )

1 Ответ

0 голосов
/ 22 декабря 2019

С точки зрения добавления графического интерфейса, стандартный подход Python заключается в использовании модуля Tkinter .

Поскольку вы совсем новичок в Python, я рекомендую попробовать следующее руководство .

...