-
#! /usr/bin/python
-
# This one creates three windows because of the Tk().winfo_screenwidth(),
-
# Tk().winfo_screenheight() call
-
-
from Tkinter import *
-
-
def quit(): sys.exit(0)
-
-
root = Tk()
-
root.title("Test screen")
-
w, h = Tk().winfo_screenwidth(), Tk().winfo_screenheight()
-
h = h * 0.75
-
paper = Canvas(root, width = h, height = h, bg = "#000020")
-
-
a = h / 10
-
b = h - a
-
-
paper.create_line(a, a, b, b, fill="white")
-
paper.create_line(a, b, b, a, fill="white")
-
-
exitB = Button(text="Exit", width=15, command=quit)
-
exitB.pack()
-
-
paper.pack()
-
mainloop()
-
-
#! /usr/bin/python
-
# This one creates only a single window.
-
-
from Tkinter import *
-
-
def quit(): sys.exit(0)
-
-
root = Tk()
-
root.title("Test screen")
-
-
h = 400
-
paper = Canvas(root, width = h, height = h, bg = "#000020")
-
-
a = h / 10
-
b = h - a
-
-
paper.create_line(a, a, b, b, fill="white")
-
paper.create_line(a, b, b, a, fill="white")
-
-
exitB = Button(text="Exit", width=15, command=quit)
-
exitB.pack()
-
-
paper.pack()
-
mainloop()
-
Any idea how to easily fix this? Thanks in advance...
Greg
Gregory,
Since you have gotten your answer, please mark the appropriate post with the 'choose as best answer button'. This makes it easier for the next person to find the solution.
3 2770
You are starting 3 instances of Tk(). Use root instead - ##--- instance 1
-
root = Tk()
-
root.title("Test screen")
-
-
##-- instances 2 & 3
-
w, h = Tk().winfo_screenwidth(), Tk().winfo_screenheight()
-
-
""" this opens one window only
-
""
-
root = Tk()
-
root.title("Test screen")
-
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
Also, to exit, use the quit command instead of sys.exit. - exitB = Button(text="Exit", width=15, command=root.quit)
Like most errors, this one is trivial when solved, but opaque beforehand. Many thanks, dwblas!
bvdet 2,851
Expert Mod 2GB
Gregory,
Since you have gotten your answer, please mark the appropriate post with the 'choose as best answer button'. This makes it easier for the next person to find the solution.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tom Locke |
last post by:
Hi All,
I'm having trouble with the python shell within emacs. It's hanging when I
use tkinter. Setup is:
Windows XP
emacs 21.3
py-mode 4.6
Recipe:
|
by: Todd Miller |
last post by:
I'm working on a Tkinter backend for the matplotlib plotting software.
matplotlib can be run interactively from some form of Python shell while
plotting to a Tk window. One annoyance we've noticed...
|
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...
|
by: Dan Greenblatt |
last post by:
I am trying to programmatically manipulate the menus in my
application, for purposes of a tutorial, showing users where things
are in our application's menu interface. My goal is to be able to...
|
by: John Fouhy |
last post by:
Hi all,
I have been attempting to change the title bar icon of my Tkinter
applications in Windows XP. Chasing round in google, I discovered:
- This is a common difficulty.
- There aren't any...
|
by: Tim Daneliuk |
last post by:
Arrrrrggg. I have a program that runs comfortably across both Unix variants
and Windows ... except .... I wish to bind an Alt-ButtonRelease-3 combination
to popup a menu. This works flawlessly...
|
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...
|
by: psbasha |
last post by:
Hi,
How to find the Tkinter module is available in Windows and UNIX OS or not?.
Is there any command available?
Thanks
PSB
|
by: bg_ie |
last post by:
Hi,
I'm in the process of writing some code and noticed a strange problem
while doing so. I'm working with PythonWin 210 built for Python 2.5. I
noticed the problem for the last py file...
|
by: akineko |
last post by:
Hello everyone,
I'm trying to create custom Tkinter/Pmw widgets for my project.
After testing my widgets under Unix (Solaris), I have tried them under
Windows and I got a surprise.
The...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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...
| |