Tooltip in Pmw : Pmw Tooltips « GUI Pmw « Python

Python
1. 2D
2. Application
3. Buildin Function
4. Class
5. Data Structure
6. Data Type
7. Development
8. Dictionary
9. Event
10. Exception
11. File
12. Function
13. GUI Pmw
14. GUI Tk
15. Language Basics
16. List
17. Math
18. Network
19. String
20. System
21. Thread
22. Tuple
23. Utility
24. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Python » GUI Pmw » Pmw TooltipsScreenshots 
Tooltip in Pmw
Tooltip in Pmw

#Pmw copyright

#Copyright 1997-1999 Telstra Corporation Limited, Australia 
#Copyright 2000-2002 Really Good Software Pty Ltd, Australia

#Permission is hereby granted, free of charge, to any person obtaining a copy 
#of this software and associated documentation files (the "Software"), to deal 
#in the Software without restriction, including without limitation the rights 
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
#copies of the Software, and to permit persons to whom the Software is furnished 
#to do so, subject to the following conditions:

#The above copyright notice and this permission notice shall be included in all 
#copies or substantial portions of the Software.

#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
#INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
#PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 





title = 'Pmw.Balloon demonstration'

# Import Pmw from this directory tree.
import sys
sys.path[:0['../../..']

import Tkinter
import Pmw

class Demo:
    def __init__(self, parent):
  # Create the Balloon.
  self.balloon = Pmw.Balloon(parent)

  # Create some widgets and megawidgets with balloon help.
  frame = Tkinter.Frame(parent)
  frame.pack(padx = 10, pady = 5)
  field = Pmw.EntryField(frame,
    labelpos = 'nw',
    label_text = 'Command:')
  field.setentry('mycommand -name foo')
  field.pack(side = 'left', padx = 10)
  self.balloon.bind(field, 'Command to\nstart/stop',
    'Enter the shell command to control')

  start = Tkinter.Button(frame, text='Start')
  start.pack(side='left', padx = 10)
  self.balloon.bind(start, 'Start the command')

  stop = Tkinter.Button(frame, text='Stop')
  stop.pack(side='left', padx = 10)
  self.balloon.bind(stop, 'Stop the command')

  self.suicide = Tkinter.Button(frame, text='Kill me soon!',
            command = self.killButton)
  self.suicide.pack(side='left', padx = 10)
  self.balloon.bind(self.suicide, 'Watch this button disappear!')

  scrolledCanvas = Pmw.ScrolledCanvas(parent,
    canvas_width = 300,
    canvas_height = 115,
  )
  scrolledCanvas.pack()
        canvas = scrolledCanvas.component('canvas')
        self.canvas = canvas

  # Create some canvas items and individual help.
  item = canvas.create_arc(553535, fill = 'red', extent = 315)
  self.balloon.tagbind(canvas, item, 'This is help for\nan arc item')
  item = canvas.create_bitmap(20150, bitmap = 'question')
  self.balloon.tagbind(canvas, item, 'This is help for\na bitmap')
  item = canvas.create_line(506070808520, width = 5)
  self.balloon.tagbind(canvas, item, 'This is help for\na line item')
  item = canvas.create_text(1090, text = 'Canvas items with balloons',
                anchor = 'nw', font = field.cget('entry_font'))
  self.balloon.tagbind(canvas, item, 'This is help for\na text item')

  # Create two canvas items which have the same tag and which use
  # the same help.
  canvas.create_rectangle(1001017050, fill = 'aliceblue',
    tags = 'TAG1')
  self.bluecircle = canvas.create_oval(1103016080, fill = 'blue',
    tags = 'TAG1')
  self.balloon.tagbind(canvas, 'TAG1',
    'This is help for the two blue items' + '\n' 10 +
                    'It is very, very big.',
                'This is help for the two blue items')
  item = canvas.create_text(18010, text = 'Delete',
                anchor = 'nw', font = field.cget('entry_font'))
  self.balloon.tagbind(canvas, item,
                'After seconds,\ndelete the blue circle')
  canvas.tag_bind(item, '<ButtonPress>', self._canvasButtonpress)
  scrolledCanvas.resizescrollregion()

  scrolledText = Pmw.ScrolledText(parent,
    text_width = 32,
    text_height = 4,
                text_wrap = 'none',
        )
  scrolledText.pack(pady = 5)
        text = scrolledText.component('text')
        self.text = text

  text.insert('end',
    'This is a text widget with ', '',
    ' balloon', 'TAG1',
    '\nhelp. Find the ', '',
    ' text ', 'TAG1',
    ' tagged with', '',
    ' help.', 'TAG2',
    '\n''',
                'Remove tag 1.', 'TAG3',
                '\nAnother line.\nAnd another', '',
  )
  text.tag_configure('TAG1', borderwidth = 2, relief = 'sunken')
  text.tag_configure('TAG3', borderwidth = 2, relief = 'raised')

  self.balloon.tagbind(text, 'TAG1',
    'There is one secret\nballoon help.\nCan you find it?')
  self.balloon.tagbind(text, 'TAG2',
    'Well done!\nYou found it!')
  self.balloon.tagbind(text, 'TAG3',
    'After seconds\ndelete the tag')
  text.tag_bind('TAG3', '<ButtonPress>', self._textButtonpress)

  frame = Tkinter.Frame(parent)
  frame.pack(padx = 10)
  self.toggleBalloonVar = Tkinter.IntVar()
  self.toggleBalloonVar.set(1)
  toggle = Tkinter.Checkbutton(frame,
    variable = self.toggleBalloonVar,
    text = 'Balloon help', command = self.toggle)
  toggle.pack(side = 'left', padx = 10)
  self.balloon.bind(toggle, 'Toggle balloon help\non and off')

  self.toggleStatusVar = Tkinter.IntVar()
  self.toggleStatusVar.set(1)
  toggle = Tkinter.Checkbutton(frame,
    variable = self.toggleStatusVar,
    text = 'Status help', command = self.toggle)
  toggle.pack(side = 'left', padx = 10)
  self.balloon.bind(toggle,
                'Toggle status help on and off, on and off' + '\n' 10 +
                    'It is very, very big, too.',
                'Toggle status help on and off')

  # Create and pack the MessageBar.
  messageBar = Pmw.MessageBar(parent,
    entry_width = 40,
    entry_relief='groove',
    labelpos = 'w',
          label_text = 'Status:')
  messageBar.pack(fill = 'x', expand = 1, padx = 10, pady = 5)

  # Configure the balloon to display its status messages in the
  # message bar.
  self.balloon.configure(statuscommand = messageBar.helpmessage)

    def toggle(self):
  if self.toggleBalloonVar.get():
      if self.toggleStatusVar.get():
    self.balloon.configure(state = 'both')
      else:
    self.balloon.configure(state = 'balloon')
  else:
      if self.toggleStatusVar.get():
    self.balloon.configure(state = 'status')
      else:
    self.balloon.configure(state = 'none')

    def killButton(self):
        # Test for old bug when destroying widgets 1while the
        # balloon was up and 2during the initwait period.
        print 'Destroying button in seconds'
        self.suicide.after(2000, self.suicide.destroy)

    def _canvasButtonpress(self, event):
        print 'Destroying blue circle in seconds'
  self.canvas.after(2000, self.deleteBlueCircle)

    def deleteBlueCircle(self):
        self.balloon.tagunbind(self.canvas, self.bluecircle)
        self.canvas.delete(self.bluecircle)

    def _textButtonpress(self, event):
        print 'Deleting the text tag in seconds'
  self.text.after(2000, self.deleteTextTag)

    def deleteTextTag(self):
  self.balloon.tagunbind(self.text, 'TAG1')
        self.text.tag_delete('TAG1')


######################################################################

# Create demo in root window for testing.
if __name__ == '__main__':
    root = Tkinter.Tk()
    Pmw.initialise(root, 12, fontScheme = 'default')
    root.title(title)

    exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
    exitButton.pack(side = 'bottom')
    widget = Demo(root)
    root.mainloop()

           
       
Related examples in the same category
1. Pmw tooltips demo: entry field and buttonPmw tooltips demo: entry field and button
w_w_w__.___j_a___v___a_2__s__.c_om___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.