问题标签 [tkinter-canvas]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Tkinter:如何让画布窗口中的框架扩展到画布的大小?
所以我一直在 tkinter 中使用画布小部件来创建一个充满标签的框架,该框架有一个滚动条。一切都很好,除了框架只扩展到放置在其中的标签的大小 - 我希望框架扩展到父画布的大小。
如果我对画布中的框架使用 pack(expand = True) (我已在下面的代码中注释掉),则可以轻松完成此操作,但随后滚动条不起作用。
这是适当的代码:
我还提供了带有彩色框架的图像,因此您可以看到我在做什么。粉色区域是需要通过mailbox_frame填充的画布(可以看到右边的滚动条):
python - Python:如何在遍历列表时显示项目(Tkinter)
我正在编写一个快速阅读器程序,其中我获取一个带有定义列表的 .txt 并显示关键字,同时在下面逐字打印定义,模拟 Spritz 快速阅读器。这一切都在 Tkinter 窗口中完成。
我创建了一个 list keyword=i[0] ,其中包含 .txt 中每一行 (i) 的关键字,以及一个 list definition=i[1:] 包含定义,每个单词都有自己的标记。
例如,如果 .txt 的 line1 是“错误:程序中的错误”,我需要输出看起来像这样。
然后
依此类推,直到定义结束。然后,将“bug”替换为下一个要定义的词。
所以......我如何在定义的每个单词中保留“错误”?这是我所拥有的一部分。它目前还相互打印单词,因此我需要删除每个单词,然后再将其替换为另一个单词。这是我第一次使用 Tkinter,所以请多多包涵。
python - Destroying Toplevel window doesn't let the application come out of the main loop
I am new to Tkinter. I am trying to destroy the Toplevel window and it gets destroyed perfectly but nothing's running after that. The cursor just keeps on blinking in python shell as it happens while running an infinite loop.
Here's my code :
Before this I have already a Tk()
window open so I am using a Toplevel()
window.
On running I am getting a window which opens and shows the message. I click on ok and everything just halts. 'lol' does not print in the shell and function never ends (as return statement is not reached), hence 'Help' is also not printed
Any Idea why is this happening ??
Thanks,
python - 如何在 Tkinter 画布中为子字符串着色
我正在编写一个程序,该程序涉及create_text()
在循环中在 Tkinter 画布上的框中显示一些文本。显示每个单词,然后替换为下一个单词。有点像闪存卡。
我需要为每个单词的一个字母着色,靠近单词的中间,这样当用户阅读单词时,他们的眼睛就会集中在单词的中间。所以if len(i)=1, color i[0], if len(i)>= 2 and <= 5, color i[1]
,等等。它需要使用 Canvas 完成,并使用
结果应该像这样打印
(但显然“m”会被涂成红色,而不是大写)
python - 为什么在按下按钮之前调用该函数?
pointSize_max
我的程序使用和变量绘制分形pointSize
,这些变量由用户在 Tkinter 中输入。问题是分形是在按下按钮之前绘制的(只要程序运行),并且在按下按钮时程序不会绘制分形。
python-3.x - _tkinter.TclError:unknown option "23" 代码适用于少数对象,但不适用于很多对象
首先,我对使用 Tkinter 非常陌生,
我遇到的问题是,如果我只有一种对象类型,我的代码就可以工作。如果它是该标签类型中唯一的一种,它将正确交互。因此,如果每次执行时我都有一艘“船”和 100 个“炮弹”,它就会正确执行。
该代码检测两个对象之间是否存在碰撞,然后将当前选定项目的颜色更改为随机颜色。因此,只要当前只有一种标签类型,它就可以正常工作。因此,如果我单击并将“船”拖到“外壳”中,它将切换它的颜色。然后,如果我取 100 个外壳中的 1 个并做同样的事情,我会收到此错误。
我不明白为什么当只有一个给定类型的对象并且与无限数量的其他对象交互时它可以正常工作,但是当有多个标签类型时它会失败。
它正确选择了所选对象的 ID 号,所以我现在迷路了,感谢任何帮助。
以下是我收到的错误和我正在使用的代码。它只是执行所需任务所需的重要部分。碰撞代码与代码中的相同。
python - Add a graphic interface (Tkinter) to this programm in python?
I just wrote a program in Python. The program does what follows:
There is a class called original. It has 2 methods (a part of init). The first method is code. What "code" does is receive a string and encode it changing every character from the received string for another character of the ASCII table. This ASCII character depends of the function generacion_clave. The function generacion_clave generates randomly a number between 1 and k (k is an input parameter for this function).
For example the character "e" is in the place 101 on the ASCII table. So if the generated number is 8, the character e is changed for the character in the ASCII table which has the position 109 (101 + 8)
The method decode receives the encoded string and the clave, and it returns the decoded string.
What I would like to do is add to the program a graphic interface that contains:
An entry box for the original String, A Canvas (or a output box?) where the encoded and decoded string will we shown, a button to encode and a button to decode.
I am quite new in Python, I have read some tutorials about Tkinter but I don´t find it easy at all. So I would appreciate any help :)
Thanks a lot in advance! Pablo
tkinter - 通过鼠标单击在 tkinter 中的单选按钮之间绘制线条
编程新手和 tkinter 新手......我想要两列单选按钮;如果用户单击第 0 列中的按钮 1,然后单击第 2 列中的按钮 3,则在单选按钮之间画一条线。我看到画线的唯一方法是在画布上。从一侧到另一侧的最佳方式是什么?我是在画布上制作虚拟按钮还是可以将单选按钮放置在画布上并且选择/取消选择鼠标单击控制行的开始/结束?
python - 为什么只有将鼠标悬停在 Tkinter 滚动条上时它才会激活?
我正在使用 Tkinter 创建一个 GUI,只有当我将鼠标放在它上面并滚动时,滚动条才处于活动状态。当鼠标不在滚动条上和窗口中间时,有没有办法可以使用鼠标上的滚轮滚动?