473,545 Members | 757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dummy tk windows

When I use a function from tkFileDialog outside of a tk GUI context, it creates
a "dummy" tk window. It would be nice to know how to close these windows
programmaticall y. TIA

Peace
Jul 18 '05 #1
3 2505
On Thu, 16 Sep 2004 18:08:12 +0000, Elaine Jackson wrote:
When I use a function from tkFileDialog outside of a tk GUI context, it
creates a "dummy" tk window. It would be nice to know how to close these
windows programmaticall y. TIA


IIRC, you can't close them without terminating the tcl interpreter (doing
so destructs the implicitly created Tk object you instantiated when you
used the tkFileDialog function). However, you can hide it with:

import Tkinter
import tkFileDialog

root = Tkinter.Tk()
root.withdraw()
fileOpen = tkFileDialog.Op en()
fileOpen.show()

HTH

Jul 18 '05 #2
"Paul Miller" <pw*******@adel phia.net> wrote in message
news:pa******** *************** *****@adelphia. net...
<snip> HTH

It did. Thank you. I made a wrapper for this stuff that I'll include here for
the benefit of anyone who may be following the discussion from the sidelines.

Peace

def dialog(classNam e):
from Tkinter import Tk
from tkFileDialog import Open,SaveAs,Dir ectory
Tk().withdraw()
name = eval(className) ().show()
if className=='Dir ectory': return name
mode = (className=='Op en' and 'r') or (className=='Sa veAs' and 'w')
return file(name,mode)
Jul 18 '05 #3
On Fri, 17 Sep 2004 09:19:26 GMT, rumours say that "Elaine Jackson"
<el************ ***@home.com> might have written:
"Paul Miller" <pw*******@adel phia.net> wrote in message
news:pa******* *************** ******@adelphia .net...
<snip> HTH

It did. Thank you. I made a wrapper for this stuff that I'll include here for
the benefit of anyone who may be following the discussion from the sidelines.

Peace

def dialog(classNam e):
from Tkinter import Tk
from tkFileDialog import Open,SaveAs,Dir ectory
Tk().withdraw()
name = eval(className) ().show()
if className=='Dir ectory': return name
mode = (className=='Op en' and 'r') or (className=='Sa veAs' and 'w')
return file(name,mode)


Elaine,

"""eval(classNa me)""" is generally insecure. Another (more secure and
direct) idea would be to """import tkFileDialog""" and then use
"""getattr(tkFi leDialog, className)""" instead.
--
TZOTZIOY, I speak England very best,
"Tssss!" --Brad Pitt as Achilles in unprecedented Ancient Greek
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1293
by: Jonathan Fine | last post by:
I'd appreciate comments on what I'm doing. Please be kind, I'm a new kid on the block. Here's my application. I'm writing some test code. (I'm a recent convert to unit testing.)
4
2903
by: wireless | last post by:
I've written code that dynamically builds an sql query based on various constraint possibilities. The problem is the code would have been very complex had I not come up with a dummy constraint as a kind of place holder in the statement. To avoid complex logic that determines if there was another constraint before any other constraint and...
9
7751
by: Bryan Ashby | last post by:
All, I'm looking for a way to define a "dummy" variable in JavaScript; specifically for the window object. I would like to define a window object that would normally be generated with window.open() but not actually open a new window. E.g.: normal code could look something like this: aVar = window.open("http://www.someurl.com", ...);...
1
1537
by: CSDunn | last post by:
Hello, I am working with a vb6 Windows application that runs on Tablet PC's. There are about five SQL Server 2000 databases that tie into the application. SQL Server MSDE runs on the tablets, and currently there is only one instance running. There are efforts underway to upgrade the application to a .NET SmartClient. One enhancement that...
15
3080
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an OnSelectedIndex event is not fired if you select the first item. Does anyone know of an easy way to do this?
3
4233
by: Simon Brooke | last post by:
As various people will have noticed, I've been having a lot of trouble with XSL lately. Brief history: I wrote myself an XML toolkit back in 2000, and it worked well enough for me, so it's been little changed since. However, it works only with an obsolete version of Saxon (6.2.2 I think), and it has a number of small bugs; and I've at last got...
0
1270
by: Nishanthmarathe | last post by:
Hi There!!! I am new to C# world. I am getting huge chunk of data from a 3rd party applications thru SOAP request and updating to my SQL Server. I cant implement Progress bar as there is no way to know how much data i will get back and its a complicated process. So i decided to use a dummy progress bar, that is 5 moving dots, Which in turn...
35
21504
by: erik gartz | last post by:
Hi. I'd like to be able to write a loop such as: for i in range(10): pass but without the i variable. The reason for this is I'm using pylint and it complains about the unused variable i. I can achieve the above with more lines of code like: i = 0 while (i != 10): i += 1 Is there a concise way to accomplish this without adding extra lines
20
1964
by: Prisoner at War | last post by:
Hi, People, Is it possible to have an "empty" or "dummy" <a href***without*** the browser jumping back up the page?? I have a hyperlink that doesn't point to another document, but is used to call forth a modal window onClick (or is there another way, without text or image links, of calling forth JavaScript on user activity??). I would...
0
7456
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7410
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5960
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5320
isladogs
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...
0
4940
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...
0
3442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3437
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1869
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
0
692
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.