scrollbar dependencies
Hello.
I am using Tkinter and Pmw.
I would like to build 2 canvases/frames that are scrollable together
horizontally, and independently vertically (so, the vertical
scrollbars should not be moved by the horizontal one).
So I built a Pmw.ScrolledFrame() containing the 2 canvases,
horizontally scrollable. Now I am trying to build 2 independent
vertical scrollbars,
--> wich command is linked to each canvas (whose parent is
Pmw.ScrolledFrame.component('frame'),
--> and which parent is root (to be packed outside the Pmw.ScrolledFrame).
Is this possible or not ? If not, does somebody allready did that another way ?
Thanks a lot.
Marion.
--
http://mail.python.org/mailman/listinfo/python-list
Re: scrollbar dependencies
Thanks a lot, Eric Brunel. Harlin, if it's still actual (don't think so, but whoever...) here is a simple code that works. --- from Tkinter import * ## Main window root = Tk() root.grid_rowconfigure(0, weight=1) root.grid_rowconfigure(1, weight=1) root.grid_columnconfigure(0, weight=1) ## First canvas c1 = Canvas(root, width=200, height=100, bd=2, relief=SUNKEN, scrollregion=(0, 0, 500, 500)) c1.grid(row=0, column=0, sticky='nswe') ## Second canvas c2 = Canvas(root, width=200, height=100, bd=2, relief=SUNKEN, scrollregion=(0, 0, 500, 500)) c2.grid(row=1, column=0, sticky='nswe') ## Special function scroll both canvases horizontally def xscrollboth(self,*args): c1.xview(self,*args) c2.xview(self,*args) ## Horizontal scrollbar for both canvases hScroll = Scrollbar(root, orient=HORIZONTAL, command=xscrollboth) hScroll.grid(row=2, column=0, sticky='we') ## Vertical scrollbars vScroll1 = Scrollbar(orient=VERTICAL, command=c1.yview) vScroll1.grid(row=0, column=1, sticky='ns') c1.config(yscrollcommand=vScroll1.set,xscrollcommand=hScroll.set) vScroll2 = Scrollbar(orient=VERTICAL, command=c2.yview) vScroll2.grid(row=1, column=1, sticky='ns') c2.config(yscrollcommand=vScroll2.set,xscrollcommand=hScroll.set) root.mainloop() --- "Eric Brunel" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > On 3 Mar 2005 02:38:59 -0800, Harlin Seritt <[EMAIL PROTECTED]> wrote: > > > Pardon a question I should already know the answer to, but what are the > > *args in the: > > > > def xscrollboth(*args): > >c1.xview(*args) > >c2.xview(*args) > > > > Thanks, > > > > Harlin > > If your question is about the syntax, it's just the way of passing any number > of arguments to a function as explained in: > http://docs.python.org/tut/node6.html#SECTION00673 > > If your question is about what will actually be passed in these arguments, > the answer is simply: I don't know, and I don't care. That's why I used a > *args: I just want to pass to the c1.xview and c2.xview methods exactly what > was passed to my xscrollboth function. Since Python allows me to just pass > the list of arguments unchanged, I happily do it. -- http://mail.python.org/mailman/listinfo/python-list
Re: scrollbar dependencies
Next mystery :
a picture drawn in the canvas c1 is scrollable.
a picture-containing canvas "grided" in the canvas c1 is not.
so why ???
Marion
---
from tkinter import *
from PIL import *
class Main:
def __init__(self):
## Main window
self.root = Tk()
self.root.grid_rowconfigure(0, weight=1)
self.root.grid_rowconfigure(1, weight=1)
self.root.grid_columnconfigure(0, weight=1)
## datas :
self.PIC=[]
self.ANN=[]
## First canvas (picture)
self.c1 = Canvas(
self.root,
width=500,
height=100,
bd=2,
relief=SUNKEN,
scrollregion=(0, 0, 100, 100))
self.c1.grid(
row=0,rowspan=2,
column=1,
sticky='nswe')
#---#
# this is scrollable :
#---#
image =Image.new("RGB",(100,100))
dessin = ImageDraw.Draw(image)
dessin.rectangle([(10,10),(50,50)],fill="rgb(255,0,0)")
photo=ImageTk.PhotoImage(image)
item = self.c1.create_image(0,0,anchor=NW,image=photo)
#---#
# this is not ! :
#---#
canvas=Canvas(self.c1,background="WHITE")
image =Image.new("RGB",(100,100))
dessin = ImageDraw.Draw(image)
dessin.rectangle([(10,10),(50,50)],fill="rgb(255,0,0)")
photo=ImageTk.PhotoImage(image)
item = canvas.create_image(0,0,anchor=NW,image=photo)
canvas.grid()
## Second canvas (annot)
c2 = Canvas(
self.root,
width=500,
height=100,
bd=2,
relief=SUNKEN,
scrollregion=(0, 0, 1000, 1000))
c2.grid(
row=2,rowspan=2,
column=1,
sticky='nswe')
## Special function scroll both canvases horizontally
def xscrollboth(a,*args):
self.c1.xview(a,*args)
c2.xview(a,*args)
## Horizontal scrollbar for both canvases
hScroll = Scrollbar(self.root, orient=HORIZONTAL, command=xscrollboth)
hScroll.grid(
row=4,rowspan=1,
column=1,
sticky='we')
## Vertical scrollbars
vScroll1 = Scrollbar(orient=VERTICAL, command=self.c1.yview)
vScroll1.grid(
row=0,rowspan=2,
column=2,
sticky='ns')
self.c1.config(yscrollcommand=vScroll1.set,xscrollcommand=hScroll.set)
vScroll2 = Scrollbar(orient=VERTICAL, command=c2.yview)
vScroll2.grid(
row=2,rowspan=2,
column=2,
sticky='ns')
c2.config(yscrollcommand=vScroll2.set,xscrollcommand=hScroll.set)
---
--
http://mail.python.org/mailman/listinfo/python-list
Re: scrollbar dependencies
ok, we must redefine each canvas scroll individually ... but what a () strange language... !! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python in High School
On Apr 1, 1:27 pm, sprad <[EMAIL PROTECTED]> wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. I am a strong support of teaching programming in middle and high school. Kids have the potential of being more than just passive consumers of other programmers work. That is best illustrated by the growth of game mod'rs writing their own levels for computer games. I think I agree with all of the positive, supporting posts about Python. I would just like to add that Python (and PyGame) are open source and so your students can download it at home and have fun exploring it on their own time (at their own pace). I think that is a real positive. -- http://mail.python.org/mailman/listinfo/python-list
How To Uses Modules And Plugins
I am working on a client/server, computer role-play game using Python. I want to gradually expand the game world by creating maps as individual py files in a map directory. I am a little foggy of how to do this. I have read about the __import__() function. I want to understand what the difference is between using modules and plugins. Are they the same thing? How will my root script interact with the individual modules once it has loaded them? If you can point me to a web site or tutorial on this subject I would be thankful. -- http://mail.python.org/mailman/listinfo/python-list
jonathan ballet?
je m'interroge si ceci est ta nouvelle adresse... je te cherchais a tout hazard sur internet... bises marion battentier de la rochette, tu te souviens??-- http://mail.python.org/mailman/listinfo/python-list
Need array help
I am switching from microsoft visual basic programming to python programming. In microsoft visual basic you can Dim a variable so that you can add variables by changing the number on the end of the variable as in the following example; Dim acct(100) numoffiles=4 data=10 ct=1 while ct <> numoffiles acctfile(ct) = data ct= ct + 1 data= data + ct Wend The results are; acctfile(1)=10 acctfile(2)=12 acctfile(3)=15 And you can compare the values of the new variables; if acctfile(1) > acctfile(2) then print "yes" if acctfile(2) > acctfile(1) then print "yes" when I try to create acctfile(ct) = data I get the following error; ***can't assign to function call. Then it gives the program line of the problem Here is the progam in python; numoffiles=4 data=10 ct=1 while ct != numoffiles: acctfile(ct) =data ct += 1 data= data + ct print acctfile(ct) Does anybody know how this is done in Python? -- http://mail.python.org/mailman/listinfo/python-list
