Re: [pygtk] TreeView problem, really simple program

2010-02-02 Thread Alessandro Dentella
On Tue, Feb 02, 2010 at 10:03:37AM -0600, Chris Gonnerman wrote:
> I'm writing a script to scan a folder for files, retrieve the version 
> information via Win32 API calls, and display the results in a sortable 
> list.  I've gotten partway into the process (reading the directory and 
> filling in the TreeView with names and blank fields) but the filenames 
> never appear on my screen... the rows are there, but they are entirely 
> blank.
> 
> But if I add a hack to the code to retrieve the value of a column and 
> print it, it appears in the console window where I started the script 
> (much as I expect it to).  So the filename is there, but it's not appearing.
> 
> I've missed something elementary, I know, but I don't know what it is, 
> and the examples I've been looking at are not terribly clear.  Perhaps 
> someone can tell me what I've done wrong?

you forgot to specify the source of data for the CellRenderer, you do that
when you create the column and is the index of the column in the model where
is should read the data:

self.programview.append_column(
   gtk.TreeViewColumn(allflds[i], gtk.CellRendererText(), text=i))

namely you forgot to add text=i


ciao
sandro
*:-)

-- 
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] can a treeview be reordered with a CellRendererToggle present

2010-02-02 Thread Pietro Battiston
Il giorno mar, 02/02/2010 alle 16.08 -0800, Yeates, Mathew C (388D) ha
scritto:
> I have a CellRendererToggle and CellRendererToggle packed in a column
> and cannot reorder. However, if I don’t pack the CellRendererToggle
> then I can’t.
> 
>  
> 
>  
> 
> Any clues or example code showing this?
> 
>  

I humbly suggest that you rephrase your problem more clearly, perhaps
providing a simple and running snippet exposing it.

Pietro


___
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] TreeView (liststore) sorting.

2010-02-02 Thread Pietro Battiston
Il giorno mar, 02/02/2010 alle 22.59 +0100, middleofdre...@gmail.com ha
scritto:
> I was looking for this in net but still i have no idea how to set
> priority of sorting. For example i'm doing:
>  somelistmodel.set_sort_column_id(0,gtk.SORT_ASCENDING) and it sort it
> right. But when elements in column 0 are the same, a want to sort by
> column 1.
>  How to?
> I've tried
> somelistmodel.set_sort_column_id(1,gtk.SORT_ASCENDING)
> somelistmodel.set_sort_column_id(0,gtk.SORT_ASCENDING), but that
> doesn't work.
> 

http://www.pygtk.org/docs/pygtk/class-gtktreesortable.html#method-gtktreesortable--set-sort-func

I strongly suggest using devhelp and taking a look at the page of the
classes you happen to use: even by a fast glance, you can learn many
things.

Pietro

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


[pygtk] can a treeview be reordered with a CellRendererToggle present

2010-02-02 Thread Yeates, Mathew C (388D)
I have a CellRendererToggle and CellRendererToggle packed in a column and 
cannot reorder. However, if I don't pack the CellRendererToggle then I can't.


Any clues or example code showing this?


Mathew
___
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] Keyboard Events Issue

2010-02-02 Thread middleofdre...@gmail.com
2010/2/2 Andy B 

> Hi,
>
> Not sure whether this is a pygtk or a gtk issue, but...
>
> I've written an app which relies on key-press and key-release events.
>  Under windows XP, python 2.6, pygtk 2.16 and gtk+ 2.18 there are no
> problems, however under ubuntu 9.10 (32 & 64bit) I'm seeing a key-release
> event following each key-press event whilst a key is held down.


Maybe something with system configuration? IDK but on Arch:
key press= D
key press= D
key press= D
key press= D
key press= D
key press= D
key press= D
key release= D

When i'm holding 'D' down and then release.
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

[pygtk] Keyboard Events Issue

2010-02-02 Thread Andy B

Hi,

Not sure whether this is a pygtk or a gtk issue, but...

I've written an app which relies on key-press and key-release events.  
Under windows XP, python 2.6, pygtk 2.16 and gtk+ 2.18 there are no 
problems, however under ubuntu 9.10 (32 & 64bit) I'm seeing a 
key-release event following each key-press event whilst a key is held down.


I've attached a small test case to demonstrate.

I've been scratching my head over this one for a while & can't figure it 
out...


TIA,

Andy


#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import os
import sys

#gtk
import pygtk
if sys.platform != 'win32':
pygtk.require('2.0')
import gtk
import gobject


class WinTest:
"""Main Window"""

def __init__(self):
"""test"""
#build the window
self.winMain = gtk.Window()
#set window properties
self.winMain.set_events(
gtk.gdk.KEY_PRESS_MASK |
gtk.gdk.KEY_RELEASE_MASK)
print "events=",self.winMain.get_events()
self.winMain.connect('key-press-event', self.on_winMain_key_press)
self.winMain.connect('key-release-event', self.on_winMain_key_press)
self.winMain.connect('delete-event', self.on_winMain_delete_event)
self.winMain.set_size_request(300, 400)
self.winMain.show()

def on_winMain_key_press(self, widget, event, *args):
"""handle keyboard events"""
keyname = gtk.gdk.keyval_name(event.keyval).upper()
if event.type == gtk.gdk.KEY_PRESS:
if keyname == 'ESCAPE':
self.on_winMain_delete_event()
else:
print "key press=", keyname
elif event.type == gtk.gdk.KEY_RELEASE:
print "key release=", keyname
return False

def on_winMain_delete_event(self, *args):
"""done, quit the application"""
#exit gtk loop
gtk.main_quit()
return False


if __name__ == '__main__':
#instantiate main GUI window class
app = WinTest()
#and... go...
gtk.main()
___
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] gtk.Window [ popup from TextView ]

2010-02-02 Thread middleofdre...@gmail.com
2010/1/31 M.B. 

> hi all,
> please help me with little problem [ the big one for me right now :(]
> i write little app [ texteditor , who not :) ]
>
> from textview i call window popup with help. [pressing 'a' in test
> prog ] and i have 2 questions.
>
> 1.) how i disable automatic Tab inserted after pasting text from popup ?
>use another key is solution but i want Tab as completer.
>
> 2.) it seems to same prob as in 1.) but how i disable moving cursor in
>textbuffer when popup window is active and i changing rows in
>treeview ? when i change type on WINDOW_TOPLEVEL my treeview has
>focus and i cannot write into buffer.
>
> Ad1 - I don't know if is right solution but you have create simple function
on signal "text-inserted"-  if text is tab - buffer.backspace(). I'm doing
something like that with enter key.

Ad2. I'm not sure here either but you can set sensitive to 0 when popup
comes, and set to 1 when you close it.
___
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] gtk.Window [ popup from TextView ]

2010-02-02 Thread M.B.
V Sun, 31 Jan 2010 21:51:36 +0100
"M.B."  napsáno:

> hi all,
sorry for bothering with this. i completelly read whole faqs :) and
rewrite returning values in next() and previous() method from False to
True. this is my problem. same with Tab key ;P


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


[pygtk] TreeView (liststore) sorting.

2010-02-02 Thread middleofdre...@gmail.com
I was looking for this in net but still i have no idea how to set priority
of sorting. For example i'm doing:
 somelistmodel.set_sort_column_id(0,gtk.SORT_ASCENDING) and it sort it
right. But when elements in column 0 are the same, a want to sort by column
1.
 How to?
I've tried
somelistmodel.set_sort_column_id(1,gtk.SORT_ASCENDING)
somelistmodel.set_sort_column_id(0,gtk.SORT_ASCENDING), but that doesn't
work.

I hope i'm clear enough
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

[pygtk] TreeView problem, really simple program

2010-02-02 Thread Chris Gonnerman
I'm writing a script to scan a folder for files, retrieve the version 
information via Win32 API calls, and display the results in a sortable 
list.  I've gotten partway into the process (reading the directory and 
filling in the TreeView with names and blank fields) but the filenames 
never appear on my screen... the rows are there, but they are entirely 
blank.

But if I add a hack to the code to retrieve the value of a column and 
print it, it appears in the console window where I started the script 
(much as I expect it to).  So the filename is there, but it's not appearing.

I've missed something elementary, I know, but I don't know what it is, 
and the examples I've been looking at are not terribly clear.  Perhaps 
someone can tell me what I've done wrong?

(I'm testing on my Ubuntu system at this stage, but without the Win32 
calls, it should still work.)

---

#!/usr/bin/env python

import os, sys, stat

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

verinfoflds = [
"CompanyName",
"FileDescription",
"FileVersion",
"InternalName",
"LegalCopyright",
"LegalTrademarks",
"OriginalFilename",
"PrivateBuild",
"ProductName",
"ProductVersion",
"SpecialBuild",
"Comments",
]

allflds = [ "FileName", ] + verinfoflds

def loadfiles(model):
fnames = os.listdir(".")
for fn in fnames:
if not stat.S_ISDIR(os.stat(fn)[stat.ST_MODE]):
# get the info
# stubbed for testing
row = [ fn ] + ([ "" ] * len(verinfoflds))
iter = model.append(row)

class MainWindow:

def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False

def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("List Programs")
self.window.connect("delete_event", self.delete_event)
self.window.set_border_width(2)
types = tuple([ 'gchararray' ] * len(allflds))
self.programmodel = gtk.ListStore(*types)
self.programview = gtk.TreeView(model = self.programmodel)
self.window.add(self.programview)
self.programview.set_headers_clickable(True)
self.programview.set_reorderable(True)
for i in range(len(allflds)):

self.programview.append_column(gtk.TreeViewColumn(allflds[i], 
gtk.CellRendererText()))
loadfiles(self.programmodel)
self.programview.show()
self.window.show()

if __name__ == "__main__":
hello = MainWindow()
gtk.main()


___
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] gtk Assitant, and pages

2010-02-02 Thread Nico
Nico a écrit :
> Hi,
> I' m facing some troubles in usage of gtk.assistant with pygtk.
>
> In some cases , when user enter invalid data for example, I want to stay
> in the same page.
>
> So in that case on the 'page_func' callback I return the same page
> number as the input ( i.e Im' in page 1, data on page 1 is invalid, so I
> return 1)
>  
> But when I click on next button the displayed page is blank, and if I
> reclick next I go to to thesame page . ( i.e. Page 1 is displayed
> correctly Then I click next ,  The page display is blank, Page Id
> remains 1, If I click next again, the content of page 1 is displayed again )
>
> Does somebody have an idea what kind of problem is ?
> Or in gtk.assitant philosophy there is no way to stay in the same page ?
> So I need to do all the user data verification before user click on next
> button ?
>
> Thanks for the help
> Nico
> ___
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
>
>   
A code example is available here : http://pastebin.com/m19964865

The example waits to enter 'next' on the first page to continue

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


[pygtk] gtk Assitant, and pages

2010-02-02 Thread Nico
Hi,
I' m facing some troubles in usage of gtk.assistant with pygtk.

In some cases , when user enter invalid data for example, I want to stay
in the same page.

So in that case on the 'page_func' callback I return the same page
number as the input ( i.e Im' in page 1, data on page 1 is invalid, so I
return 1)
 
But when I click on next button the displayed page is blank, and if I
reclick next I go to to thesame page . ( i.e. Page 1 is displayed
correctly Then I click next ,  The page display is blank, Page Id
remains 1, If I click next again, the content of page 1 is displayed again )

Does somebody have an idea what kind of problem is ?
Or in gtk.assitant philosophy there is no way to stay in the same page ?
So I need to do all the user data verification before user click on next
button ?

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