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

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



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("<Button-1>", _b1PressEvt)
tkRoot.mainloop()

Jul 19 '05 #1
0 2003

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

Similar topics

8
by: ed | last post by:
Does anyone know if ASP.NET 2.0 is going to incorporate "maintain scroll position on postback" in non-IE browsers like Firefox? This seems like an often requested feature on these newsgroups...
8
by: ergobob | last post by:
Hello, I have two scroll boxes on the same page. The first scroll box is good in IE but the words will not wrap correctly in Firefox. The second scroll box is good in all browsers. You can...
1
by: Smith John | last post by:
I am developing web based application using ASP.Net. When the user clicks on the last button in the screen(scrolled down screen), screen postback happens, and display at the start of the page. 1....
1
by: santosh singh | last post by:
Hi, I have one .aspx file which is generating whole page dynamically by taking all the HTML tags from SQL SERVER 2000 database . This .aspx is also containing one user control ( which contains two...
0
by: ranabhavin2 | last post by:
Hi , I have made chat application in asp.net using atlas. It is database chat. So, every 1 minutes page is going to refresh and fetch data from database. All the data of chatting I m...
0
by: Keithb | last post by:
The maintain scroll position on postback feature works as expected with my site running under localhost on the development machine. When the files are posted to an IIS 6.0 web server running on a...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using the VScrollBar and set it as follow: m_vScrollBar.Minimum = -19602; m_vScrollBar.Maximum = 0; m_vScrollBar.SmallChange = 1; m_vScrollBar.LargeChange = 1089; m_vScrollBar.Value =...
1
by: Itzik | last post by:
The simple situation that works: A form (ASP 2.0 Page) with Page.MaintainScrollPositionOnPostBack set to True as well as Page.EnableViewState defaults to True. As the form's data are submitted to...
5
by: googletired | last post by:
Hello, I have slight delima and not sure how to go about this. When a user clicks a link it brings them to a new page, when they have done what the need to do there is a link on that page to...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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 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.