[pygtk] Custom widgets ..

2009-01-21 Thread Daniel Hernández Bahr
Hullo everyone!! 

I would like to include in my application an Entry such as the ones Mozilla 
Firefox has. I mean .. an entry with a search button inside. 

Any sugestions?? 


Cheers!! 

-- 

Daniel Hernández Bahr 
Universidad de las Ciencias Informáticas. 

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

[pygtk] window focus

2009-01-21 Thread Daniel Hernández Bahr
Hi again!! 

I've being fighting with the issue tha may window won't get the focus at start, 
it will just stay below .. even if there are not other windows it wont get the 
focus. Is there any reason for this?? 

I am showing a splash while loading; I guess this might have something to do 
with it .. 

Any clues?? 

Cheers!! 

-- 

Daniel Hernández Bahr 
Universidad de las Ciencias Informáticas. 

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

Re: [pygtk] Tooltips on comboBox

2009-01-21 Thread Alessandro Dentella
I forward here the answer from Kristian Rietveld in gtk list. I thinks it may
be useful to others.

After this I decided to use deprecated widget OptionMenu, that gives a
normal MenuItem that supports tooltips



sandro

---
On Wed, Jan 21, 2009 at 10:22 AM, Alessandro Dentella san...@e-den.it wrote:
 In my attempt to get tooltips I see that as I click on the arrow and the
 popup appears, the tooltip disappears.

This is also because GTK+ hides a tooltip as soon as something is
clicked to avoid the tooltip getting in your way.

 It seems the popup is a different gtk.Widget, and I should connect to that
 one to attach tooltips. Is that correct? and in case how can I have that
 widget?

Yes, the popup is a different widget.  There is no API call to access
this popup widget directly (this has also been done deliberately,
since the popup widget/window can change when the theme changes and in
general people shouldn't mess around with it ;).

 Can somebody clearify which is the way a ComboBox pops a menu and how I can
 get to it's components to set a tooltip?

Right now I don't see a way how to easily set a tooltip on the combo
box popup.  I do agree that this would be very useful to be able to do
and we should support this in a future version of GTK+.


regards,

-
On Wed, Jan 21, 2009 at 1:16 PM, Alessandro Dentella san...@e-den.it wrote:
 Right now I don't see a way how to easily set a tooltip on the combo
 box popup.  I do agree that this would be very useful to be able to do
 and we should support this in a future version of GTK+.

 sigh...

 Thank you so much for the explanation.

I have this mail thread marked in my inbox so that I won't forget to
open a bug for this issue ;)

 Of course I think that addition would be really usefull. For the time being
 I think the only solution for me will be to mock it with a menu. Would
 OptionMenu (that was deprecated in favor to ComboBox) give me the
 opportunity to set tootlip or I would meet the same problem?

I think the option menu will give you this opportunity since you have
to create the menu that is popped up yourself and pass that to the
GtkOptionMenu.

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


[pygtk] try/except won't trap DeprecationWarning from OptionMenu

2009-01-21 Thread Alessandro Dentella
Hi,

  I'd like to use deprecated OptionMenu, but I can't stop the
  DeprecationWarning. Why is it different from a self produced one?

import gtk

try:
raise DeprecationWarning
except DeprecationWarning, e:
pass


try:
a = gtk.OptionMenu()
except DeprecationWarning, e:
pass

  
  only the first one will be trapped. Why?
  Is there a way to stop it?



  sandro
  *:-)


PS: the reason why I want to use OptionMenu is as per my other thread the
possibilityto add tooltips
  
-- 
Sandro Dentella  *:-)
http://sqlkit.argolinux.orgSQLkit home page - PyGTK/python/sqlalchemy
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] try/except won't trap DeprecationWarning from OptionMenu

2009-01-21 Thread Paul Pogonyshev
Alessandro Dentella wrote:
   I'd like to use deprecated OptionMenu, but I can't stop the
   DeprecationWarning. Why is it different from a self produced one?

It is not different.  Please see the 'warnings' module.  Last time I
checked the warnings filters described there could be used to suppress
warnings from PyGTK as well.

Paul

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


Re: [pygtk] get_active() of CheckButton added to ScrolledWindow

2009-01-21 Thread Daniel Roesler
Thanks Walter!

My example program now works with the self.button solution. Also, I
changed the self.window to self.gui to make the name more appropriate.

Revised program (working):

import pygtk
import gtk
import gtk.glade

class app_gui:
 def __init__(self):
   self.gui = gtk.glade.XML(check.glade)
   dic = { on_button1_clicked : self.button1_clicked,
   on_button2_clicked : self.button2_clicked,
   on_window1_destroy : (gtk.main_quit) }
   self.gui.signal_autoconnect(dic)
   return

 def button1_clicked(self,widget):
   self.button = gtk.CheckButton(test)
   self.gui.get_widget(scrolledwindow1).add_with_viewport(self.button)
   self.button.show()
   return

 def button2_clicked(self,widget):
   status = self.button.get_active()
   print status
   return

app=app_gui()
gtk.main()


Avast!
Daniel Roesler
diaf...@gmail.com

On Wed, Jan 21, 2009 at 1:34 AM, Walter Leibbrandt
wal...@translate.org.za wrote:
 Hi,

 Firstly, on a conceptual note, self.window is not really an accurate name
 for the glade.XML object created. It does not represent any one window, but
 rather the whole GUI (windows and widgets) created in Glade. You can see the
 glade.XML object as a factory object, taking the XML output from the Glade
 UI designer (check.glade in your case) as input and giving you the
 constructed widgets as output.

 Having said that, there is no way for the glade.XML object to know about
 widgets that were created at run-time and not specified in its input XML and
 that is why self.window.get_widget(test) returns None. Also the string you
 passed as argument to gtk.CheckButton() is the button's label and not it's
 name. The difference is that the label is the string that is displayed on
 the button and the name is used as an internal string identifier for the
 widget.

 The most common way to achieve what you are trying to do here, is to keep a
 reference to all new, custom-created widgets. So if you replace button =
 gtk.CheckButton('test') with self.button = gtk.CheckButton('test'), you
 can simply do state = self.button.get_active() in your button2_clicked()
 event handler.

 HTH

 Walter

 Daniel Roesler wrote:

 Howdy all,

 I'm just learning pygtk and glade, and I have a question about
 accessing widgets that were added during an called function. In my
 example, I have two buttons. The first button that adds a checkbox to
 a scrolled window area. The second button prints the activity status
 (True/False) of the checkbox.

 The first button works fine. However, when I push button two, python
 says AttributeError: 'NoneType' object has no attribute
 'get_active'. Obviously, this means that I'm not reaching the
 checkbox widget correctly.

 So my question, how can I get properties of a widget added after the
 initial glade file was loaded?

 Here's my program, and I've attached my glade file. Thanks all!
 ---
 import pygtk
 import gtk
 import gtk.glade

 class app_gui:
  def __init__(self):
self.window = gtk.glade.XML(check.glade)
dic = { on_button1_clicked : self.button1_clicked,
on_button2_clicked : self.button2_clicked,
on_window1_destroy : (gtk.main_quit) }
self.window.signal_autoconnect(dic)
return

  def button1_clicked(self,widget):
button = gtk.CheckButton(test)
self.window.get_widget(scrolledwindow1).add_with_viewport(button)
button.show()
return

  def button2_clicked(self,widget):
status = self.window.get_widget(test).get_active()
print status
return

 app=app_gui()
 gtk.main()
 ---

 Avast!
 Daniel Roesler
 diaf...@gmail.com
  

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

 --
 Walter Leibbrandt  http://translate.org.za/blogs/walter
 Software Developer  +27 12 460 1095 (w)
 Translate.org.za

 Recent blogs:
 * Virtaal's MVCisation
 http://www.translate.org.za/blogs/walter/en/content/virtaals-mvcisation
 * Things that changed the way I code
 * Switching from Subversion to git



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


Re: [pygtk] [Glade-devel] how to add window as a page to a notebook

2009-01-21 Thread Neil Dugan
Tristan Van Berkom wrote:
 On Sat, Jan 10, 2009 at 1:54 AM, anusha k anuha...@gmail.com wrote:
 hi,

 I am using glade and pygtk to develop an accounting software.In that we have
 two glade files .first glade file contain the main window and the note book
 and the second glade contains the another window .I want to add the second
 glade-window as a page to first glade-window.how to do this
 I have the code as below.but it is giving the warning and the window is not
 shown up .warnings are :
 How to solve the warnings.Is there any other way to solve this
 Warnings:

 self.wTree = gtk.glade.XML(self.gladefile)
 main.py:47: GtkWarning: gtk_notebook_set_tab_label: assertion `GTK_IS_WIDGET
 (child)' failed
   self.wTree = gtk.glade.XML(self.gladefile)
 main.py:20: GtkWarning: Can't set a parent on a toplevel widget


 self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget(window_new_org)
 , None, 0)
 main.py:20: GtkWarning: gtk_widget_set_child_visible: assertion
 `!GTK_WIDGET_TOPLEVEL (widget)' failed
 
 You cannot add a GtkWindow to another GtkContainer, a GtkWindow is a
 toplevel-only
 widget and is not meant to be maintained.
 
 You can either:
- Manually unparent your window's child and add that child to the
 notebook (the traditional oldschool way)
- Use the root argument to glade_xml_new or some equivalent
 gtkbuilder api (I think that works
  for building of sub-portions of the glade file)
- Use development or trunk versions of Glade allowing you to use
 non-GtkWindow toplevel project
  widgets - and use GtkBuilder that will allow you toplevelless
 glade files without errors/warnings.
 
 Cheers,
-Tristan

One thing I have done that is similar is, to not attach the window, 
but attach the most top level widget.  When designing the window, you 
need to put all the widgets in a HBox,VBox or Table.  Attach this not 
the window itself.

Regards Neil.

 
 self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget(window_new_org)
 , None, 0)
 ***
 Code:

 import pygtk
 pygtk.require('2.0')
 import gtk
 import gtk.glade
 import new_org
 class mainmenu:
 def show_newOrganisation(self,widget):
 new_org.org()
 self.gladefile_newOrg = new_org.glade
 self.wTreenewOrg = gtk.glade.XML(self.gladefile_newOrg)

 self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget(window_new_org)
 , None, 0)
 self.notebook.set_current_page(self.page)

 def dialogQuit(self,widget):
 self.dialog_quit = self.wTree.get_widget(dialog_quit)
 self.dialog_quit.show()
 self.response = self.dialog_quit.run()
 if self.response == 'gtk.RESPONSE_QUIT':
 gtk.main_quit()
 self.window.destroy()
 self.dialog_quit.destroy()


 def on_button_quit_clicked(*args):
 gtk.main_quit()

 def on_button_cancel_clicked(*args):
 self.dialog_quit.destroy()

 #To quit the main window
 def on_Mainwindow_destroy(self):
 gtk.main_quit()


 def __init__(self):
 #set the glade file
 self.gladefile = gnukhata.glade
 self.wTree = gtk.glade.XML(self.gladefile)

 #get the Main Window and connect the Destroy event
 self.window = self.wTree.get_widget(MainWindow)
 self.window.show()
 self.window.connect('destroy',gtk.main_quit)
 self.notebook = self.wTree.get_widget(notebook_main)
 self.notebook.show()

 self.menuitem_quit = self.wTree.get_widget(menuitem_quit)
 self.menuitem_quit.connect('activate',self.dialogQuit)

 self.menuitem_newOrg =
 self.wTree.get_widget(menuitem_new_organisation)
 self.menuitem_newOrg.connect('activate',self.show_newOrganisation)
 if __name__ == __main__:
 mm=mainmenu()
 gtk.main()

 Thanks in advance

 Njoy the share of Freedom,
 Anusha

 ___
 Glade-devel maillist  -  glade-de...@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/glade-devel


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

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