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

Displaying a photo from hard drive

Im using Perl with Tk.
Im creating a graphical user interface for my computer program.

I have this file called "sunset.jpg" and i want it to be displayed in my graphical user interface for my program.

How do i get photos displayed in perl tk?
Sep 7 '06 #1
1 1302
Rykus
5
Im using Perl with Tk.
Im creating a graphical user interface for my computer program.

I have this file called "sunset.jpg" and i want it to be displayed in my graphical user interface for my program.

How do i get photos displayed in perl tk?

You need the Tk::JPEG module.

here is a snippet from a web browser I wrote about 5 or 6 years ago. Hopefully it's still relevant.

Expand|Select|Wrap|Line Numbers
  1. sub open_image
  2. #opens single image and displays it
  3. {
  4.     my ($main, $window_id, $status_window, $bar, $address_bar, $filename) = @_;
  5.     $window[$window_id]->delete('1.0', 'end');
  6.     my $frame = $window[$window_id]->Frame;
  7.     my $label = $frame->Label->pack;
  8.     my $image = $label->Photo(-file=>$filename);
  9.     $label->configure(-image=>$image);
  10.     $width = $image->width();
  11.     $height = $image->height();
  12.     $x = $width/2;
  13.     $y = $height/2;
  14.     #$window[$window_id]->imageCreate(end, -image=>$image);
  15.     $window[$window_id]->windowCreate('end', -align=>center, -window=>$frame);
  16.  
  17.     $saved[$window_id] = 0;
  18.     open(OUT, "<$filename");
  19.     $curr_code[$window_id] = <OUT>;
  20.     close(OUT);
  21. }
Sep 20 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Daniel | last post by:
when writing out a file from .net, when is the file created? after the bytes are all written to the hard drive or before the bytes are written to the hard drive?
3
by: Ken | last post by:
I have a database called autographs.mdb that is in the "XYZ" folder in the "database" folder. I have a form in the database that I want to display a photo of the celeb on. The photos are in a...
3
by: Dalan | last post by:
At first I was not certain what could cause Access 97 from displaying most jpeg images, but not all. After further testing, it seemed that all original images of less than 275 pixels per inch or...
5
by: bob garbados | last post by:
I am trying to create a database-driven photo gallery for a friend with an admin form to upload images... I can upload a file to the web server, but I want to store the image in a database and I...
18
by: Joe Lester | last post by:
This thread was renamed. It used to be: "shared_buffers Question". The old thread kind of died out. I'm hoping to get some more direction by rephrasing the problem, along with some extra...
1
by: David Lozzi | last post by:
Hello, I'm wondering whats the best method to use for displaying several photos' thumbnails. One method I know is to dynamically resize the photo at the time the page is loaded. What does this...
2
by: Steve Hershoff | last post by:
I'd like to display a jpeg image sitting on the C: drive of my webserver. The directory the image is under however, isn't beneath inetpub\wwwroot. Is there a way for an aspx page to display an...
1
by: JVFord | last post by:
Hello. We were having trouble displaying our photos (inserted as OLE Objects) in our database using Access 2003. (you can think of it as a contacts database where it housed info on the person and...
27
fnwtech
by: fnwtech | last post by:
I have been reading the forums, but I really need a step by step. I took a one day vb class about 3 years ago, so I know just enough to be confused! I have a database of students that I have to...
11
by: Marge | last post by:
After importing a VB6 project into Express 2008 I have two gif's with transparency do not display correctly. In VB6 these pictures where used with the image object which had different properties...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.