472,961 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Computer locks up when running valid stand alone Tkinter file.


py help,

The file below will run as a stand alone file.
It works fine as it is.

But, when I call it from another module it locks
my computer, The off switch is the only
salvation.

This module when run as a stand alone, it will
open a jpeg image and add a vertical and
horizontal scrollbar to the canvass.
That's all it does.

Replace the img9.jpg file with one of your own,
put the image in the current working dir., and
run.

If you think you can help, I would appreciate it.
jim-on-linux

############################################

#!/usr/bin/env python

"""
#############################################
import Tkinter as Tk

Do not do
( from Tkinter import * )
because of name space conflict with
Image.open

##############################################

#### below imports Image and ImageTk are from
#### Imaging-1.1.5, PIL in Python

"""
import Image
import ImageTk
import Tkinter as Tk
import os

vpath = os.getcwd()+os.sep+'img9.jpg'

class Kshow_0 :

def __init__(self ) :
self.Fimgshow0()

def Fimgshow0(self ) :
window = Tk.Tk() # used for stamd alone

# window = Tk.Toplevel()
# Above Toplevel call used when running
# from another file

window.title(' Image Location '+vpath )
window.protocol('WM_DELETE_WINDOW',
window.destroy)

vcanvas = Tk.Canvas(window, width = 375,
height=375,
borderwidth = 1, bg=
'white')

sbarY=Tk.Scrollbar()
sbarX = Tk.Scrollbar( orient='horizontal')
sbarY.config(command= vcanvas.yview)
sbarX.config(command= vcanvas.xview)

vcanvas.config(yscrollcommand=sbarY.set)
vcanvas.config(xscrollcommand=sbarX.set)

sbarY.pack(side='right', fill='y')
sbarX.pack(side='bottom', fill='x')
vcanvas.pack(expand='yes', fill='both')

im= Image.open( vpath)
tkim = ImageTk.PhotoImage(im)

imgW = tkim.width()
print imgW, '## imgW, jpg 58\n'

imgH = tkim.height()
print imgH, '## imgH, jpg 61\n'

# Draw the image on the canvas
vcanvas.create_image(0, 0, image=tkim,
anchor = 'nw' )

vcanvas.config(scrollregion= (0, 0, imgW,
imgH))
window.mainloop ()
if __name__ == '__main__' :

Kshow_0()
Oct 25 '06 #1
2 2263
But, when I call it from another module it locks
methinks this "other module" has the answer.

jim-on-linux wrote:
py help,

The file below will run as a stand alone file.
It works fine as it is.

But, when I call it from another module it locks
my computer, The off switch is the only
salvation.

This module when run as a stand alone, it will
open a jpeg image and add a vertical and
horizontal scrollbar to the canvass.
That's all it does.

Replace the img9.jpg file with one of your own,
put the image in the current working dir., and
run.

If you think you can help, I would appreciate it.
jim-on-linux

############################################

#!/usr/bin/env python

"""
#############################################
import Tkinter as Tk

Do not do
( from Tkinter import * )
because of name space conflict with
Image.open

##############################################

#### below imports Image and ImageTk are from
#### Imaging-1.1.5, PIL in Python

"""
import Image
import ImageTk
import Tkinter as Tk
import os

vpath = os.getcwd()+os.sep+'img9.jpg'

class Kshow_0 :

def __init__(self ) :
self.Fimgshow0()

def Fimgshow0(self ) :
window = Tk.Tk() # used for stamd alone

# window = Tk.Toplevel()
# Above Toplevel call used when running
# from another file

window.title(' Image Location '+vpath )
window.protocol('WM_DELETE_WINDOW',
window.destroy)

vcanvas = Tk.Canvas(window, width = 375,
height=375,
borderwidth = 1, bg=
'white')

sbarY=Tk.Scrollbar()
sbarX = Tk.Scrollbar( orient='horizontal')
sbarY.config(command= vcanvas.yview)
sbarX.config(command= vcanvas.xview)

vcanvas.config(yscrollcommand=sbarY.set)
vcanvas.config(xscrollcommand=sbarX.set)

sbarY.pack(side='right', fill='y')
sbarX.pack(side='bottom', fill='x')
vcanvas.pack(expand='yes', fill='both')

im= Image.open( vpath)
tkim = ImageTk.PhotoImage(im)

imgW = tkim.width()
print imgW, '## imgW, jpg 58\n'

imgH = tkim.height()
print imgH, '## imgH, jpg 61\n'

# Draw the image on the canvas
vcanvas.create_image(0, 0, image=tkim,
anchor = 'nw' )

vcanvas.config(scrollregion= (0, 0, imgW,
imgH))
window.mainloop ()
if __name__ == '__main__' :

Kshow_0()
Oct 26 '06 #2

Thanks for responding,

For those who care.
The solution to the problem was;

First, I did not give a parent to the Yview
scrollbar.

Next, I used the pack geometry for this class and
everything else is grid geometry.

When run stand alone it ran fine because the Yview
scrollbar attached itself to the default parent,
but when run from another module, it locked up.

The difficulty is really in the fact that
scrollbar Yview without a parent tried to attach
itself to the root Tk, already built and running
with grid geometry.

Pack and grid in the same Frame don't get along
(computer lockup).

Give Yview a parent, problem solved.
Changed pack to grid anyway.
jim-on-linux

http://www.inqvista.com


On Wednesday 25 October 2006 23:05, you wrote:
But, when I call it from another module it
locks

methinks this "other module" has the answer.

jim-on-linux wrote:
py help,

The file below will run as a stand alone
file. It works fine as it is.

But, when I call it from another module it
locks my computer, The off switch is the only
salvation.

This module when run as a stand alone, it
will open a jpeg image and add a vertical and
horizontal scrollbar to the canvass. That's
all it does.

Replace the img9.jpg file with one of your
own, put the image in the current working
dir., and run.

If you think you can help, I would appreciate
it.
jim-on-linux

############################################

#!/usr/bin/env python

"""
#############################################
import Tkinter as Tk

Do not do
( from Tkinter import * )
because of name space conflict with
Image.open

#############################################
#

#### below imports Image and ImageTk are
from #### Imaging-1.1.5, PIL in Python

"""
import Image
import ImageTk
import Tkinter as Tk
import os

vpath = os.getcwd()+os.sep+'img9.jpg'

class Kshow_0 :

def __init__(self ) :
self.Fimgshow0()

def Fimgshow0(self ) :
window = Tk.Tk() # used for stamd
alone

# window = Tk.Toplevel()
# Above Toplevel call used when
running # from another file

window.title(' Image Location '+vpath
) window.protocol('WM_DELETE_WINDOW',
window.destroy)

vcanvas = Tk.Canvas(window, width =
375, height=375, borderwidth = 1, bg=
'white')

sbarY=Tk.Scrollbar()
sbarX = Tk.Scrollbar(
orient='horizontal') sbarY.config(command=
vcanvas.yview) sbarX.config(command=
vcanvas.xview)
vcanvas.config(yscrollcommand=sbarY.set)
vcanvas.config(xscrollcommand=sbarX.set)

sbarY.pack(side='right', fill='y')
sbarX.pack(side='bottom', fill='x')
vcanvas.pack(expand='yes',
fill='both')

im= Image.open( vpath)
tkim = ImageTk.PhotoImage(im)

imgW = tkim.width()
print imgW, '## imgW, jpg 58\n'

imgH = tkim.height()
print imgH, '## imgH, jpg 61\n'

# Draw the image on the canvas
vcanvas.create_image(0, 0,
image=tkim, anchor = 'nw' )

vcanvas.config(scrollregion= (0, 0,
imgW, imgH)) window.mainloop ()
if __name__ == '__main__' :

Kshow_0()
Oct 29 '06 #3

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

Similar topics

1
by: Marc | last post by:
Hi all, After some research I've decided that my previous question (Confusing problem between Tkinter.Intvar...) was headed in the wrong direction. Partly because I think I have a greater...
3
by: Rob Mayo | last post by:
I am working in an environment with 4 developers. 2 groups of 2 people working on the same server on the same web project with no version control management on the web server. Programmers A & B...
4
by: a8736d53 | last post by:
Is it possible to install PHP on a stand alone WinME computer, and have the .php files work exactly like they do on an Internet server?
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
0
by: trusharn | last post by:
hi, I m Trushar. I wanted to install Ms-Sql 2000 with Windows XP Pro on a stand alone computer. It's not in network. so plz guide me what to do now..... thanx .....
13
by: Edwin Smith | last post by:
I have a form which displays a DataGridView table generated with the VS2005 tools. The database is a Pervasive v.9 with an ODBC driver. The DataGridView works great except when I'm done and I...
7
by: Jan | last post by:
Hi: When I searched the newsgroup for this problem, I saw two or three instances of the question being asked, but it was never answered. Not too promising, but here goes: I have a form with...
3
by: Vik Rubenfeld | last post by:
I'm developing a web site in PHP for an Apache server. I have a particular stand-alone application that takes a text file as input, and produces a text-file as output. It's usually run from the...
17
by: henry | last post by:
Folks Here's a skeleton, generic HTML page, call it "index.php". You'll see a bit of php code in the middle: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.