hi all.. python noob here.. i am creating a GUI for an applcation... now i was just testing the working of askstring : -
from tkSimpleDialog import askstring
-
string=askstring('site','enter site:')
-
print string
-
now.. an extra empty window just pops up.. so i include NoDefaultRoot in th \e following manner: -
from Tkinter import *
-
NoDefaultRoot()
-
from tkSimpleDialog import askstring
-
string=askstring('site','enter site:')
-
print string
-
it then gives the following set of errors:
Traceback (most recent call last):
File "./check2.py", line 5, in ?
string=askstring('site','enter site:')
File "/usr/lib/python2.4/lib-tk/tkSimpleDialog.py", line 304, in askstring
d = _QueryString(title, prompt, **kw)
File "/usr/lib/python2.4/lib-tk/tkSimpleDialog.py", line 282, in __init__
_QueryDialog.__init__(self, *args, **kw)
File "/usr/lib/python2.4/lib-tk/tkSimpleDialog.py", line 172, in __init__
parent = Tkinter._default_root
AttributeError: 'module' object has no attribute '_default_root'
any idea whats wrog? or any alternative way to stop the default window from appearing?
8 4730
The first method is correct.
The "extra" window is actually the application. It will eventually hold your main window. At this point, it is there to get all the event system, etc. rolling.
yes but the problem still exists.. anyhow,, here is something else on similar lines: -
from Tkinter import *
-
from tkSimpleDialog import askstring
-
win=Tk()
-
ti={1:[2,4,5,6],3:[4,8,7,9,0],4:[5,5,6]}
-
enter=askstring('','')
-
for tag,num in ti.items():
-
if enter in num:
-
Label(text=tag,width=20).pack()
-
win.mainloop()
-
above program ideally should give me a window with 1 and 4 as its labels... but it gives an empty window... where am i going wrong?
yes but the problem still exists.. anyhow,, here is something else on similar lines: -
from Tkinter import *
-
from tkSimpleDialog import askstring
-
win=Tk()
-
ti={1:[2,4,5,6],3:[4,8,7,9,0],4:[5,5,6]}
-
enter=askstring('','')
-
for tag,num in ti.items():
-
if enter in num:
-
Label(text=tag,width=20).pack()
-
win.mainloop()
-
above program ideally should give me a window with 1 and 4 as its labels... but it gives an empty window... where am i going wrong?
Looks like - Label() needs a parent window
- The only available window is win (not the dialog)
- Label() text might need to be a string (str(tag)), but ints may get converted
One way to get dictionaries to automatically make string type keys is:
well ints do get converted in python V2.4.. also if i change line 8 to the following: -
Label(win,text=tag,width=20).pack()
-
which is unnecessary since it will use the default window ie win(ie Label wont need a parent window)... it still gives the same output
what to do?
well ints do get converted in python V2.4.. also if i change line 8 to the following: -
Label(win,text=tag,width=20).pack()
-
which is unnecessary since it will use the default window ie win(ie Label wont need a parent window)... it still gives the same output
what to do?
Sorry. I didn't see that IF statement in there: -
from Tkinter import *
-
from tkSimpleDialog import askstring
-
win=Tk()
-
ti={1:[2,4,5,6],3:[4,8,7,9,0],4:[5,5,6]}
-
enter=askstring('','')
-
for tag,num in ti.items():
-
Label(text=tag,width=20).pack()
-
win.mainloop()
Works. I cant' imagine what you are attempting with:
ok here is a snippet of what i am actually working on: -
import sys
-
from Tkinter import *
-
root = Tk()
-
widget=Toplevel()
-
win2=Toplevel()
-
sub=Listbox(widget)
-
sbar=Scrollbar(widget)
-
sbar.config(command=sub.yview)
-
sub.config(yscrollcommand=sbar.set)
-
sbar.pack(side=RIGHT,fill=Y)
-
sub2=Listbox(win2)
-
sbar2=Scrollbar(win2)
-
sbar2.config(command=sub2.yview)
-
sub2.config(yscrollcommand=sbar2.set)
-
sbar2.pack(side=RIGHT,fill=Y)
-
i=0
-
wordlist=['qqe','rrt','ytgh','ihj']
-
def enter():
-
sub2.insert('end',sub.curselection())
-
sub2.pack()
-
-
def writesub():
-
global i
-
sub.insert('end',wordlist[i])
-
i+=1
-
if i==len(wordlist)-1:
-
i=0
-
sub.pack(expand=YES,fill=BOTH)
-
mainbutton=Button(root,text="enter text",command=writesub).pack(expand=YES,fill=BOTH)
-
exitbutton=Button(root,text='QUIT',command=sys.exit).pack(fill=BOTH,expand=YES)
-
enter()
-
root.mainloop()
-
now as i click the button " enter text" , the words in the wordlist get appended as expected in "sub" Listbox.. at the same time.. what i want is if i click any of the words in this list box.. it should get appended in the "sub2" listbox ... which is not happening ... it is just giving a blank window..
i also added the following in line 19: -
sub2.insert('end',sub.get(sub.curselection()))
-
now the problem is that i have to click the button everytime i have to append the selected string in the sub list box in the sub2 listbox
how do i get around it?
hey everyone .. never mind... problem solved.... didnt create a binding event with the double click...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Josh |
last post by:
Caution, newbie approaching...
I'm trying to come up with a very simple Tkinter test application that
consists of a window with a drop-down menu bar at the top and a grid
of colored rectangles...
|
by: Bruce Davis |
last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded
tkinter gui application. The problem appears to be a deadlock condition
when a child thread pops up a
Pmw dialog window in...
|
by: Rob |
last post by:
My first GUI so be gentle...
When I start my program I call a class that runs the initial window. While
in this class if a certain button is pressed it calls a function outside the
class. This...
|
by: DoubleM |
last post by:
Hi,
I'm running Python2.3.3c1 on Mandrake 9.1
The following code is designed to bring up a window with a button labeled
"popup". Clicking on the popup buttons triggers a secondary window with...
|
by: Russell E. Owen |
last post by:
I want to support execution of simple user-written scripts in a Tkinter
application. The scripts should be able to wait for data and such
without hanging the GUI (and without having to write the...
|
by: Pekka Niiranen |
last post by:
Hi there,
after reading TkInter/thread -recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965
I wondered if it was possible to avoid using threads
for the following problem:
...
|
by: Richard Lewis |
last post by:
Hi there,
I've got a tree control in Tkinter (using the ESRF Tree module) but I
can't get it to layout how I want it.
I'd like to have it so that it streches north/south (anchored to the 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: Stewart Midwinter |
last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item
that does nothing more than fetch a directory listing and display it
in a Toplevel window (I'd use a tkMessageBox showinfo...
|
by: Guilherme Polo |
last post by:
On Thu, Aug 28, 2008 at 10:29 AM, <dudeja.rajat@gmail.comwrote:
It is good to post a short code sample that demonstrates the problem,
but it has to run by itself at least.
tkMessageBox...
|
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:
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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: 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: 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...
| |