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() 2 2300
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()
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()
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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?
|
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...
|
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 .....
|
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...
|
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...
|
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...
|
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"...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
|
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...
| |