Hi there,
I am fighting with a problem I intended to believe trivial that
I could not solve yet!
I am trying to have a button with a variable text, that
pops up another button with a variable text when pressed.
I did that with the following program in Python, but the
second button remains always void!!! is it related to
the textvariable parameters?
If any of you had a clue, please don't hesitate!
in advance, many thanks
Samuel
#----------------------- program 2 buttons.py
--------------------------
from Tkinter import *
def go(event):
root = Tk()
s1=StringVar()
s1.set("s1")
label1 = Label(root, textvariable=s1)
label1.pack(side=LEFT)
root.mainloop()
root = Tk()
s0=StringVar()
s0.set("s0")
label0 = Label(root, textvariable=s0)
label0.pack(side=LEFT)
root.bind("<Return>",go)
root.mainloop() 3 1551
Samkos wrote:
Hi there,
I am fighting with a problem I intended to believe trivial that
I could not solve yet!
I am trying to have a button with a variable text, that
pops up another button with a variable text when pressed.
I did that with the following program in Python, but the
second button remains always void!!! is it related to
the textvariable parameters?
If any of you had a clue, please don't hesitate!
in advance, many thanks
Samuel
#----------------------- program 2 buttons.py
--------------------------
from Tkinter import *
def go(event):
root = Tk()
s1=StringVar()
s1.set("s1")
label1 = Label(root, textvariable=s1)
label1.pack(side=LEFT)
root.mainloop()
root = Tk()
s0=StringVar()
s0.set("s0")
label0 = Label(root, textvariable=s0)
label0.pack(side=LEFT)
root.bind("<Return>",go)
root.mainloop()
You have instantiated Tk twice which causes these kind of problems. If
you want a window in go(), use Toplevel instead of Tk (and "mainloop" is
not needed in go()). I.e.:
def go(event):
not_root = Toplevel()
s1=StringVar()
s1.set("s1")
label1 = Label(not_root, textvariable=s1)
label1.pack(side=LEFT)
James
On Wednesday 21 March 2007 20:11, Samkos wrote:
Hi there,
I am fighting with a problem I intended to
believe trivial that I could not solve yet!
I am trying to have a button with a variable
text, that pops up another button with a
variable text when pressed.
I did that with the following program in
Python, but the second button remains always
void!!! is it related to the textvariable
parameters?
If any of you had a clue, please don't
hesitate!
in advance, many thanks
Samuel
#----------------------- program 2 buttons.py
--------------------------
from Tkinter import *
def go(event):
root = Tk()
s1=StringVar()
s1.set("s1")
label1 = Label(root, textvariable=s1)
label1.pack(side=LEFT)
root.mainloop()
root = Tk()
s0=StringVar()
s0.set("s0")
label0 = Label(root, textvariable=s0)
label0.pack(side=LEFT)
root.bind("<Return>",go)
root.mainloop()
try this;
def go():
root = Tk()
root.config(bg= 'yellow')
s1=StringVar()
blabel1 = Button(root, textvariable=s1,
width = 10, height = 2,
command = next)
blabel1.pack()
root.bind("<Return>", vbind)
s1.set('click_s1')
def vbind(event):
next()
def next():
second = Toplevel()
s0=StringVar()
s0.set("click_s0")
blabel0 = Button(second, textvariable=s0,
command = second.destroy,
width = 10, height = 2)
blabel0.pack()
if __name__ == '__main__' :
go()
mainloop()
jim-on-linux http://inqvista.com
Thanks a lot Jim and James
now it works fine!
Sam This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Javaman59 |
last post by:
Using local declarations within a block often makes code more readable, but
is it less efficient? eg...
void P() {
while (...) {
int i = ...;
bool b = ...;
....
}
}
|
by: R Reyes |
last post by:
Hi. I'm trying to make some event handlers for buttons that are nested
within datalists, however I keep getting errors trying to access them and a
blank page shows w/o any real error message. How...
|
by: Robert |
last post by:
Need some help to stop me going around in circles on this one....
Have a nested subform (subform2) which simulates a continuous form for the
record on the parent subform.
Subform2 has rows of...
|
by: redpayne |
last post by:
Ok-I am doing homework out of a book and the instructions are to display an interface with 5 option buttons in a frame. When clicked, each button changes the background color of the frame. It...
|
by: brad |
last post by:
Group,
I'm using Visual Studio 2003 to create an ASP.NET 1.1 project which
contains nested server user controls in order to create a tree-like
hierarchy.
The tree is a sort of question and...
|
by: galathaea |
last post by:
On Mar 2, 11:29 pm, galath...@veawb.coop (galathaea) wrote:
still being very naive about this whole crackpot / crank thing
i accidentally let the engineer inside think too hard about this
...
|
by: Didje |
last post by:
Hi,
I am trying to create a grid which contains three rows, within each row there will be various buttons also in gridlayout.
There are 20 buttons in the middle row, 3 in the top and 4 at the...
|
by: Sheldon |
last post by:
Hi,
Can anyone help with this problem with setting up nested structures
and initializing them for use.
I have created several structs and placed them in a super struct that
I will then pass to...
|
by: tmarch001 |
last post by:
HI, I am currently working on a site that has a horizontal scrolling menu, that is made up of a series of movie clips, the last of which contains my buttons. The trouble I am having is that the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |