Re: [pygtk] Glade - Best practice

2005-08-09 Thread Brian
On Tue, 2005-09-08 at 09:10 +, [EMAIL PROTECTED] wrote:
>   
> Hi all,
> 
> Is it better to use:
> 
> self.wTree.get_widget("widget").do_something()
> self.wTree.get_widget("widget").do_something_else()
> self.wTree.get_widget("widget").do_something_else_again()
> 
> or
> 
> widget = self.wTree.get_widget("widget")
> widget.do_something()
> widget.do_something_else()
> widget.do_something_else_again()
> 
> Thanks
> 
I use a little common sense about it.  if you rarely need to call it or
use it I do the first rather than tie up more memory and try to track
yet another variable.


On the other hand something that is used more frequently it is much
better to get it once and use it many times.
-- 
Brian <[EMAIL PROTECTED]>

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Re: pygtk + help guide

2005-08-09 Thread Brian
On Tue, 2005-09-08 at 11:01 +0200, Luigi Pantano wrote:
> i want create a help browser like this:
> http://www.cs.cf.ac.uk/systems/html/322/node7.html
> but multiplatform.
> 

Why create one when you can just import one from python.


Here is some code from our program.  we recently added a custom web
browser choice if the user wishes rather than the the default web
browser that python knows about.  dprint() is our utils print function
that prints to stderr if the debug flag was passed at startup.

[code]


# if using gnome, see if we can import it
try:
import gnome
try:
import gnomevfs
except: # try the depricated module
import gnome.vfs
except ImportError:
# no gnome module
#print >>stderr, ('Module "gnome" not found. '
# 'You will not be able to use gnome to open web pages.')
dprint('LOADERS: Module "gnome" not found. '
   'You will not be able to use gnome to open web pages.')

# get the standard webbrowser module
try:
import webbrowser
except ImportError:
#print >>stderr, ('Module "webbrowser" not found. '
# 'You may not be able to open web pages.')
dprint(' * LOADERS: Module "webbrowser" not found. You may not be able to 
open web pages.')


def load_web_page(name, prefs):
"""Try to load a web page in the default browser"""
dprint("LOADERS: load_web_page(); starting browser thread")
browser = web_page(name, prefs)
browser.start()
return

def load_help_page(name, prefs):
"""Load a locale-specific help page with the default browser."""
dprint("LOADERS: load_help_page: %s" % name)
lc = prefs.globals.LANG
if not lc: lc = "en"
helpdir = os.path.join(prefs.DATA_PATH, 'help')
if os.access(os.path.join(helpdir, lc, name), os.R_OK):
pagename = "file://" + os.path.join(helpdir, lc, name)
elif os.access(os.path.join(helpdir, lc.split('_')[0], name), os.R_OK):
pagename = "file://" + os.path.join(helpdir, lc.split('_')[0], name)
elif os.access(os.path.join(helpdir, "en", name), os.R_OK):
pagename = "file://" + os.path.join(helpdir, "en", name)
else:
dprint(" * LOADERS: failed to find help file '%s' with LANG='%s'!" %
(name, prefs.globals.LANG))
return False
load_web_page(pagename, prefs)


class web_page(threading.Thread):
"""Try to load a web page in the default browser"""
def __init__(self, name, prefs):
dprint("LOADERS: web_page.__init__()")
threading.Thread.__init__(self)
self.name = name
self.prefs = prefs
self.setDaemon(1)  # quit even if this thread is still running

def run(self):
dprint("LOADERS: web_page.run()")
if self.name == '' or self.name == None:
return
if self.prefs.globals.use_custom_browser:
command = self.prefs.globals.custom_browser_command
if '%s' not in command: command += ' %s'
browser = webbrowser.GenericBrowser(command)
try:
browser.open(self.name)
except:
dprint("LOADERS: failed to open '%s' with browser command '%s'" 
% (self.name, command))
else:
try:
gnome.url_show(self.name)
except:
dprint("LOADERS: Gnome failed trying to open: %s" %self.name)
try:
webbrowser.open(self.name)
except:
dprint("LOADERS: webbrowser failed trying to open: %s  -- 
giving up" %self.name)
pass
dprint("LOADERS: Browser call_completed for: %s" %self.name)

[/code]
-- 
Brian <[EMAIL PROTECTED]>

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Dynamically menus with UIManager

2005-08-09 Thread Don Allingham
I've started using UIManager to handle my toolbar and menubar. The
action groups and ui merging have proven to be very powerful.

However, there are a few cases where I would like to have dynamic menus
attached to the menubar. Examples include a history mechanism and a
bookmark list.

Any ideas on how I would dynamically add menu items to a menu that is
generated by UIManager?

Thanks.

Don

-- 
Don Allingham
GRAMPS - Open Source Genealogy
http://www.gramps-project.org

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Re: UIManager toolbar stock image size

2005-08-09 Thread Chris Lambacher
The image size is determined by gtk theme.  There is a depricated toolbar
method which sets the size.  I think there are some hoops you can jump through
to modify the theme settings, but I am not sure how to do that.

-Chris


On Tue, Aug 09, 2005 at 03:19:59PM +, Vinay Reddy wrote:
> > Hi,
> > I created a toolbar from using the UIManger interface. I used the
> > gtk.STOCK* images to create the toolbar, but the default size of the
> > images is too big to my liking. Is it possible to reduce the size of
> > the images in this toolbar (and also the size of the text below the
> > images)?
> 
> sorry for asking the same thing again, but is the above possible or
> will I have to create the toolbar myself?
> 
> Regards,
> Vinay
> ___
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Re: UIManager toolbar stock image size

2005-08-09 Thread Gian Mario Tagliaretti
2005/8/9, Vinay Reddy <[EMAIL PROTECTED]>:

> sorry for asking the same thing again, but is the above possible or
> will I have to create the toolbar myself?

I don't know if I understood correctly but you can set the toolbar style with:
http://www.pygtk.org/pygtk2reference/class-gtktoolbar.html#method-gtktoolbar--set-style

the size can be set with:
http://www.pygtk.org/pygtk2reference/class-gtktoolbar.html#method-gtktoolbar--set-icon-size

but this method is deprecated since 2.4

cheers
-- 
Gian Mario Tagliaretti
PyGTK GUI programming
http://www.parafernalia.org/pygtk/
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] ANNOUNCE: GnomePythonExtras 2.11.4 (unstable)

2005-08-09 Thread Gustavo J. A. M. Carneiro
GnomePythonExtras 2.11.4 has been just released.  This is a unstable
release for testing and unstable application development.

  GnomePythonExtras provides python interfacing modules for some GNOME
libraries not part of the Developer Platform.  The
following Python modules are included:

  - gtkhtml2
  - gnomeapplet
  - gnomeprint, gnomeprint.ui
  - gtksourceview
  - egg.trayicon, egg.recent
  - wnck
  - gtkspell
  - gtkmozembed
  - gdl
  - totem.plparser
  - gtop
  - nautilusburn
  - gda
  - gksu, gksu.ui
  - mediaprofiles (new!)


  The source tarball can be found here:
http://ftp.gnome.org/pub/GNOME/sources/gnome-python-extras/2.11/

  Please file bug reports (bugs, missing APIs) here:
http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-python-extras


Overview of Changes from gnome-python-extras 2.11.3 to gnome-python-extras 
2.11.4
=
* general
 - Fix --with-mozpackage configure option (Gustavo)
* New modules
 - New mediaprofiles module: python bindings for the gnome-media's
   gnome-media-profiles package (Raphael Slinckx)


  Happy testing!

-- 
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
The universe is always one step beyond logic

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] gtk.Scale.set_digits(0)

2005-08-09 Thread Steve Langer


On Aug 8, 2005, at 2:58 PM, John Finlay wrote:


Steve Langer wrote:


Hi --

I'm trying to use a gtk.HScale widget to select integer values, so I 
use HScale.set_digits(0).  However, I also don't want the widget to 
display its value, because the value is also displayed in an 
accompanying gtk.Entry.  But if I use HScale.set_draw_value(False), 
the set_digits(0) doesn't work anymore!HScale.get_value() returns 
non-integers.  Am I doing something wrong, or is this a bug?


Neither - it's a feature. Just round and int the return value in your 
signal handler.


Then it's a documentation bug.  The set_digits description doesn't say 
anything about requiring set_draw_value:


The set_digits() method sets the "digits" property to the value 
specified by digits. The value of digits specifies the number of 
decimal places that are displayed in the value. The value of the 
adjustment is also rounded off to this number of digits, so the 
retrieved value matches the value the user sees.


Thanks for the response.

 -- Steve


--
-- EMail: [EMAIL PROTECTED]Phone: (301) 
975-5423 --
-- WWW:  http://math.nist.gov/mcsd/Staff/SLanger/Fax:   (301) 
990-4127 --
-- Mail: NIST; 100 Bureau Drive -- Stop 8910; Gaithersburg, Md  
20899-8910 --


-- "I don't think this will work.  That's why it's science."
   --
--  Naomi Langer,  17 Feb 2003  
   --


___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Re: UIManager toolbar stock image size

2005-08-09 Thread Vinay Reddy
> Hi,
> I created a toolbar from using the UIManger interface. I used the
> gtk.STOCK* images to create the toolbar, but the default size of the
> images is too big to my liking. Is it possible to reduce the size of
> the images in this toolbar (and also the size of the text below the
> images)?

sorry for asking the same thing again, but is the above possible or
will I have to create the toolbar myself?

Regards,
Vinay
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] How play MP3 everywhere ?

2005-08-09 Thread Guillaume Proux

Axel R. wrote:

Hi,
I develop a pygtk application which have to run on windows/linux/MacOS. And in
this application, I would like heard sound when I click on button. The sound is
a MP3 file (I've got lot of sound-file)
How can I do this ?

Thank you,

Axel


I advise you check out the pygame library (www.pygame.org).
You can also use ctypes to wrap the FMOD library (see www.fmod.org) or 
BASS library (www.un4seen.com).


Regards,

Guillaume
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Re: pygtk + help guide

2005-08-09 Thread Gian Mario Tagliaretti
2005/8/9, Luigi Pantano <[EMAIL PROTECTED]>:
> i want create a help browser like this:
> http://www.cs.cf.ac.uk/systems/html/322/node7.html

that I guess is done using gtkhtml

> but multiplatform.

I don't think this is possible with gtkhtml, it depends from gnome libraries.

ciao
--- 
Gian Mario Tagliaretti
PyGTK GUI programming
http://www.parafernalia.org/pygtk/
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] How play MP3 everywhere ?

2005-08-09 Thread Axel R.
Hi,
I develop a pygtk application which have to run on windows/linux/MacOS. And in
this application, I would like heard sound when I click on button. The sound is
a MP3 file (I've got lot of sound-file)
How can I do this ?

Thank you,

Axel

--
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Glade - Best practice

2005-08-09 Thread Prash
Surely the second one will make your program look readable. You also
avoid making calls to get_widget repeatedly.

On 9 Aug 2005 09:10:41 -, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> 
> 
>   
> Hi all,
> 
> Is it better to use:
> 
> self.wTree.get_widget("widget").do_something()
> self.wTree.get_widget("widget").do_something_else()
> self.wTree.get_widget("widget").do_something_else_again()
> 
> or
> 
> widget = self.wTree.get_widget("widget")
> widget.do_something()
> widget.do_something_else()
> widget.do_something_else_again()
> 
> Thanks 
> 
>  
> ___
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> 
> 
>
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Re: closing tabs in notebook (Philippe Collet)

2005-08-09 Thread [EMAIL PROTECTED]

Hi Vinay Reddy,
Do you only want a close symbol on the right corner of the tabLabel or 
furthermore the capability to close the page of the notebook when it is clicked?
If you want callback also here is the code i use:
Make sure the path for your icon file is correct. (I'm using a relative path 
perhaps you will have to complete it.)

import pygtk
pygtk.require('2.0')
import gtk

   def add_icon_to_button(self,button,iconFilename):
   iconBox = gtk.HBox(False, 0)
   image = gtk.Image()
   fc=filenameChecker()
   image.set_from_file(iconFilename)

   image.show()
   iconBox.pack_start(image, True, False, 0)
   button.add(iconBox)
   iconBox.show()
   return 


   def create_custom_tab(self,text):
iconFile = "hmi\\images\\close.xpm"   
#create a custom tab for notebook containing a label and a button with 
picture on it
eventBox = gtk.EventBox()
   tabBox = gtk.HBox(False, 2)
   tabLabel = gtk.Label(text)
   
   tabButton=gtk.Button()

   tabButton.connect('clicked',self.on_tabButton_clicked)
   
	#Add a picture on a button

   self.add_icon_to_button(tabButton,iconFile)
   
   iconBox = gtk.HBox(False, 0)
   
   eventBox.show()

   tabButton.show()
   tabLabel.show()

   tabBox.pack_start(tabLabel, False)   
   tabBox.pack_start(tabButton, False)
   
   # needed, otherwise even calling show_all on the notebook won't

   # make the hbox contents appear.
   tabBox.show_all()
   eventBox.add(tabBox)
   return eventBox

and in your main function, just call it with :
eventBox=create_custom_tab("Hello")
#Add your_widget in the page and eventBox as tabLabel
self.notebook.append_page(your_widget,eventBox)


___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Glade - Best practice

2005-08-09 Thread [EMAIL PROTECTED]

  
Hi all,

Is it better to use:

self.wTree.get_widget("widget").do_something()
self.wTree.get_widget("widget").do_something_else()
self.wTree.get_widget("widget").do_something_else_again()

or

widget = self.wTree.get_widget("widget")
widget.do_something()
widget.do_something_else()
widget.do_something_else_again()

Thanks



___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Re: pygtk + help guide

2005-08-09 Thread Luigi Pantano
i want create a help browser like this:
http://www.cs.cf.ac.uk/systems/html/322/node7.html
but multiplatform.

-- 
Luigi Pantano
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] pygtk + help guide

2005-08-09 Thread Luigi Pantano
I'm writing a guide (html format) for my program...which widget I must
use in order to use this guide?
-- 
Luigi Pantano
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/