I have a script that will make a window that shows the text I want
using Tkinter. What I need to do is to make another window popup above
the current window showing other text. I tryed:
-----------
from Tkinter imprt *
root = Tk()
L = Label(root, text="Blah")
L.grid(row=0, column=0)
# Other labels are also here but their inclusion is not so relavent.
root.mainloop()
sub = Tk()
subL = Label(root, text="Blah")
subL.grid(row=0, column=0)
sub.mainloop()
----------
However, when I ran the script it only showed the second window after I
closed the first one. After looking at the code I guess I can see why.
The problem is that I do not know how to fix the issue. Thank you for
you help. 4 2182
greenflame wrote: I have a script that will make a window that shows the text I want using Tkinter. What I need to do is to make another window popup above the current window showing other text. I tryed:
----------- from Tkinter imprt *
root = Tk()
L = Label(root, text="Blah") L.grid(row=0, column=0)
# Other labels are also here but their inclusion is not so relavent.
root.mainloop()
sub = Tk()
subL = Label(root, text="Blah") subL.grid(row=0, column=0)
sub.mainloop() ---------- However, when I ran the script it only showed the second window after I closed the first one. After looking at the code I guess I can see why. The problem is that I do not know how to fix the issue. Thank you for you help.
Use Toplevel().
from Tkinter import *
root = Tk()
def callback(e=None):
t = Toplevel()
Label(t, text='blah').pack()
b = Button(root, text='new top', command=callback)
b.pack()
root.mainloop()
Also, do not do this twice in the same script: Tk().
James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095 http://www.jamesstroud.com/
Ok so I played with your script. Here is a script that more closely
mimics what I would like to do except that the way I make the variable
deckstr will be different. The only thing I am confused about is that
it opens the second window in the beginning and when I click on the
button, it does nothing even after I have closed the other window.
from Tkinter import *
from string import join
root = Tk()
def showdeck(deck):
deckwin = Toplevel()
deckstr = join(deck, "\n")
Label(deckwin, text=deckstr, justify=LEFT, anchor=W,
font="Courier").pack(fill=X)
L = Button(root, text="Show Deck", font="Courier",
command=showdeck(list('zxcvbnm')))
L.pack()
root.mainloop()
greenflame wrote in news:1149305472.893535.67770
@h76g2000cwa.googlegroups.com in comp.lang.python: Ok so I played with your script. Here is a script that more closely mimics what I would like to do except that the way I make the variable deckstr will be different. The only thing I am confused about is that it opens the second window in the beginning and when I click on the button, it does nothing even after I have closed the other window.
from Tkinter import * from string import join
root = Tk()
def showdeck(deck): deckwin = Toplevel() deckstr = join(deck, "\n") Label(deckwin, text=deckstr, justify=LEFT, anchor=W, font="Courier").pack(fill=X)
L = Button(root, text="Show Deck", font="Courier", command=showdeck(list('zxcvbnm')))
You made the buttons command option None (which is what
showdeck() returns), you need to make command a function
that calls showdeck(list('zxcvbnm')).
L = Button(root, text="Show Deck", font="Courier",
command= lambda : showdeck(list('zxcvbnm')))
L.pack()
root.mainloop()
lambda's docs online: http://docs.python.org/ref/lambdas.html
Rob.
-- http://www.victim-prime.dsl.pipex.com/
What you said about why my code is wrong is still a bit fuzzy but it
worked! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fuzzyman |
last post by:
I'm having trouble implementing my GUI using Tkinter......
I've been working through the Tkinter tutorials from 'Programming
Python' and am generally happy enough with the functionality and feel...
|
by: Peter Moscatt |
last post by:
Ok.... I am pretty new to Python (as you may have gathered from previous
posts). So now it time for another one of my ridiculous questions.... :-)
When using 'Tkinter', what is used as the...
|
by: Richard Townsend |
last post by:
I've been experimenting with passing a window handle from a wxPython app to
a Tkinter app. The Tkinter app should embed a Toplevel window containing a
Canvas widget in the wxPython app's Frame (see...
|
by: Svennglenn |
last post by:
Hi
I'm creating a program in Tkinter and I would need
help to create a "close button" for dialog windows.
One of my typical dialog windows look like this:
def show_window(self):
top =...
|
by: syed_saqib_ali |
last post by:
Below is a simple code snippet showing a Tkinter Window bearing a
canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine.
When you shrink/resize the window the scrollbars adjust...
| |
by: syed_saqib_ali |
last post by:
Below is a simple code snippet showing a Tkinter Window bearing a
canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine.
When you shrink/resize the window the scrollbars adjust...
|
by: Claus Tondering |
last post by:
I am trying to make a Tkinter main window appear and disappear, but I
have problems with that.
Here is a small code sample:
class MyDialog(Frame):
def __init__(self):
Frame.__init__(self,...
|
by: Andrea Gavana |
last post by:
Hi Diez & All,
Do you mind explaining "why" you find it *buttugly*? I am asking just
out of curiosity, obviously. I am so biased towards wxPython that I
won't make any comment on this thread...
|
by: Dream |
last post by:
The code create 2 windows. 2 radiobuttons are put on the second
window. A control variable "v" is binded to the 2 widgets.
But when I run the code, I found the control variable not binded...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |