spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Tkinter widgets set to appear in multiple windows appear in the same window


If you don't tell a widget what its parent is, the default is the root window. In many of your widgets you aren't setting the parent window. You should always define the parent window.

This is particularly true when defining widgets in a class that inherits from Frame or Toplevel. When you do that, the assumption is that the class is self-contained -- that everything is a child of that class. When some of the widgets become a child of the root window, your code becomes hard to grasp because you can't make any assumptions about which widgets belong to which parents.

Notice how your terminal class is a subclass of Frame, but you're putting the command line and output windows inside the root window (by virtue of not putting it anywhere else):

class Terminal(Frame):
    def __init__(self, master):
        ...
        self.commandline =
Text(wrap=None,font=txtFont,width=40,height=1)
        ...
        self.output =
Text(wrap=WORD,font=txtFont,width=40,height=30)

Likewise:

class App(Frame):
    def __init__(self, master):
        ...
        self.texteditor =
Text(wrap=WORD,font=txtFont,width=120,height=20)

Each of the above text widgets should use self as the parent of the Text widget so that the child widgets appear inside the Frame widgets. For example:

self.texteditor = text(self, wrap=WORD,
...)

Categories : Python

Related to : Tkinter widgets set to appear in multiple windows appear in the same window
How can I create multiple tkinter widgets with different names in a loop?
Instead of having fifteen variables named c1, c2... c15, create a single list which will hold all of your checkbuttons. Do the same for your entries and vars. checkbuttons = [] entries = [] vars = [] for i in range(numrec): results = cursor.fetchone() var = IntVar() check_button=Checkbutton(frame1,variable=var) check_button.grid(row=i,column=0,sticky='nw') check_button.config(

Categories : Python
TKinter leaving borders around widgets
The extra border is caused by the highlightthickness attribute. The default value is 1 (one); set it to zero to remove the border. This border shows when the button has keyboard focus. However, it appears you're running this on OSX. OSX buttons are a bit less configurable than on other platforms. Setting highlightthickness to zero won't help. The best you can do is set highlightbackground to the

Categories : Python
Adding or deleting tkinter widgets from within other modules
You do it by passing the memory address of whatever widget to the second program. There is no reason to import Tkinter again as you can just pass a pointer to the existing instance. If you are going to be doing anything more than simple experimenting with Tkinter, then it is well worth the time to learn classes first at one of the online sites like this one http://www.greenteapress.com/thinkpyth

Categories : Python
How to update python tkinter window
Your update field is only executed when you close the window because tkinter's mainloop keeps running until the window is closed. Because of this mainloop, using a (long) while loop in tkinter is a bad idea, because the while loop locks up the tkinter mainloop. To do something multiple times without blocking the mainloop, use the after method. This calls a function after a certain amount of time.

Categories : Python
tkinter button to open new window and run script
Multiline code is more readable if you edit your question to add it (allowed, just mark it as edited and say so in the comment) rather than in a comment. from Tkinter import * from sys import executable from subprocess import Popen, CREATE_NEW_CONSOLE import os def delprof(): Popen(["cmd.exe"], creationflags=CREATE_NEW_CONSOLE) ` If you get a console with a prompt, you can run python or do any

Categories : Python
Recently Add
Adding json to new Django database
document clustering in python
Only read the last character in a .txt file
Is it possible to redirect to different domain retaining the trailing endpoint, from a route?
Python NameError: not defined
Numpy array loop
Turning off Tick Marks in Bokeh
Python: Number and operator concatenation not working (Euler's Method)
Python: Twitter API tweets/search: Flatten nested dictionary to columns
Python 2.7 cmd autocomplete readline buffers seem stale
Memory usage/efficiency for pandas dataframe versus lists versus tuples, etc.
How can i use multiple lists as arguments in a function and receive them differently?
PyQt - setText method of QTableWidget gets AttributeError
Matplotlib - get value of autoscale
Backwards axes in numpy.delete
Twilio - How to determine the length of a conference call?
Counting string using for loop
Automating creation of class instances in python for an undetermined amount of instances
Printing 2D-array in a grid
Load PreComputed Vectors Gensim
IPython _repr_html_
Reversing a number using recursion
Is there a configuration under which a numpy operation will work on more than a single core/thread?
Is there a better way to write this if-statement?
Python: Effective reading from a file using csv module
Django/Python: CSV for-in loop overriding first row each time through
How to read the pickled igraph graph object from old version by new version igraph
Tornado WebSocket with Django ORM with shared session
trying to plot contours of bivariate normal, won't work with a correlation term
Python split users input
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.