helly evry bodie听到stackoverflow了!今天我的第二个问题是我想让代码打印出运行命令的键盘,该按钮运行名为function_to_run_game 4 evur的命令。所以我做了通过'string_for_for_loop'的forloop。如果我想让make loop进行四个操作,是否应该在'string_for_for_loop'中添加更多字符。
import socket
from tkinter import *
try:
def the_function_that_makes_a_new_label_for_the_main_window():
b.configure(text='pleese work | beg')
the_main_window_that_will_show_up_when_the_code_is_run=Tk()
the_main_label_for_the_first_window_that_prints_hellow_world=Label(the_main_window_that_will_show_up_when_the_code_is_run, text='hellow world',font=('comicsans', 70))
b=Label(the_main_window_that_will_show_up_when_the_code_is_run, text='hellow world', font=('comicsans', 70))
the_main_button_for_the_first_window=Button(the_main_window_that_will_show_up_when_the_code_is_run, text='click here', command=the_function_that_makes_a_new_label_for_the_main_window)
try:
def function_to_start_game():
string_for_for_loop ='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
for the_number_of_times_that_the_for_loop_will_run__ in string_for_for_loop:
new_tkinter_lable_for_my_code = Label(the_main_window_that_will_show_up_when_the_code_is_run, text='GAme playing')
new_tkinter_lable_for_my_code.pack()
start_game_button = Button(text='press this button |f u want to start the gmae ! ! ! !', command=function_to_start_game)
except:
print(' AN ERROR HAS OCCURED')
the_main_label_for_the_first_window_that_prints_hellow_world.pack()
b.pack()
the_main_window_that_will_show_up_when_the_code_is_run.configure(bg='pink')
the_main_button_for_the_first_window.pack()
short_precise_vereiable_name=Label(the_main_window_that_will_show_up_when_the_code_is_run, text='do u want to start game ! ?')
start_game_button.pack()
short_precise_vereiable_name.pack()
the_main_window_that_will_show_up_when_the_code_is_run.mainloop()
except:
print('AN ERRORR HAS OCCUR')
我让befor bean帮助了stackoverflow,所以如果有人再次帮助,那么就喜欢木头!谢谢!
在True而不是for循环时使用
while True:
new_tkinter_lable_for_my_code = Label(the_main_window_that_will_show_up_when_the_code_is_run, text='GAme playing')
new_tkinter_lable_for_my_code.pack()
不要使用四个圈,要使用其他