简体   繁体   English

在Python中使用Tkinter。 如何一次将一个列表变量调用到画布中

[英]With Tkinter in Python. How do I call a list variable into a canvas one at a time

With Tkinter in Python. 在Python中使用Tkinter。 How do I call a list variable into a canvas one at a time when a button's pressed (in this case. next ). 如何在按下按钮时一次将一个列表变量调用到画布中(在本例中为next )。 Here's what I tried. 这是我尝试过的。 I'm a newby in programming. 我是编程的新手。

def _next_(self):
    def y(self):
        a='hey'
        b='you'
        e=[a,b]
        for i in (e):
            while True:
                 print i
                 break
    x=y
    self.ques = self.canvas1.create_text(380,40, text= self.x())

Is this what you are looking for: 这是你想要的:

from tkinter import *
root = Tk()

textList = ["Hey", "you", "whatsup"]

mycanvas = Canvas(root)
mycanvas.pack()

textobj = mycanvas.create_text(100, 50)

def f():
    mycanvas.itemconfig(textobj, text=textList)

mybutton = Button(root, text="Click", command=f)
mybutton.pack()

?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想使用python中的列表理解一一打印列表中的项目。 怎么能这样做? - I want print items in list one by one using list comprehension in python. How can do that? 如何设置 Python tkinter 画布元素的 z 索引? - How do I set the z index of an Python tkinter canvas element? Python。 我如何制作一个更大列表的小部分列表? - Python. How do I make a list of small portions of a bigger list? python 中 copy() 的时序复杂度。 如何添加经过的时间? - Timing complexity for copy() in python. How do I add the elapsed time? Python 中的负进程执行时间。 我如何正确衡量这个? - Negative process execution time in Python. How do I correctly measure this? Python。无法将列表项放入单个变量中。 当我这样做时,变量包含整个列表项 - Python. Cannot place list items into individual variables. When I do, the variable contains the whole list items 我如何在 Tkinter 画布中显示 - how do I display in Tkinter canvas 如何更新Tkinter Canvas上的图像? - How do I update images on a Tkinter Canvas? 如何将 object 置于 Tkinter 中的 canvas 上? - How do I center an object on the canvas in Tkinter? 如何将函数绑定到可变大小列表中的 tkinter 小部件? - How do I bind functions to tkinter widgets that are in a list of variable size?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM