473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

2 GUI Windows in Tkinter

I am trying to make a simple dialog box, but when I run this, I get one black window in front of the working application window that I want. How do I get rid of that window?

Expand|Select|Wrap|Line Numbers
  1. from Tkinter import *
  2. import tkSimpleDialog
  3. from traders import QueryTrader
  4.  
  5. class Inputs(tkSimpleDialog.Dialog):              
  6.  
  7.     def body(self, master):
  8.         Label(master, text="Enter Environment Name:").grid(row=0)
  9.         Label(master, text="ID #:").grid(row=1)
  10.         Label(master, text="Enter Start Date for Query:").grid(row=2)
  11.         Label(master, text="Enter End Date for Query:").grid(row=3)
  12.         Label(master, text="Output File Location:").grid(row=4)
  13.  
  14.         self.e1 = Entry(master)
  15.         self.e2 = Entry(master)
  16.         self.e3 = Entry(master)
  17.         self.e4 = Entry(master)
  18.         self.e5 = Entry(master)
  19.  
  20.         self.e1.grid(row=0, column=1)
  21.         self.e2.grid(row=1, column=1)
  22.         self.e3.grid(row=2, column=1)
  23.         self.e4.grid(row=3, column=1)
  24.         self.e5.grid(row=4, column=1)
  25.         return self.e1
  26.  
  27.     def apply(self):
  28.         MXSess = int(self.e1.get())
  29.         Id = int(self.e2.get())
  30.         startDate = int(self.e3.get())
  31.         endDate = int(self.e4.get())
  32.         output = int(self.e5.get())
  33.  
  34.         new = Query()
  35.         arr = new.loadFiles(MXSess, startDate, endDate, Id)
  36.         new.searchDocs(arr, output)
  37.  
  38. root = Tk()        
  39. root.title('Input Parameters')
  40. d = Inputs(root)
  41.  
Sep 1 '10 #1
1 1792
dwblas
626 Expert 512MB
First, you have to pass the Tk() instance to your class. Second, you are not using SimpleDialog so there is no reason to inherit it. Take another look at where you got the code and see what they did and did not do. Some modified code that you can start with follows. Tkinter tutorials/references:
http://infohost.nmt.edu/tcc/help/pub...ter/index.html
http://effbot.org/tkinterbook/
Expand|Select|Wrap|Line Numbers
  1. from Tkinter import *
  2. ##import tkSimpleDialog
  3. ##from traders import QueryTrader
  4.  
  5. class Inputs():              
  6. ##class Inputs(tkSimpleDialog.Dialog):              
  7.  
  8.     def __init__(self, master):
  9.         self.body(master)
  10.  
  11.     def body(self, master):
  12.         Label(master, text="Enter Environment Name:").grid(row=0)
  13.         Label(master, text="ID #:").grid(row=1)
  14.         Label(master, text="Enter Start Date for Query:").grid(row=2)
  15.         Label(master, text="Enter End Date for Query:").grid(row=3)
  16.         Label(master, text="Output File Location:").grid(row=4)
  17.  
  18.         self.e1 = Entry(master)
  19.         self.e2 = Entry(master)
  20.         self.e3 = Entry(master)
  21.         self.e4 = Entry(master)
  22.         self.e5 = Entry(master)
  23.  
  24.         self.e1.grid(row=0, column=1)
  25.         self.e2.grid(row=1, column=1)
  26.         self.e3.grid(row=2, column=1)
  27.         self.e4.grid(row=3, column=1)
  28.         self.e5.grid(row=4, column=1)
  29.  
  30.         ##----- you don't have to return as "self." variables
  31.         ##      are global within the class
  32.         ##return self.e1
  33.  
  34.     def apply(self):
  35.         MXSess = int(self.e1.get())
  36.         Id = int(self.e2.get())
  37.         startDate = int(self.e3.get())
  38.         endDate = int(self.e4.get())
  39.         output = int(self.e5.get())
  40.  
  41. ##        new = Query()
  42. ##        arr = new.loadFiles(MXSess, startDate, endDate, Id)
  43. ##        new.searchDocs(arr, output)
  44.  
  45. root = Tk()        
  46. root.title('Input Parameters')
  47. d = Inputs(root)
  48. root.mainloop() 
Sep 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Thomas Nücker | last post by:
Hi! I am creating a dialog-box within my application, using tkinter. The problem is the following: After the dialogbox is started, the main application window comes again to top and the...
1
by: corrado | last post by:
Hello I have an application running several thread to display some financial data; basically I have a thread displaying HTML tables by means of Tkhtml, another implementing a scrolling ticker...
7
by: Justin Ezequiel | last post by:
What font is Tkinter using for displaying utf-8 characters? On my Windows XP, most of the characters with names (unicodedata.name) are displayed WYSIWYG. However, on my Mandrake (warning: Linux...
7
by: krishnakant Mane | last post by:
hello all, I seam to have noticed this a bit late but it appears to me that tkinter is being used very widely for gui development on all platform? is that right? since fredric lundh has written a...
13
by: Daniel Fetchinson | last post by:
Was looking at PEP 3108, http://www.python.org/dev/peps/pep-3108/ , Is it just me or others also think that it would be a major loss to remove tkinter from the python core? PEP 3108 starts off...
7
by: Protected | last post by:
Hello. I'm a complete newbie trying to learn Python. I decided to try some Tkinter examples, including the one from the library reference, but they don't seem to do anything! Shouldn't there be,...
2
by: Dudeja, Rajat | last post by:
Hi, So, now I've finally started using Eclipse and PyDev as an IDE for my GUI Application. I just wrote some sample programs as an hands on. Now I would like to take up Tkinter. I'm using...
3
by: J-Burns | last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By...
0
by: dudeja.rajat | last post by:
Hi, I'm using Tkinter and Tix. I've created a combo box which I am able to fill it up. I'm want to call a function as soon as user selects some thing from the combo box. More precisely, I want...
1
by: Francesco Bochicchio | last post by:
Il Mon, 18 Aug 2008 12:15:10 +0100, dudeja.rajat ha scritto: Uhm, I don't think you should use the grid manager to obtain a window like that. The grid manager is for equally distributing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
Oralloy
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,...
0
jinu1996
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 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.