Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old May 6th, 2008, 06:22 AM
jedifan jedifan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 1 jedifan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 13 sec
Reputation Power: 0
GUI Tkinter - Background image on main app

Hey there, just needing some help with python GUI using tk! just want to know how I can put a picture as a background for my GUI app. I did a search on google for some examples! found one but didnt quite get it to work. My script is a simple one and still learning this python thing.

Code:
from Tkinter import *
import tkMessageBox
import urllib, os, urllib2, httplib



class Application(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.grid()
        self.create_widgets()

    def visit(self):
        visiturl = self.url_ent.get()
        request = urllib2.Request(visiturl)
        httplib.HTTPConnection.debuglevel = 1
        opener = urllib2.build_opener() 
        feeddata = opener.open(request).read()
        print feeddata


    def about(self):
        tkMessageBox.showinfo("Jedi",'''
        Jedi
        ++++++++++++++++++++++++++++++++++++++++
        Jedi Rulz''')

    def close(self):
        root.destroy()


    def history(self):
        tkMessageBox.showinfo("Pyge Visitor",'''
        No History  
        +++++++++++++++++++++++++++++++++++++++
        Testing 
        Date: 10/03/2008''')

    def create_widgets(self):

        # Menubar
        menubar = Menu(self)
        filemenu = Menu(menubar, tearoff = 0)
        filemenu.add_command(label = "History", command=self.history)
        filemenu.add_separator()
        filemenu.add_command(label = "Close", command=root.quit)
        menubar.add_cascade(label = "File", menu = filemenu)
        root.config(menu=menubar)
        helpmenu = Menu(menubar, tearoff = 0)
        helpmenu.add_command(label = "About", command=self.about)
        menubar.add_cascade(label = "Help", menu = helpmenu)
        # create the label for instructions
        self.ins_lbl = Label(self, text = "Enter Your Pyge:")
        self.ins_lbl.grid(row = 0, column = 0, columnspan = 3, sticky = NW)
        # create entry for url
        self.url_ent = Entry(self, width = 29)
        self.url_ent.grid(row = 1, column = 1, columnspan = 3, pady = 2, padx = 5)
        # create label for url
        self.url_lbl = Label(self, text = "URL :")
        self.url_lbl.grid(row = 1, column = 0, sticky = NW)
        # create visit button
        self.cust_bttn = Button(self, text = "Visit",command=self.visit)
        self.cust_bttn.grid(row = 4, column = 0, columnspan = 3, sticky = N, padx = 3, pady = 5)


root = Tk()
root.title("Jedi")
root.geometry( "250x100+300+200")
root.resizable(0,0)
app = Application(root)
root.mainloop()


The above is my script and its a GUI app, just want to put a picture background. The code below is the example I found:

Code:
import Tkinter as tk

root = tk.Tk ()
root.title('image hard')

# pick a .gif image file you have in the working directory
image1 = tk.PhotoImage(file="something.gif")
w = image1.width()
h = image1.height()

root.geometry("%dx%d+0+0" % (w, h))

# tk.Frame has no image argument
# so use a label as a panel/frame
panel1 = tk.Label(root, image=image1)
panel1.pack(side='top', fill='both', expand='yes')

button2 = tk.Button(panel1, text='button2')
button2.pack(side='right')



#save the panel's image from 'garbage collection
panel1.image = image1

#start the even loop
root.mainloop()


Any help would be appreciated, thank you

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > GUI Tkinter - Background image on main app


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway