How to get ScrollRegion to adjust w/ window-size?

2005-08-05 Thread syed_saqib_ali
Below is a simple code snippet showing a Tkinter Window bearing a
canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine.
When you shrink/resize the window the scrollbars adjust accordingly.

However, what I really want to happen is that the area of the canvas
that the scrollbars show (the Scrollregion) should expand as the window
grows. It doesn't currently do this. although, if the window shrinks
smaller than the original canvas-size, then the scrollregion adjusts
properly.

How can I make it such that the Scrollregion fills the entire space
avaialable to it. I tried all permutations of setting
expand=Tkinter.YES and fill=Tkinter.BOTH in the pack command??

-Saqib



import Tkinter

class testApp2:

def _setupCanvas(self):
self._canvasFrame = Tkinter.Frame(self._overallFrame, bd=1,
relief=Tkinter.SUNKEN)
self._canvasFrame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)

self._canvas = Tkinter.Canvas(self._canvasFrame,
background="white", width=self._canvasWidth,
height=self._canvasHeight,)

# Scroll Bars
vScrollbar = Tkinter.Scrollbar(self._canvasFrame)
hScrollbar = Tkinter.Scrollbar(self._canvasFrame)

# Scroll Bars
vScrollbar = Tkinter.Scrollbar(self._canvasFrame)
vScrollbar.pack(side=Tkinter.LEFT, expand=Tkinter.NO,
fill=Tkinter.NONE)

hScrollbar = Tkinter.Scrollbar(self._canvasFrame)
hScrollbar.pack(side=Tkinter.TOP, expand=Tkinter.NO,
fill=Tkinter.NONE)

# Configure
self._parent.rowconfigure(0, weight=1)
self._parent.columnconfigure(0, weight=1)
#self._scrollX0 = self._scrollY0 = 0
#self._scrollX1 = self._canvasWidth
#self._scrollY1 = self._canvasHeight

print "self._canvasWidth = %s" % self._canvasWidth
print "self._canvasHeight = %s" % self._canvasHeight
#print "self._scrollX1 = %s" % self._scrollX1
#print "self._scrollY1 = %s" % self._scrollY1
self._canvas.config(
width=self._canvasWidth,
height=self._canvasHeight,
scrollregion=(0,0, self._canvasWidth, self._canvasHeight),
yscrollcommand=vScrollbar.set,
xscrollcommand=hScrollbar.set,
)

vScrollbar.config(orient=Tkinter.VERTICAL,
command=self._canvas.yview)
hScrollbar.config(orient=Tkinter.HORIZONTAL,
command=self._canvas.xview)

self._canvasFrame.pack()
self._canvas.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)
vScrollbar.pack(side=Tkinter.RIGHT, expand=Tkinter.YES,
fill=Tkinter.Y)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=Tkinter.YES,
fill=Tkinter.X)

def __init__(self, parent):
self._parent = parent

self._overallFrame = Tkinter.Frame(self._parent, bd=1,
relief=Tkinter.SUNKEN)
self._overallFrame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)

self._canvasWidth = 300
self._canvasHeight = 250
self._setupCanvas()
self._setCallBacks()

def _setCallBacks(self):
# Function Bindings
self._canvas.bind("", self._b1PressEvt)

def _b1PressEvt(self, event):
print self._canvas.config('scrollregion')
print self._canvas.config('width')
print self._canvas.config('height')
print "=" * 50
print "\n"

root = Tkinter.Tk()
app = testApp2(root)
root.mainloop()

-- 
http://mail.python.org/mailman/listinfo/python-list


Tough Tkinter Scrollregion vs Window Size Problem

2005-08-04 Thread syed_saqib_ali



Below is a simple code snippet showing a Tkinter Window bearing a
canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine.
When you shrink/resize the window the scrollbars adjust accordingly.


However, what I really want to happen is that the area of the canvas
that the scrollbars show (the Scrollregion) should expand as the window
grows. It doesn't currently do this. although, if the window shrinks
smaller than the original canvas-size, then the scrollregion adjusts
properly.


How can I make it such that the Scrollregion fills the entire space
avaialable to it. I tried all permutations of setting
expand=Tkinter.YES and fill=Tkinter.BOTH in the pack command??


-Saqib





import Tkinter

class testApp2:

def _setupCanvas(self):
self._canvasFrame = Tkinter.Frame(self._overallFrame, bd=1,
relief=Tkinter.SUNKEN)
self._canvasFrame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)

self._canvas = Tkinter.Canvas(self._canvasFrame,
background="white", width=self._canvasWidth,
height=self._canvasHeight,)


# Scroll Bars
vScrollbar = Tkinter.Scrollbar(self._canvasFrame)
hScrollbar = Tkinter.Scrollbar(self._canvasFrame)

# Scroll Bars
vScrollbar = Tkinter.Scrollbar(self._canvasFrame)
vScrollbar.pack(side=Tkinter.LEFT, expand=Tkinter.NO,
fill=Tkinter.NONE)

hScrollbar = Tkinter.Scrollbar(self._canvasFrame)
hScrollbar.pack(side=Tkinter.TOP, expand=Tkinter.NO,
fill=Tkinter.NONE)

# Configure
self._parent.rowconfigure(0, weight=1)
self._parent.columnconfigure(0, weight=1)
#self._scrollX0 = self._scrollY0 = 0
#self._scrollX1 = self._canvasWidth
#self._scrollY1 = self._canvasHeight


print "self._canvasWidth = %s" % self._canvasWidth
print "self._canvasHeight = %s" % self._canvasHeight
#print "self._scrollX1 = %s" % self._scrollX1
#print "self._scrollY1 = %s" % self._scrollY1
self._canvas.config(
width=self._canvasWidth,
height=self._canvasHeight,
scrollregion=(0,0, self._canvasWidth, self._canvasHeight),
yscrollcommand=vScrollbar.set,
xscrollcommand=hScrollbar.set,
)

vScrollbar.config(orient=Tkinter.VERTICAL,
command=self._canvas.yview)
hScrollbar.config(orient=Tkinter.HORIZONTAL,
command=self._canvas.xview)

self._canvasFrame.pack()
self._canvas.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)
vScrollbar.pack(side=Tkinter.RIGHT, expand=Tkinter.YES,
fill=Tkinter.Y)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=Tkinter.YES,
fill=Tkinter.X)






def __init__(self, parent):
self._parent = parent

self._overallFrame = Tkinter.Frame(self._parent, bd=1,
relief=Tkinter.SUNKEN)
self._overallFrame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)


self._canvasWidth = 300
self._canvasHeight = 250
self._setupCanvas()
self._setCallBacks()









def _setCallBacks(self):
# Function Bindings
self._canvas.bind("", self._b1PressEvt)

def _b1PressEvt(self, event):
print self._canvas.config('scrollregion')
print self._canvas.config('width')
print self._canvas.config('height')
print "=" * 50
print "\n"



root = Tkinter.Tk()
app = testApp2(root)
root.mainloop()

-- 
http://mail.python.org/mailman/listinfo/python-list


Tough Scrolling question with Tkinter

2005-06-14 Thread syed_saqib_ali
Please take a look at and run the code snippet shown below.

It creates a canvas with vertical & Horizontal scroll-bars.
If you shrink the window to smaller than the area of the canvas, the
scroll-bars work as advertised. That's great.

However, if you click the Left Mouse button, it calls code which
expands the width of the canvas by 100 pixels. The area being viewed
expands correspondingly. BUT I DON'T WANT IT TO!!

I want to know how to expand the size of a canvas without changing the
area/size of what is currently shown by the scroll bars. I would like
to find code that expands the width of the canvas and simply adjusts
the H-Scrollbar without changing what is shown on in the area of the
canvas being displayed.

I have tried seemingly every combination of messing with the
canvas.config and scrollregion parameters to no avail. Can someone out
there show me how its done??

-Saqib

-
import Tkinter

def _b1PressEvt(event):
print "B1"
_canvas.config(width=300)

tkRoot = Tkinter.Tk()
_canvas = Tkinter.Canvas(tkRoot, background="white", width=200,
height=200,)

# Scroll Bars
vScrollbar = Tkinter.Scrollbar(tkRoot)
vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y)

hScrollbar = Tkinter.Scrollbar(tkRoot)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)

_canvas.config(
width=200,
height=200,
scrollregion=(0,0,100,100),
yscrollcommand=vScrollbar.set,
xscrollcommand=hScrollbar.set,
)

vScrollbar.config(orient=Tkinter.VERTICAL, command=_canvas.yview)
hScrollbar.config(orient=Tkinter.HORIZONTAL, command=_canvas.xview)

#tkRoot.pack()
_canvas.pack(expand=Tkinter.NO)
vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)

# Function Bindings
_canvas.bind("", _b1PressEvt)

tkRoot.mainloop()

-- 
http://mail.python.org/mailman/listinfo/python-list


How to maintain scroll-region view while changing canvas size?

2005-06-07 Thread syed_saqib_ali


Please take a look at and run the code snippet shown below.

It creates a canvas with vertical & Horizontal scroll-bars.
If you shrink the window to smaller than the area of the canvas, the
scroll-bars work as advertised. That's great.

However, if you click the Left Mouse button, it calls code which
expands the width of the canvas by 100 pixels. The area being viewed
expands correspondingly. BUT I DON'T WANT IT TO!!

I want to know how to expand the size of a canvas without changing the
area/size of what is currently shown by the scroll bars. I would like
to find code that expands the width of the canvas and simply adjusts
the H-Scrollbar without changing what is shown on in the area of the
canvas being displayed.

I have tried seemingly every combination of messing with the
canvas.config and scrollregion parameters to no avail. Can someone out
there show me how its done??

-Saqib






-
import Tkinter

def _b1PressEvt(event):
print "B1"
_canvas.config(width=300)


tkRoot = Tkinter.Tk()
_canvas = Tkinter.Canvas(tkRoot, background="white", width=200,
height=200,)


# Scroll Bars
vScrollbar = Tkinter.Scrollbar(tkRoot)
vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y)

hScrollbar = Tkinter.Scrollbar(tkRoot)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)


_canvas.config(
width=200,
height=200,
scrollregion=(0,0,100,100),
yscrollcommand=vScrollbar.set,
xscrollcommand=hScrollbar.set,
)

vScrollbar.config(orient=Tkinter.VERTICAL, command=_canvas.yview)
hScrollbar.config(orient=Tkinter.HORIZONTAL, command=_canvas.xview)

#tkRoot.pack()
_canvas.pack(expand=Tkinter.NO)
vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)


# Function Bindings
_canvas.bind("", _b1PressEvt)


tkRoot.mainloop()

-- 
http://mail.python.org/mailman/listinfo/python-list


How to add a shapefile to an existing ArcMap 9.x project using Python?

2005-03-16 Thread syed_saqib_ali
Hi.


I have an Instance of ArcMap 9.0 running.


I also have a shapefile named myShape (actually corresponding to 4
files on the disk: myShape.dbf, myShape.shp, myShape.pnt and
myShape.shx)


I would like to write some Python code that inserts myShape into the
running instance of ArcMap9.0 as a new layer.


How can I do this? What software tools/package can I use to do this?
Can you show me the Python code fragment? 


Thanks 
-Saqib

-- 
http://mail.python.org/mailman/listinfo/python-list


Why does interpreter flub

2005-03-01 Thread syed_saqib_ali








I have a file named testPython.py as shown below.

I have shown a trace of the Interpreter Session in which I import the
modules from this file using the command:
"from testPython import *"
When I do this, and modify a global variable from within a function, it
seems that the interpreter is unaware of the updated value!  See Trace
#1 to see what I'm talking about. I don't understand why. Could
somebody please supply a coherent explanation??

However, when I use the "import testPython" command instead, it seems
to work as I would expect. (See Trace #2). Why the difference??


==START OF FILE==
#!C:\python21\python.exe -u -d
x = 10
def main():
global x
print "In Main"
x = 12

def printX():
print x
if __name__ == "__main__":
main()
== END OF FILE ==

==START OF TRACE 1==
Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> from testPython import *
>>> x
10
>>> main()
In Main
>>> printX()
12
>>> x
10
>>>
== END OF TRACE 1 ==


==START OF TRACE 2==
Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import testPython
>>> testPython.x
10
>>> testPython.main()
In Main
>>> testPython.printX()
12
>>> testPython.x
12
>>>
== END OF TRACE 2 ==

-- 
http://mail.python.org/mailman/listinfo/python-list


How to enable Python Scripts with MS IIS Web Server?

2005-02-04 Thread syed_saqib_ali



Hi. I have MS Windows Server 2003, Enterprise Edition.
It has MS Management Console 2.0, Version 5.2
and IIS Manager 6.0



I have a directory called "myDirs". Within this directory are 2 files:
1) index.pl (a perl script)
2) index.py (a python script whose first line is
"#!C:\Python21\pythonw.exe")

The webserver is listening on port 8080.

When I point my browser to http://localhost:8080/myDirs/index.pl, it
works... I see the output of the perl script.

HOWEVER,
When I point my browser to http://localhost:8080/myDirs/index.py, it
simply shows the python file as text. It doesn't interpret it at all.

How Can I get it to interpret the python file using the interpreter and
display the output in the browser?

Please explain each step in careful/excruciating detail because I'm a
windows Newbie.


-Saqib Ali

-- 
http://mail.python.org/mailman/listinfo/python-list