Hi everyone,
I am working on a module for my GUI that shows one image with an index value below and would use a scrollbar to control which of the images are displayed. The images are stored in a successive folder in the format Pic#, i,e. Pic1, Pic2 etc.
What I want to do is make a slider that is attached to a label which would output the slide number that is being looked at. I would use that number then to return the image of the slide to the TK window/canvas. I'm slightly succesfull using the scrollbar and loading images, however, I have yet to figure out how to do a simple scrollbar with a set amount of indices such as numbers 1-140 (which would be all of the pictures in the directory 1-n where n=140).
Here is some of my code, most importantly I would like to see a way of setting the slider to a preset beginning and maximum before I load the specific picture. -
# This module creates a slide show viewer in the Tk environment
-
# Its main purpose is to quickly decide the slide range to be used
-
-
from Tkinter import *
-
import Tkinter
-
import Image # PIL
-
import ImageTk # PIL
-
import sys
-
import getopt
-
from tkMessageBox import *
-
import tkFileDialog
-
from time import *
-
from os import *
-
from math import *
-
from array import *
-
import ImageDraw
-
-
def slideshow(Dir, Resw, Resh, Nslides):
-
root=Tk()
-
root.title("Slide Viewer")
-
root.minsize(width=(Resw+100), height=(Resh+100))
-
-
canv=Canvas(bg="yellow", relief=SUNKEN)
-
canv.config(width=Resw, height=Resh)
-
canv.config(scrollregion=(0,0,1000,500))
-
canv.pack(expand=YES, fill=BOTH)
-
-
for i in range(1,11):
-
slidepic=outputdir+"\\breast"+str(i)+".JPG"
-
print slidepic
-
im=Image.open(slidepic)
-
jpg1=ImageTk.PhotoImage(im)
-
canv.create_image(0,10,image=jpg1, anchor=NW)
-
#slidepic=outputdir+"\\breast2.JPG"
-
#im = Image.open(slidepic)
-
#jpg1=ImageTk.PhotoImage(im)
-
#canv.create_image(50,10,image=jpg1, anchor=NW)
-
#slidepic=outputdir+"\\breast100.JPG"
-
#im = Image.open(slidepic)
-
#jpg2=ImageTk.PhotoImage(im)
-
#canv.create_image(400,10,image=jpg2, anchor=NW)
-
-
scrollbar=Scrollbar()
-
scrollbar.config(command=canv.xview, orient='horizontal')
-
scrollbar.pack(side=TOP, fill=X)
-
-
bottomframe=Frame(root)
-
entry1=Entry(bottomframe)
-
entry1.pack(side=LEFT)
-
entry2=Entry(bottomframe)
-
label1=Label(bottomframe)
-
label1["text"]="-"
-
label1.pack(side=LEFT)
-
entry2.pack(side=RIGHT)
-
bottomframe.pack(side=BOTTOM)
-
-
label2=Label()
-
label2["text"]="Enter the slide range (Lower and Upper bounds inclusive)"
-
label2.pack(side=BOTTOM)
-
-
root.mainloop()
-
-
# Tests
-
outputdir=r"C:\Unity Test\11 Nov 2007 210823\slides"
-
slideshow(outputdir, 512, 512, 144)
Thank you very much for the help!
JP
3 4957
shameless bump
It would be quite helpful to find out this answer.
JP
[code]
#slidepic=outpu tdir+"\\breast2 .JPG"
What kind of images are you looking at? hahah xD
What kind of images are you looking at? hahah xD
Hah, the images are CTs for my masters work. Mind in the gutter I say!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Thomas Buschhardt |
last post by:
Hallo,
I have a problem with Tkinter and the module socket. In a console-window
everything works fine, but in a Tkinter-window I can no more use the
widgets. I found some other mails with this problem, but no solution (I
understand really :-)
Here is my code:
-----------------------------------------------
import win32ui, dde, string, time, os, sys, shutil
|
by: Patrick L. Nolan |
last post by:
Our Tkinter application has a big ScrolledText widget which is
a log of everything that happens. In order to prevent people
from making changes, we have it in DISABLED mode except when
the program wants to write a new entry. This works OK, except
that sometimes we want to copy out of piece of the contents and
paste it in another window. When it's DISABLED, it appears
that we can't even select a portion of the text.
Is this an...
|
by: syed_saqib_ali |
last post by:
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!!
|
by: syed_saqib_ali |
last post by:
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...
|
by: Dustan |
last post by:
I'm trying to get a scrollbar bound with a Frame, and I keep on getting
a scrollbar, but it doesn't actually scroll. Some help, please?
| |
by: C D Wood |
last post by:
To whom this may concern,
Below is the source code, which
demonstrates a
problem I am having making a GUI for my python project work.
'table.txt'
is a file that is read from the same folder.
My code writes to a text file 'table.txt', and 'table.txt' is displayed
in
|
by: jim-on-linux |
last post by:
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
|
by: Hunter.lennon |
last post by:
I want to create a custom scrollbar using particular images, which
will then be placed on a canvas to control another window on the
canvas. Right now I am inheriting from scrollbar, but I do the
movement with custom functions. When I create it and put in into the
canvas with "canvas.create_window" a standard scrollbar shows in the
correct spot and my custom one is outside of the canvas.
All I have right now is something that moves...
|
by: goldtech |
last post by:
Hi,
I'm stumped on how to have a scrollbar with a long list of checkboxes.
Given code like:
from Tkinter import *
root = Tk()
states =
for i in range(150):
var = IntVar()
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |