如何在Zelle图形窗口中显示变量?

时间:2019-06-19 19:31:51

标签: python zelle-graphics

我有一些int变量需要显示在Python的Zelle图形窗口中。我正在尝试通过GraphWin()窗口执行此操作,但是我没有找到方法。如何获取整数并将其显示在窗口中。

1 个答案:

答案 0 :(得分:0)

通过将int参数作为text参数传递到Text对象以及您希望放置的位置,可以在Zelle图形中显示from graphics import * win = GraphWin("My Number") number = 1729 text_1 = Text(Point(100, 100), number) text_1.setFace('arial') text_1.setSize(18) text_1.setStyle('bold') text_1.setTextColor('red') text_1.draw(win) win.getMouse() # pause for click in window win.close() 。您还可以选择字体的特征:

str

您不需要先将数字转换为Textfunction (jsonData) { // obtain all the property as they are image url var urlPorperty = Object.keys(jsonData.data); // random pick an index var index = Math.floor(Math.random() * urlPorperty.length); // get the url base on the index var imageUrl = urlPorperty[index]; // assign the image to #imagetestresult background image $('#imagetestresult').css('background-image', `url(${imageUrl})`); } 对象似乎可以为您处理。

enter image description here

相关问题