tk

How can I make the button text change, from text to an empty name with a delay?

半腔热情 提交于 2019-12-02 15:47:01
问题 I'm using tkinter library for the GUI. Basically I'm creating 4 buttons using a for loop, each having a random number as their text. Now I got stuck when trying to implement a method which allows the button text to appear as a number and then change to nothing in a second or so (After this is done the next button would do the same process). So the method would allow each button to flash it's number and moves on to the next (Until all the buttons flashed their numbers for one time). This is

Why is my Tk button being pressed automatically?

Deadly 提交于 2019-12-02 15:33:06
问题 In the code below, clicking the button should change the black text from Hello to Goodbye. But when I run the program, it immediately says Goodbye. from Tkinter import * from tkMessageBox import * print "this is a test" class Demo(Frame): def __init__(self): self.createGUI() print "init" #self.__mainWindow = Tk() def destroy(self): print "destroy" def createGUI(self): Frame.__init__(self) self.pack(expand = YES, fill = BOTH) self.master.title("Demo") self.trackLabel = StringVar() self

update idletasks when toplevel hasn't the focus

你说的曾经没有我的故事 提交于 2019-12-02 13:29:54
问题 I've a ttk::progressbar in my toplevel (the one and only . ) which I update via the following function: proc progress {x} { global prog set prog [expr fmod(($prog +$x),100)] update idletasks } prog is the variable bound to the progressbar via the -variable option. Everything works fine if I keep the focus on my window. If I switch to another window the progressbar stops to be updated and it doesn't restart even if I switch back to my application. I'm using tcl/tk 8.6 on Windows 7 (just in

How can I make the button text change, from text to an empty name with a delay?

梦想的初衷 提交于 2019-12-02 09:40:55
I'm using tkinter library for the GUI. Basically I'm creating 4 buttons using a for loop, each having a random number as their text. Now I got stuck when trying to implement a method which allows the button text to appear as a number and then change to nothing in a second or so (After this is done the next button would do the same process). So the method would allow each button to flash it's number and moves on to the next (Until all the buttons flashed their numbers for one time). This is the code which I got so far from tkinter import * from tkinter.messagebox import showinfo from random

tkinter - Going Back and Forth Between Frames Using Buttons

五迷三道 提交于 2019-12-02 08:40:55
I need functions, preferably one function, that can go back and forth between pages when the next and back buttons are pressed. I imagine this could be done by assigning boolean variables to the back and next buttons (not sure if this can be done) to figure out if you're going foward or back down an ordered list of all the pages. The index of the currently raised frame will need to be known. The indexes could be used to figure out the next page and then it would be raised. If the current index is 0 or the last index (in this case 2) and you press back or next respectively, then you would go to

Using Lambda and tuples to send to Multiple Functions: Python, Tkinter

一世执手 提交于 2019-12-02 07:24:24
问题 column1 = [ ('H', 'Hydrogen', 'Atomic # = 1\nAtomic Weight =1.01\nState = Gas\nCategory = Alkali Metals'), ('Li', 'Lithium', 'Atomic # = 3\nAtomic Weight = 6.94\nState = Solid\nCategory = Alkali Metals'), ('Na', 'Sodium', 'Atomic # = 11\nAtomic Weight = 22.99\nState = Soild\nCategory = Alkali Metals'), ('K', 'Potassium', 'Atomic # = 19\nAtomic Weight = 39.10\nState = Solid\nCategory = Alkali Metals'), ('Rb', 'Rubidium', 'Atomic # = 37\nAtomic Weight = 85.47\nState = Solid\nCategory = Alkali

update idletasks when toplevel hasn't the focus

假装没事ソ 提交于 2019-12-02 06:54:05
I've a ttk::progressbar in my toplevel (the one and only . ) which I update via the following function: proc progress {x} { global prog set prog [expr fmod(($prog +$x),100)] update idletasks } prog is the variable bound to the progressbar via the -variable option. Everything works fine if I keep the focus on my window. If I switch to another window the progressbar stops to be updated and it doesn't restart even if I switch back to my application. I'm using tcl/tk 8.6 on Windows 7 (just in case it might be relevant). What could be the cause of this behaviour? Have I missed something on how to

Using Lambda and tuples to send to Multiple Functions: Python, Tkinter

二次信任 提交于 2019-12-02 06:02:57
column1 = [ ('H', 'Hydrogen', 'Atomic # = 1\nAtomic Weight =1.01\nState = Gas\nCategory = Alkali Metals'), ('Li', 'Lithium', 'Atomic # = 3\nAtomic Weight = 6.94\nState = Solid\nCategory = Alkali Metals'), ('Na', 'Sodium', 'Atomic # = 11\nAtomic Weight = 22.99\nState = Soild\nCategory = Alkali Metals'), ('K', 'Potassium', 'Atomic # = 19\nAtomic Weight = 39.10\nState = Solid\nCategory = Alkali Metals'), ('Rb', 'Rubidium', 'Atomic # = 37\nAtomic Weight = 85.47\nState = Solid\nCategory = Alkali Metals'), ('Cs', 'Cesium', 'Atomic # = 55\nAtomic Weight = 132.91\nState = Solid\nCategory = ALkali

Python equation parser

非 Y 不嫁゛ 提交于 2019-12-02 05:56:51
问题 I'm writing a program which needs a user input for an polynomial function of x. I'm using Tkinter and python 2.5. I have a parser method which so far takes the inputted equation and splits it into terms without dropping the signs. I want to take each term and parse it to get a tuple of the (coefficient, degree). For example, -2x^3 returns (-2,3). I can then add these to an array and manipulate them accordingly in the program. Is there a way or standard module that can do this? Here is the

Python自学--基础知识点汇总(1)

▼魔方 西西 提交于 2019-12-02 05:56:06
第一个问题,什么是 Python ?根据 Python 之父 Guido van Rossum 的话,Python 是: 一种高级程序语言,其核心设计哲学是代码可读性和语法,能够让程序员用很少的代码来表达自己的想法。 对于我来说,学习 Python 的首要原因是,Python 是一种可以优雅编程的语言。它能够简单自然地写出代码和实现我的想法。 另一个原因是我们可以将 Python 用在很多地方:数据科学、Web 开发和机器学习等都可以使用 Python 来开发。Quora、Pinterest 和 Spotify 都使用 Python 来进行他们的后端 Web 开发。那么让我们来学习一下 Python 吧。 Python 基础 变量 你可以把变量想象成一个用来存储值的单词。我们看个例子。 Python 中定义一个变量并为它赋值是很容易的。假如你想存储数字 1 到变量 “one” ,让我们试试看: one = 1 超级简单吧?你只需要把值 1 分配给变量 “one” 。 two = 2 some_number = 10000 只要你想,你可以把任意的值赋给任何其他的变量。正如你从上面看到的那样,变量 “two” 存储整型变量 2 ,变量 “some_number” 存储 10000 。 除了整型,我们还可以使用布尔值(True/Flase)、字符串、浮点型和其他数据类型。 #