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=askstrin g('site','enter site:')
File "/usr/lib/python2.4/lib-tk/tkSimpleDialog. py", line 304, in askstring
d = _QueryString(ti tle, 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._defaul t_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 4753 bartonc 6,596
Recognized Expert Expert
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?
bartonc 6,596
Recognized Expert Expert
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?
bartonc 6,596
Recognized Expert Expert
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 filling the remainder of the window. Mind you,
this is a contrived test application to help me understand Tkinter and
Python, not an actual application yet. I've trivially subclassed
Tkinter.Canvas into ColorCanvas, added a bunch of ColorCanvases...
|
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 the context of a main window. The problem does not
occur on HPUX or Linux. The following simple example code illustrates
the problem and the work around
I've come up with; However, I'd like, very much, to get rid of the kludgy
work around....
|
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 function then initially calls another function to
"root.destroy()". Basically I want the current window gone so the function I
just called can open it's own window. The problem I'm stuck with is that
once this function is done and I need to close...
|
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 a
button labeled "ok". The second window is supposed to be modal - it should
not be possible to reset the focus back to the first window or close the
first window without first closing the second. The program works just fine
in Windows XP...
|
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 script as a
bunch of asynchronously called subroutines).
I decided to use Tkinter's wait_variable. I built a "script runner"
object that has suitable wait methods. Internally each of these methods
registers a callback that sets a variable when...
| |
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:
I have script started from W2K console that normally
prints ascii messages to the screen. However, I have
command line "debug" -flag that might cause printing
|
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
and bottom), is of a fixed width and is anchored to the left hand side.
Here's my code (its derived from one of the examples from the ESRF web
site):
|
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 accordingly.
However, what I really want to happen is that the area of the canvas
that the scrollbars show (the Scrollregion) should expand as the window
grows. It doesn't currently do this. although, if the window shrinks
smaller than the...
|
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 widget, but for
some reason the text is invisible on cygwin).
After I close the Toplevel widget, all of the menus in my app behave
as though they have no contents to them, i..e I can press on the File
menu button, and see it depress, but the Exit...
|
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 blocks till you finish it, maybe that is what is causing
your problem but it is hard to tell what you are doing wrong in that
myAppGui without seeing it (preferably reduced code demonstrating the
problem).
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |