简体   繁体   English

Python Tkinter移动

[英]Python tkinter move

I have numerous lines on a graph, datalines, horizontal divider line, day and month indicator lines, etc. I have typically, probably until now, been adding lines in this fashion: 我在图形上有许多行,数据线,水平分隔线,日和月指标线等。我大概到现在为止一直以这种方式添加线:

canvas_1.create_line(x1,y1,x2,y2)

I now have simple problem. 我现在有一个简单的问题。 I want to also add in a vertical scale to show how much above and below zero the line is...quite natural. 我还想添加一个垂直比例,以显示该线在零之上和之下多少是……很自然。 The datafile is big, roughly 12,000 data units and growing so I have everything setup using the left and right arrow keys to allow scrolling through the data. 数据文件很大,大约有12,000个数据单元,并且还在增长,因此我使用向左和向右箭头键进行所有设置,以允许滚动数据。 It works great but I haven't added in the vertical scale yet. 效果很好,但我还没有添加垂直比例。 Right now everything moves: 现在一切都在移动:

canvas_1.move(ALL,x,y)

When I add in the vertical scale I don't want the vertical scale to move. 当我添加垂直比例时,我不希望垂直比例移动。 I know by using the move(ALL) that the vertical scale will also move. 我知道通过使用move(ALL)垂直刻度也会移动。

What do I have to change in order to get the vertical scale so it won't move? 为了获得垂直比例尺以使其不会移动,我必须更改什么? Do I have to go out and 'label' all create_line statements??? 我是否必须外出并“标记”所有create_line语句???

line1 = canvas_1.create_line....

If so when I have mega reference of lines that I want to move how do I put them into the move statement. 如果是这样,当我要移动的行有大量引用时,如何将它们放入move语句中。 Do I have to put all the labels into a list or what? 我是否必须将所有标签放入列表中? I kinda really lost in the thought process on this concept. 我真的迷失了这个概念。

I fess I'm still looking into scrollbars but haven't quite had any good luck with them yet and I have a feeling I will still have the same problem to be dealt with. 我仍然在寻找滚动条,但是还没有给他们带来好运,我觉得我仍然会遇到同样的问题。

The move method takes either an id of a single object, or a tag that represents zero or more objects. move方法采用单个对象的ID或代表零个或多个对象的标签。 ALL is a built-in tag (literally, the string "all" ) that refers to everything on the canvas. ALL是一个内置标记(字面意思是字符串"all" ),它引用画布上的所有内容。

So, to use the move method without moving the scale, give everything except the scale a unique tag, and then use that tag for the move command. 因此,要在不移动刻度的情况下使用move方法,请为除刻度之外的所有内容赋予唯一的标签,然后将该标签用于move命令。

canvas_1.create_line(x1,y1,x2,y2, tags=("lines",))
...
canvas_1.move("lines")

For more information about tags, see http://effbot.org/tkinterbook/canvas.htm#item-specifiers 有关标签的更多信息,请参见http://effbot.org/tkinterbook/canvas.htm#item-specifiers

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM