pygtk treview, ListStore not displaying properly
hi group i am running into a problem with gtk. i have a treeview that
just displays tabular data (no down arrows or trees etc). it has 5
columns. The tiny problem i am having is that it is just display the
data of the column named `title` in all the colums!
here the pic of the app in action
http://i36.tinypic.com/2djcqqr.png
the related code of the app is as follows:
self.tv = self.glade.get_widget('treeview1') #the treeview object
def show_sync_wind(self,obj, data = None):
t = Template.select(Template.q.synced == '0')
self.synclstore = gtk.ListStore(str,str,str,str,str)
x = 0
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('#', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(0)
self.tv.append_column(col)
self.sno_col = col
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Title', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(1)
self.tv.append_column(col)
self.title_col = col
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Section', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(2)
self.tv.append_column(col)
self.section_col = col
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Category', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(3)
self.tv.append_column(col)
self.category_col = col
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Sync', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(4)
self.tv.append_column(col)
self.sync_col = col
self.tv.set_model(self.synclstore)
self.tv.set_headers_clickable(True)
#self.tv.set_expander_column(self.title_col)
for y in t:
row =
self.synclstore.append([str(x),y.title,y.section.name,y.category.name,y.synced])
self.synclstore.set(row,0,'0')
self.synclstore.set(row,1,y.title)
self.synclstore.set(row,2,y.section.name)
self.synclstore.set(row,3,y.category.name)
self.synclstore.set(row,4,y.synced)
self.sync_window.show()
--
http://mail.python.org/mailman/listinfo/python-list
Re: pygtk treview, ListStore not displaying properly
finally i solved it. This for any googler who comes this way
def show_sync_wind(self,obj, data = None):
t = Template.select(Template.q.synced == '0')
self.synclstore = gtk.ListStore(str,str,str,str,str)
x = 0
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('#', cr);
col.set_attributes(cr, text=0)#<-- attaches col to the 0`th
item
of liststore
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(0)
self.tv.append_column(col)
self.sno_col = col
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Title', cr);
col.set_attributes(cr, text=1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(1)
self.tv.append_column(col)
self.title_col = col
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Section', cr);
col.set_attributes(cr, text=2)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(2)
self.tv.append_column(col)
self.section_col = col
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Category', cr);
col.set_attributes(cr, text=3)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(3)
self.tv.append_column(col)
self.category_col = col
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Sync', cr);
col.set_attributes(cr, text=4)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(4)
self.tv.append_column(col)
self.sync_col = col
self.tv.set_model(self.synclstore)
self.tv.set_headers_clickable(True)
#self.tv.set_expander_column(self.title_col)
for y in t:
x = x+1
row =
self.synclstore.append([str(x),y.title,y.section.name,y.category.name,y.synced])
self.sync_window.show()
--
http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Python questions
One great open source GUI package that you left out is GTK ie. pygtk. i cant compare it with wx as i have never used it but isay its much better than QT. Anyway for ur q if u want to compair qt n wx. QT should be faster coz it has a better documentation. and welcome to the python family! kind regards binaryjesus On Jul 31, 12:10 pm, Tim Roberts <[EMAIL PROTECTED]> wrote: > LessPaul <[EMAIL PROTECTED]> wrote: > > >...My > >question is in regard to GUI platforms. My primary target would be > >Windows, but I would also like be able to support Linux and Mac > >versions if possible. I'm also interested in using a system that also > >has support for pure C++ applications. As such, and after reading many > >web pages regarding Python GUIs, I believe I have the candidates > >narrowed down to pyQT and wxPython. > > >The first question -- how steep is the curve to become proficient with > >the above GUI packages? > > There is so much personal preference here that it is extremely hard to give > any guidance. If you have done any Windows programming at all, so that you > are familiar with the event-driven programming model, then I don't think > you would see that much difference in learning curve. The two packages are > more alike than they are different -- the various APIs are just spelled > differently. > > I happen to be a big wxPython fan. I learn best by example, and wxPython > has a 44,000-line demo suite with 167 source files that demonstrates > virtually every class it includes. > > >Since there appears to be no commercial licencing fee for wxWidgets/ > >wxPython, the last question is what do I gain from going QT over wx? > >I've seen great applications written with both (on my computer I have > >the wxPython Digsby and the pyQT apps "Mnemosyne" and "Anki". All seem > >to be solid. > > Yep. Personal preference. > -- > Tim Roberts, [EMAIL PROTECTED] > Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
why goes the time change after import statement ?
hi i am working on a S3 project and facing a really weird problem!
take a look at the following import statements and the time output
>>> import time
>>> time.strftime("%a, %d %b %Y %X GMT", time.gmtime())
'Sat, 02 Aug 2008 20:21:56 GMT'
# OK
>>> import pygtk
>>> time.strftime("%a, %d %b %Y %X GMT", time.gmtime())
'Sat, 02 Aug 2008 20:22:04 GMT'
# OK
>>> import gtk
>>> time.strftime("%a, %d %b %Y %X GMT", time.gmtime())
'Sat, 02 Aug 2008 08:22:11 PM GMT'
# HOW THE HELL THIS HAPPEN ??? not DATE_RFC2822 format gmt time !
i have waisted 3 hours trying to locate the source of this strange
problem.
so what i am asking is does anyone know to overwrite or fix the
defaurl behaviour strftime()
--
http://mail.python.org/mailman/listinfo/python-list
Re: why goes the time change after import statement ?
On Aug 3, 1:46 am, Paul Hankin <[EMAIL PROTECTED]> wrote:
> On Aug 2, 10:35 pm, binaryjesus <[EMAIL PROTECTED]> wrote:
>
>
>
> > hi i am working on a S3 project and facing a really weird problem!
> > take a look at the following import statements and the time output
>
> > >>> import time
> > >>> time.strftime("%a, %d %b %Y %X GMT", time.gmtime())
>
> > 'Sat, 02 Aug 2008 20:21:56 GMT'
>
> > # OK
>
> > >>> import pygtk
> > >>> time.strftime("%a, %d %b %Y %X GMT", time.gmtime())
>
> > 'Sat, 02 Aug 2008 20:22:04 GMT'
>
> > # OK
>
> > >>> import gtk
> > >>> time.strftime("%a, %d %b %Y %X GMT", time.gmtime())
>
> > 'Sat, 02 Aug 2008 08:22:11 PM GMT'
>
> > # HOW THE HELL THIS HAPPEN ??? not DATE_RFC2822 format gmt time !
>
> Reading the manual page for strftime
> --http://docs.python.org/lib/module-time.html
> -- says that '%X' is the locale's appropriate time representation, so
> obviously gtk is adjusting your locale. Perhaps use a formatting
> string that doesn't depend on the locale: '%H:%M:%S' instead of '%X'
> seems to give your preferred format.
>
> --
> Paul Hankin
ok that explain it.
but what command does gtk runs that it sets the default behaviour of
strfime() to that ?
--
http://mail.python.org/mailman/listinfo/python-list
Re: SMTP via GMAIL
i have a lot of experience in gmail. i use it to store 100GB's of server backup on it. the form: field will be equal to the gmail acc u login with. you are not clear with ur cc: so i cant offer any help on it. but u can include multiple addresses in the To: and use Bcc: since python doesnt include bcc in sendmail but there is a hacky method to do that to ='[EMAIL PROTECTED] \n\rBcc: [EMAIL PROTECTED]' snedmail(from,to,mail) this hack is also known as header injection attack On Aug 3, 2:36 am, mmm <[EMAIL PROTECTED]> wrote: > After reading about and using the smtplib module, I thought code such > as below would ignore the 'Cc: ' body line below when sending messages > and instead simply use the RECEIVERS list > > session = smtplib.SMTP(SMTPserver,port) > session.set_debuglevel(1) > session.ehlo(SMTPuser) # say hello > session.starttls() # TLS needed > session.ehlo(SMTPuser) # say hello again > session.login(SMTPuser, pw) > > FROM=SENDER > RECEIVERS= (TO,CC) > > BODY= MakeBody(FROM,TO,CC,SUBJECT,MESSAGE) > SMTPresult = session.sendmail(SENDER, RECEIVERS, BODY) > > Here the MakeBody() creates text like below > > From: FROM > To: TO > Cc: CC > Subject: SUBJECT > > MESSAGE > > But when using smtp.gmail.com as the server I learned that any > @gmail.com address in the Cc: text block would > receive mail even if I changed the code to have the RECEIVERS list to > ignore the CC addresses or not include the gmail address in the CC > list as below > > RECEIVERS= (TO,) > BODY= MakeBody(FROM,TO,CC,subject,message) > SMTPresult = session.sendmail(SENDER, RECEIVERS, BODY) > > Other @zzz.com CC addresses need to be in the RECEIVERS list however. > > Also the gmail server changes the 'From: ' text to be the same as > SENDER even if this is modified (a case not using FROM=SENDER. I > found other servers send mail that displays the BODY specified From: > address. > > Is this gmail specific or a quirk of the smtplib functions? > I understand how Google might not want to send mail with FROM not = > SENDER, but the CC behavior baffles me. > > And does anyone have a general routine that lets one also have Bcc: > addresses usign SMTP? -- http://mail.python.org/mailman/listinfo/python-list
Re: File reading across network (windows)
On Aug 12, 8:48 am, "Prof. William Battersea" <[EMAIL PROTECTED]> wrote: > Hello, > > Suppose I have a Vista machine called VISTA and an XP machine called > XP in a workgroup named WORKGROUP. Physically they're connected to a > router and I can see lists of public and shared files on each of them. > How do I address these for IO? > > A search suggested that the form open(r"\\server\folder\folder"), but > I tried many combinations guessing what it wants for that path in my > case (r"\\WORKGROUP\VISTA", "\\VISTA\PUBLIC", etc), and none have > worked so far. > > Thanks! Does the remote folder require authentication? Maybe you could map a network drive and then access files using (z:/VISTA-FOLDER/ ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Read from serial port
On Aug 14, 6:11 am, [EMAIL PROTECTED] wrote: > Hi, > I am newbie in python. I am working on Telit GM862 GPS/GPRS module > which has python interpreter built in. But it seems this problem is > pretty much related to general python structure. > > I need a promt/terminal when the device is connected to PC. If user > enters a command by serial port and press "Enter" then the data is > read by the device and work on the command. This is similar to > readline() function. Unfortunately there is no readline() function for > GM862 device. The following functions are available for serial port > data receive- > > SER.read() - reads whole string at a time from buffer > SER.receive(timeout) - reads if there is any input in the buffer > andwait for the input upto timeout > SER.receivebyte(timeout) - reads if there is any byte sent in the > buffer and wait for the input upto timeout > > Now, is this possible to build a readline() using the functions above? > Can I redirect the terminal or serial port data to receive it as a > whole string when entered "\n"? > > Please advise me how can I solve this problem. > > Thanks a lot. Well i dont think its much of a problem. What i think you should be doing is to read the data into a secondary buffer. it could be a simple string or a specialized buffer class. You would need a method to update() this secondary buffer. ie read from port and append the read data to our buffer. That done you can easily make a readline function. lol i think even a 15yr old can make a readline() from here. btw does ur gm862 support multiple thread? if yes u can put the update() function code and also a method launcher when ever a particular command is sent to the device using a serial connection! hope it helps ! BJ -- http://mail.python.org/mailman/listinfo/python-list
Porting a pygtk app to Windows
hi everyone,
first of all
I had written an app using pygtk module and created the GUI with
glade.All the development was done on a linux machine and the app was
working fine all this tme in linux.
now, the thing is i have to change the development environment to
windows. So this means that i have to port the application to work in
windows.
Initially i thought that porting an application written using a
platform independent language and cross-platform window frame work
would be a piece of cake. Well i guess all the assumptions end there.
unlike linux, in windows pygtk and the GTK frame work are not
installed by default.
So, long story short. i installed GTK devel, pygtk, pygobject, pycaro,
glade ui. Also made a lot of path adjustments (os.path.absolutepath()
is not portable i guess) and finally got the app to at least start
without showing an error.
The problem that i am now facing is that nothing shows up in the app.
No menu, buttons, frames or anything else is visible. When i move the
cursor over the window it changes into an hour-glass type icon. hoe
ever all c++ GTK programs seem to render well.
here is a screen shot: http://i36.tinypic.com/x52uk9.jpg
i have written below the startup code of the app:
import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade
from ConfigParser import ConfigParser
class jDesk(object):
def __init__(self):
#self.seclstore.append(["0","Section1"])
#self.catlstore.append(["cat 1"])
self.synclstore = gtk.ListStore(str,str,str,str,str,int)
self.seclstore = gtk.ListStore(str,str)
self.catlstore = gtk.ListStore(str,str)
self.process_glade()
def process_glade(self):
self.gladefile = "gui.glade"
self.glade = gtk.glade.XML(self.gladefile)
#windows
self.main_window = self.glade.get_widget('MainWindow')
#main window
self.templatefile = self.glade.get_widget('templatefile')
self.imageurl = self.glade.get_widget('imageurl')
self.posttitle = self.glade.get_widget('posttitle')
self.sectionbox = self.glade.get_widget('sectionbox')
self.categorybox = self.glade.get_widget('categorybox')
self.demolink = self.glade.get_widget('demolink')
self.posttext = self.glade.get_widget('posttext')
self.statusbar = self.glade.get_widget('statusbar')
self.signal_autoconnect()
self.main_window.show()
print '===main wind created='
def run(self):
try:
print "Entering GTK main now"
gtk.main()
print "Leaving GTK main"
except:
print "Exception in main"
if __name__ == "__main__":
conf = ConfigParser()
conf.read('settings.cfg')
gtk.gdk.threads_init()
app = jDesk()
app.run()
i have tried a lot of things, checked up paths, checked libcairo but
nothing seems to help.problem seems to be with pygtk since other c++
GTK programs like pedgin and GTK demo rn fine.
So maybe is there any pygtk windows bugs that i coming from linux
background might not be knowing about or perhaps u have encountered
such a problem in the past before ?
Much thanks in advance
BinaryJ
--
http://mail.python.org/mailman/listinfo/python-list
Re: parse a midi file
On Sep 16, 9:48 pm, Mr.SpOOn <[EMAIL PROTECTED]> wrote: > Hi, > I need to parse a midi file with Python. What I exactly need is the > possibility to distinguish all notes in all channels in a midi file > and put them in a list or something. > > I've found this: > > http://groups.google.com/group/alt.sources/msg/22467419ad4bf416 > > I'm not sure how it does work, but looking at the code I saw it can > get input from the terminal, so I tried: > > python midi.py < mymidi.mid > > All it does is printing a lot of strange symbols. > > Do you know other easy way to parse a midi file in Python? Or how > actually does this module work? > > Thanks, > Carlo hi, just looked at the code. try this python midi.py -i mymidi.mid to see all the debug information do python midi.py -p -d -i mymidi.mid -- http://mail.python.org/mailman/listinfo/python-list
