473,379 Members | 1,283 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,379 software developers and data experts.

Tkinter Unix and Windows incompatibility

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 widgets came out differently.
The following simple code snippet demonstrates the difference:

root = Tk()

w = Canvas(root, width=12, height=12, bd=4, relief=RAISED,
bg='cyan')
w.create_rectangle(5,5,16,16,fill='blue', outline='black')
w.pack()

w2 = Canvas(root, width=12, height=12, bd=0, relief=RAISED,
bg='purple')
w2.create_oval(0,0,12+1,12+1,fill='blue', outline='')
w2.pack()

w3 = Canvas(root, width=32, height=32, bd=4, relief=RAISED,
bg='purple')
w3.create_oval(4+0,4+0,4+32+1,4+32+1,fill='blue', outline='')
w3.pack()

root.mainloop()

//

I noticed the difference because rectangle (or oval) object on the
canvas covers the entire canvas such that small differences in size
are very noticeable.
As Tkinter is a thin wrapper layer for Tk, I'm suspecting the
differences are rooted in Tk.
I'm using TK8.5 under Unix while Python under Windows uses TK8.4.

As I don't have any access to Python under Windows with TK8.5, I
cannot verify if this problem is fixed under TK8.5 for Windows.

//

So, here are my questions:
(1) Can anybody who has access to Python under Windows with TK8.5 to
verify if the problem is fixed.
If the problem is fixed, rectangle and ovals are inscribed to the
canvas boundary nicely.
If not, you see the rectangle is off by one pixel and the radius is
one pixel larger, I think. The boundary width is also not correct
(right side is one pixel wider).
(2) As the official distribution of Python under Windows uses TK8.4,
what is the best approach to make my widgets to work correctly under
both environment?
- I could use sys.platform to code differently so that they look the
same.
- I'm afraid this creates a problem when TK8.5 is finally introduced
to Python under Windows.

Any suggestions?

Aki Niimura
Aug 27 '08 #1
1 1477
On Wed, 27 Aug 2008 06:50:30 +0200, akineko <ak*****@gmail.comwrote:
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 widgets came out differently.
The following simple code snippet demonstrates the difference:

root = Tk()

w = Canvas(root, width=12, height=12, bd=4, relief=RAISED,
bg='cyan')
w.create_rectangle(5,5,16,16,fill='blue', outline='black')
w.pack()

w2 = Canvas(root, width=12, height=12, bd=0, relief=RAISED,
bg='purple')
w2.create_oval(0,0,12+1,12+1,fill='blue', outline='')
w2.pack()

w3 = Canvas(root, width=32, height=32, bd=4, relief=RAISED,
bg='purple')
w3.create_oval(4+0,4+0,4+32+1,4+32+1,fill='blue', outline='')
w3.pack()

root.mainloop()

//

I noticed the difference because rectangle (or oval) object on the
canvas covers the entire canvas such that small differences in size
are very noticeable.
As Tkinter is a thin wrapper layer for Tk, I'm suspecting the
differences are rooted in Tk.
I'm using TK8.5 under Unix while Python under Windows uses TK8.4.

As I don't have any access to Python under Windows with TK8.5, I
cannot verify if this problem is fixed under TK8.5 for Windows.

//

So, here are my questions:
(1) Can anybody who has access to Python under Windows with TK8.5 to
verify if the problem is fixed.
If the problem is fixed, rectangle and ovals are inscribed to the
canvas boundary nicely.
If not, you see the rectangle is off by one pixel and the radius is
one pixel larger, I think. The boundary width is also not correct
(right side is one pixel wider).
(2) As the official distribution of Python under Windows uses TK8.4,
what is the best approach to make my widgets to work correctly under
both environment?
- I could use sys.platform to code differently so that they look the
same.
- I'm afraid this creates a problem when TK8.5 is finally introduced
to Python under Windows.

Any suggestions?
I didn't really test your code, but I know there have been a few problems
with the Canvas relief and border for quite a while now. For example, the
Canvas border has a tendency to disappear when the Canvas is scrolled.
Don't know if it's fixed in the latest version.

The usual workaround is to create canvases with a flat relief and 0
border, and add the relief if you want one via a surrounding Frame. In
your example, for the first Canvas, that would be:

f = Frame(root, bd=4, relief=RAISED)
f.pack()
w = Canvas(f, width=12, height=12, bg='cyan')
w.create_rectangle(1, 1, 12, 12, fill='blue', outline='black')
w.pack()

This may solve your problem.

HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
Aug 27 '08 #2

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

Similar topics

0
by: Mike Maxwell | last post by:
First, apologies if this is not the appropriate newsgroup (and let me know what would be a better group). I downloaded the Python 2.3.3, did the ./configure and make routine. 'configure' seems...
1
by: Eric Brunel | last post by:
Hi all, I'm in the process of localizing a Tkinter application and I'm struggling with a problem for which I can't figure out a solution. The following code: -------------------------------...
8
by: Erik Johnson | last post by:
I am looking for some input on GUI libraries. I want to build a Python-driven GUI, but don't really understand the playing field very well. I have generally heard good things about wxPython. I...
12
by: Tom | last post by:
1) Portable to Windows, Unix-like platforms, and the Macintosh; 2) Powerful, GUI is very beautiful ; 3) Efficiency of development is high; What's the best, Tkinter, wxPython, QT, GTK or other? ...
1
by: dmsbox2000-list1 | last post by:
This is a beginner question. I am using a Mac running OS X. I have TclTkAqua installed. If I type: import Tkinter r = Tkinter.Tk() c = Tkinter.Canvas(r) c.pack() c.create_line(0,0,100,0)
5
by: Ben Kovitz | last post by:
Hi, I just tried to run Tkinter on OS X 10.3.9 under Python 2.4.3, and I'm getting a bus error as soon as I call Tk(). Googling has turned up info other Tkinter bus errors, but not this one that...
2
by: Ben Finney | last post by:
Howdy all, Python programmers looking for a built-in GUI toolkit are told two things: one, Python already comes with a GUI toolkit, and two, it looks equally ugly on all platforms. This is...
0
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.