Re: [pygtk] importing gtk modifies sys.path

2005-11-03 Thread Jeffery Collins
Almost.  I applied the patch to my 2.4 version; below is output of a 
pychecker call to a file that prints sys.path before and after the gtk 
module import. 


pychecker jnk.py
Processing jnk...

['', '/opt/vexcel/openev2/lib/python24.zip', 
'/opt/vexcel/openev2/lib/python2.4', 
'/opt/vexcel/openev2/lib/python2.4/plat-linux2', 
'/opt/vexcel/openev2/lib/python2.4/lib-tk', 
'/opt/vexcel/openev2/lib/python2.4/lib-dynload', 
'/opt/vexcel/openev2/lib/python2.4/site-packages', 
'/opt/vexcel/openev2/lib/python2.4/site-packages/Numeric', 
'/opt/vexcel/openev2/lib/python2.4/site-packages/gtk-2.0']


['/opt/vexcel/openev2/lib/python2.4/site-packages/pychecker', '', 
'/opt/vexcel/openev2/lib/python24.zip', 
'/opt/vexcel/openev2/lib/python2.4', 
'/opt/vexcel/openev2/lib/python2.4/plat-linux2', 
'/opt/vexcel/openev2/lib/python2.4/lib-tk', 
'/opt/vexcel/openev2/lib/python2.4/lib-dynload', 
'/opt/vexcel/openev2/lib/python2.4/site-packages', 
'/opt/vexcel/openev2/lib/python2.4/site-packages/Numeric', 
'/opt/vexcel/openev2/lib/python2.4/site-packages/gtk-2.0']


Since the pychecker name and '' differ, the delete didn't work.

Is there any reason why we cannot preserve the path through the import?

import sys
_save_path = sys.path[:]
from _gtk import *
sys.path = _save_path
del sys, _save_path

This does work for my limited test cases.



Johan Dahlin wrote:

Jeffery D. Collins wrote:
I don't know if this is normal behavior, but importing gtk causes 
sys.path to be modified.   This holds for both pygtk-2.4.1 and 
pygtk-2.6.x.  The path the python module being run is getting loaded 
into the first postion of sys.path.  This happens normally when 
python is run on a module, but gtk is inserting *another* one.
Why the extra one?   This is particularly problematic for pychecker, 
which modifies the path so that its own internal modules are exposed 
last in sys.path. Some debugging reveals that its the _gtk extension 
module that causes the change, but I was not able to determine where 
the change is being made.


Thanks for reporting this, I just fixed it in CVS.

The problem was that we're calling PySys_SetArgv, because we want to 
remove all options from argv which gtk+ ate up. However PySys_Argv is 
a little stupid and always inserts argv[0] into sys.path.


Can you check and see if it solves your problems?

Thanks

Johan





--
Jeffery D. Collins


___
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] importing gtk modifies sys.path

2005-11-03 Thread Jeffery Collins

Thanks!

Johan Dahlin wrote:

Jeffery Collins wrote:
Almost.  I applied the patch to my 2.4 version; below is output of a 
pychecker call to a file that prints sys.path before and after the 
gtk module import.

pychecker jnk.py
Processing jnk...

['', '/opt/vexcel/openev2/lib/python24.zip', 
'/opt/vexcel/openev2/lib/python2.4', 
'/opt/vexcel/openev2/lib/python2.4/plat-linux2', 
'/opt/vexcel/openev2/lib/python2.4/lib-tk', 
'/opt/vexcel/openev2/lib/python2.4/lib-dynload', 
'/opt/vexcel/openev2/lib/python2.4/site-packages', 
'/opt/vexcel/openev2/lib/python2.4/site-packages/Numeric', 
'/opt/vexcel/openev2/lib/python2.4/site-packages/gtk-2.0']


['/opt/vexcel/openev2/lib/python2.4/site-packages/pychecker', '', 
'/opt/vexcel/openev2/lib/python24.zip', 
'/opt/vexcel/openev2/lib/python2.4', 
'/opt/vexcel/openev2/lib/python2.4/plat-linux2', 
'/opt/vexcel/openev2/lib/python2.4/lib-tk', 
'/opt/vexcel/openev2/lib/python2.4/lib-dynload', 
'/opt/vexcel/openev2/lib/python2.4/site-packages', 
'/opt/vexcel/openev2/lib/python2.4/site-packages/Numeric', 
'/opt/vexcel/openev2/lib/python2.4/site-packages/gtk-2.0']


Since the pychecker name and '' differ, the delete didn't work.

Is there any reason why we cannot preserve the path through the import?

import sys
_save_path = sys.path[:]
from _gtk import *
sys.path = _save_path
del sys, _save_path

This does work for my limited test cases.


Okay, seems simple enough for me. I commited something very similar.

Johan
___
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/



--
-
Jeffery D. Collins, Ph.D.  Vexcel Corp.
Sr. Engineer   1690 38th St.
Voice: (303)583-0228   Boulder, CO 80301
Fax:   (303)583-0246   vexcel.com

___
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] importing gtk modifies sys.path

2005-10-25 Thread Jeffery D. Collins
I don't know if this is normal behavior, but importing gtk causes 
sys.path to be modified.   This holds for both pygtk-2.4.1 and 
pygtk-2.6.x.  The path the python module being run is getting loaded 
into the first postion of sys.path.  This happens normally when python 
is run on a module, but gtk is inserting *another* one. 

Why the extra one?   This is particularly problematic for pychecker, 
which modifies the path so that its own internal modules are exposed 
last in sys.path. Some debugging reveals that its the _gtk extension 
module that causes the change, but I was not able to determine where the 
change is being made.


To demonstrate, this code:

# jnk.py
import sys
print sys.path before:
print sys.path
print sys.argv before:
print sys.argv
print
import gtk
print sys.path after:
print sys.path
print sys.argv after:
print sys.argv
# end

results in:


localhost:tmp$ python `pwd`/jnk.py
sys.path before:
['/home/jcollins/tmp', '/opt/local/lib/python24.zip', 
'/opt/local/lib/python2.4', '/opt/local/lib/python2.4/plat-linux2', 
'/opt/local/lib/python2.4/lib-tk', 
'/opt/local/lib/python2.4/lib-dynload', 
'/opt/local/lib/python2.4/site-packages', 
'/opt/local/lib/python2.4/site-packages/Numeric', 
'/opt/local/lib/python2.4/site-packages/gtk-2.0', 
'/opt/local/lib/python2.4/site-packages/vtk_python']

sys.argv before:
['/home/jcollins/tmp/jnk.py']

sys.path after:
['/home/jcollins/tmp', '/home/jcollins/tmp', 
'/opt/local/lib/python24.zip', '/opt/local/lib/python2.4', 
'/opt/local/lib/python2.4/plat-linux2', 
'/opt/local/lib/python2.4/lib-tk', 
'/opt/local/lib/python2.4/lib-dynload', 
'/opt/local/lib/python2.4/site-packages', 
'/opt/local/lib/python2.4/site-packages/Numeric', 
'/opt/local/lib/python2.4/site-packages/gtk-2.0', 
'/opt/local/lib/python2.4/site-packages/vtk_python']

sys.argv after:
['/home/jcollins/tmp/jnk.py']


Running pychecker on the same:

localhost:tmp$ pychecker jnk.py
Processing jnk...
sys.path before:
['', '/opt/local/lib/python24.zip', '/opt/local/lib/python2.4', 
'/opt/local/lib/python2.4/plat-linux2', 
'/opt/local/lib/python2.4/lib-tk', 
'/opt/local/lib/python2.4/lib-dynload', 
'/opt/local/lib/python2.4/site-packages', 
'/opt/local/lib/python2.4/site-packages/Numeric', 
'/opt/local/lib/python2.4/site-packages/gtk-2.0', 
'/opt/local/lib/python2.4/site-packages/vtk_python']

sys.argv before:
['/opt/local/lib/python2.4/site-packages/pychecker/checker.py', 'jnk.py']

sys.path after:
['/home/opt/local/lib/python2.4/site-packages/pychecker', '', 
'/opt/local/lib/python24.zip', '/opt/local/lib/python2.4', 
'/opt/local/lib/python2.4/plat-linux2', 
'/opt/local/lib/python2.4/lib-tk', 
'/opt/local/lib/python2.4/lib-dynload', 
'/opt/local/lib/python2.4/site-packages', 
'/opt/local/lib/python2.4/site-packages/Numeric', 
'/opt/local/lib/python2.4/site-packages/gtk-2.0', 
'/opt/local/lib/python2.4/site-packages/vtk_python']

sys.argv after:
['/opt/local/lib/python2.4/site-packages/pychecker/checker.py', 'jnk.py']
 ImportError: No module named _gobject

--
-
Jeffery D. Collins, Ph.D.  Vexcel Corp.
Sr. Engineer   1690 38th St.
Voice: (303)583-0228   Boulder, CO 80301
Fax:   (303)583-0246   vexcel.com



___
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] invalidating gui

2002-07-07 Thread Collins

On Sat, 6 Jul 2002 22:02:27 -0700 (PDT) icewind [EMAIL PROTECTED]
wrote:
 I have a couple of threads updating the gui (adding
 lines to a CList, changing text in a textentry area,
 etc.) The problem is, the widget that was changed
 doesnt show its updates until some event occurs such
 as me moving or clicking the mouse into the
 applications window. I would like the gui updated
 continuously as the threads actually manipulate the
 widgets.
 
 So, I assume this could be done by calling an
 invalidate function that will tell gtk that some
 widget needs to be redrawn. If this is how to do what
 I want, what is the name of the function/method I have
 to call, and is it something I have to apply to just
 the widget that was changed or to the window the
 widget is in or something else?

 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

I got this little nugget from someone on the list a month or two back.

 while events_pending():# suggested by pygtk users
mainiteration(FALSE)



-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-galeon
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] text and fonts

2002-06-08 Thread Collins

I'm using a gtk rc file to set colors and fonts for various
compotents.  Most everything is working ok, but I can't seem to get
fonts to take effect.  The only one that seems to be recognized is
bitstream-charter.  All of the other common fonts honor the font size
(somewhat), but the display is a broken font of some sort that gets
more unreadable as font size increases (bold is ignored).

Any ideas what might be going on here?

I've tried removing some of the font libraries from the X config, but
that seems to have no effect.

-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] BG Color for GtkCList

2002-06-07 Thread Collins

How can I set the bg color for a CList widget?

If my gtkrc file contains, for example

widget_class *GtkEntry style text

the bg colors in text will be honored.

but if I code

widget_class *GtkCList style text

this will be ignored

I even tried putting the CList in a GtkEventBox and setting the style
in code.

Nothing seems to affect CList - it's always dazzling white


-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] A few simple questions

2002-06-06 Thread Collins

1. I have a gui compile tool that presents a dialog box(do you want to
rename temporary file?) that appears when each operation completes. 
Howdo I make this dialog box obtain complete control so that the user
cannot continue use of the main window until the question in the
dialog has been answered?

2.  How do I obtain the current geometry settings (really just the top
left corner) of the main window so that I can position the dialog box
to overlay the main window?

3.  Even though I use clist.freeze(), update the clist,
clist.unthaw(), I get a lot of screen flickering.  Any idea how to
control this?

TIA,
-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] Dialog Box geometry

2002-06-01 Thread Collins

I have a dialog box that I want to open over the middle of my current
window?  How do I accomplish this?

At present, gtk maps this window to the next available space on the
screen, where it is not obvious that it is related to my current
window.

-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] clist refresh view

2002-05-31 Thread Collins

I'm using a clist as a display window for background tasks.  While the
task is running, output is captured (compiles, for example) and
written to a temporary file and the output is also written to the
screen (when over 30 lines, row zero is removed before inserting new
data at the bottom.

Unfortunately, the data only appears after all is said and done (the
command has run to completion).  How can I make the data appear as it
is added to the clist?  Once full, the clist should appear as a
continuously scrolling window with new data appearing at the bottom
and old data removed at the top.

-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] Window sizing controls

2002-05-27 Thread Collins

What are the proper controls to use with windows and the various child
widgets to allow everything to resize automatically.

I'm using a main window and a notebook with (at least) 3 static tabs. 
Each tabe has a radio buttons box at the top and a clist in a
scroolled window widget at the bottom that receives variable data

Right now I'm using no sizing on the main window and the scrolled
window has set_usize(100,380) and the clist has set_usize(94,8000). 
The value 8000 has to be larger than the number of items I insert into
the clist, or the scrolled window can't reach all of the items.

What would be a better way to do this?

-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] gtk rc files

2002-05-27 Thread Collins

I'm setting up an application that will be packaged for general use,
and I would like to have one or more rc files to control the default
settings (styles and default directories, among others).

Is it possible to include non-gtk-related items in a gtk rcfile that
is processed by rc-parse()?  Are there standard methods for parsing
the additional values I put in the file?


-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] Notebook tab functions

2002-05-26 Thread Collins

This is more of a python question than a pygtk question, but I've been
unable to sort it out with my python books and several google
searches.

I have created a notebook than creates two tabs to display the
contents of two different directory structures (installed packages and
packages available for install).  Each tab is identical except for the
need to bind to different methods to handle the different directory
structure for each.

Right now I have the code duplicated to create each tab, and all is
cool, but it would be nice to be able to collapse the duplicated code
into a common function that I can invoke with the actual connection
functions passed in.

Is there a way to code a python function that receives an object that
can be invoked in that function,  i.e. the equivalent of passing in a
pointer to funtion in C code and invoking that function or passing its
address to another function.

Something like the following code snippet.

def callback(widget,entry) :
  pass

def function(rtn1) :
  . . .
  b2 = GtkRadioButton(label=Full list)
  b2.connect(pressed, rtn1, b2)
  ...

...
function(callback)
...



-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] Radio Box Buttons

2002-05-21 Thread Collins

How does one group radio buttons to allow only one concurrent button
to be depressed.  GtkRadioButton() has a group= parameter that
defaults to None, but I can't find a GtkGroup() or anything that lets
me group the buttons.

TIA,
-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] Radio button plus editable text

2002-05-21 Thread Collins

Is there any easy way to get something like the following:

  --  --  
-
|  | Choice 1   |  |  Choice 2  |(Editable text)  
|  |  |
  --  --  
-

Choice 1 and 2 are radio buttons (mutually exclusive), but Choice 2
has text (search string) to be entered.


-- 
Collins Richey - Denver Area - WWTLRD?
gentoo(since 01/01/01) 2.4.18+(ext3) xfce-sylpheed-mozilla
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/