Re: [pygtk] Sharing a CellRenderer among two or more columns
Stéphane Brunet wrote: Hi, I am working on TreeViews using a ListStore model but I couldn't find any answer on this yet: Say I have a ListStore with 4 columns containing strings. They are all be rendered by a CellRendererText object in a separate TreeViewColumn. I have tried to use a single instance of CellRendererText assigned to each TreeViewColumn and it worked great. However, when I want to make each column editable, how do I specify the callback function to the CellRendererText object so that it will know in which column to put the new text ? Am I compelled to use a separate instance of CellRendererText for each column ? That's probably the only way - you have to determine which column from the cellrenderertext to set the right value in the liststore. With a single cellrenderetext you can't tell which column has been edited. John ___ 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] Label a different font sizes
Vláďa wrote: Thank you for your reply. I know I have to use "set_use_markup(True)". All of the Pango markup attributes work for me except of font size. At the top of the page you are referring there is an example: Blue text So I think my code is correct. The problem is, that the first value (size="14") in my example is also used for the second line, although I specified new size (size="10"). The strange thing is that if I use attributes like "large" or "small" then it works. Unfortunately my English is rather weak, so I'm not sure if I can explain it clearly. Here is a short sample code to show the problem: I used the line self.label = gtk.Label('size="2">Texting\nTexting\nsize="small">Text 3') Everything worked how it should Ubuntu 7.10 (gutsy) Gnome 2.10.1 Kernel 2.6.22-14-generic Python 2.5.1 Regards Neil. #!/usr/bin/env python import pygtk pygtk.require('2.0') import gtk import pango class HelloWorld: def hello(self, widget, data=None): print "Hello World" def delete_event(self, widget, event, data=None): print "delete event occurred" return False def destroy(self, widget, data=None): print "destroy signal occurred" gtk.main_quit() def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) self.window.set_border_width(10) self.button = gtk.Button() self.label = gtk.Label('Text 1\nsize="10">Text 2\nText 3') self.label.set_use_markup(True) self.button.add(self.label) self.button.connect("clicked", self.hello, None) self.button.connect_object("clicked", gtk.Widget.destroy, self.window) self.window.add(self.button) self.window.show_all() def main(self): gtk.main() if __name__ == "__main__": hello = HelloWorld() hello.main() The button label has 3 lines, the first 2 have size 14, the last one is small. But the second line should have size 10. What is wrong in my code? Thank you John Finlay napsal(a): Vláďa wrote: Hi, I have a question regarding labels and Pango. I want to use different sizes of font, but unfortunately it doesn't work. If I use self.label = gtk.Label('Text 1\nsize="10">Text 2') then only the first size definition (14) is taken into account. The second line has the same font size. Is this a feature, bug or my fault? Hot to create a label with different font sizes in it? First you have to tell the label to use Pango markup: self.label.set_use_markup(True) Then you have to specify a readable size since numerical sizes are in thousandths of a point - see: http://www.pygtk.org/docs/pygtk/pango-markup-language.html John ___ 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] Sharing a CellRenderer among two or more columns
Hi, I am working on TreeViews using a ListStore model but I couldn't find any answer on this yet: Say I have a ListStore with 4 columns containing strings. They are all be rendered by a CellRendererText object in a separate TreeViewColumn. I have tried to use a single instance of CellRendererText assigned to each TreeViewColumn and it worked great. However, when I want to make each column editable, how do I specify the callback function to the CellRendererText object so that it will know in which column to put the new text ? Am I compelled to use a separate instance of CellRendererText for each column ? Thank you, Stéphane ___ 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] Automatic actions and gtk.FileChooserButton
Marcus Vinicius Eiffle Duarte wrote: Hi, folks! Sorry if this question seems silly, but I am rather new to python and a total newbie regarding Gtk programming, I googled a lot for a solution to my problem and couldn't find something that worked for me. I created a GUI using Glade, which contains a FileChooserButton. On startup, this FileChooserButton displays the default folder for the application, and a list of text files contained in this folder is loaded and presented in a TreeView. My idea is, everytime the user chooses another folder using the FileChooserButton, the application automatically loads the list of text files in this new folder and refreshes the TreeView to show this new list. In order to do this, I connected some code to the "current_folder_changed" signal of the FileChooserButton, as in (...) self.btnPasta = self.wTree.get_widget( "btnPasta" ) self.btnPasta.connect( "current_folder_changed", self.mudarPasta ) (...) However, when I use the FileChooserButton btnPasta to choose another folder,nothing happens. I made some tests and it seems that the function mudarPasta is not executed at all. This function is defined inside my class (as other functions that are executed by other signals of other widgets and called as self.): def mudarPasta( filechooser, widget ): novaPasta = filechooser.get_current_folder() PASTA = novaPasta os.chdir( PASTA ) self.popular() Can someone help me? How about this example ? Thanks in advance, Regards Neil. #!/usr/bin/env python # example filechooser.py import pygtk pygtk.require('2.0') import gtk # Check for new pygtk: this is new class in PyGtk 2.4 if gtk.pygtk_version < (2,3,90): print "PyGtk 2.3.90 or later required for this example" raise SystemExit dialog = gtk.FileChooserDialog("Open..", None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) filter = gtk.FileFilter() filter.set_name("All Text files") filter.add_pattern("*.txt") dialog.add_filter(filter) filter = gtk.FileFilter() filter.set_name("All files") filter.add_pattern("*") dialog.add_filter(filter) filter = gtk.FileFilter() filter.set_name("Images") filter.add_mime_type("image/png") filter.add_mime_type("image/jpeg") filter.add_mime_type("image/gif") filter.add_pattern("*.png") filter.add_pattern("*.jpg") filter.add_pattern("*.gif") filter.add_pattern("*.tif") filter.add_pattern("*.xpm") dialog.add_filter(filter) response = dialog.run() if response == gtk.RESPONSE_OK: print dialog.get_filename(), 'selected' elif response == gtk.RESPONSE_CANCEL: print 'Closed, no files selected' dialog.destroy() ___ 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] Newbie question
When you call gtk.glade.XML it creates everything that is in the glade file. Easiest thing to do is to mark your progress window hidden in the glade file, and then to call show() on it when you need it. Geert Geurts wrote: Thank god I knew I was doing something realy strange... ;) The first window get buildup at self.gladefile = "/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade" self.wTree = gtk.glade.XML(self.gladefile) the second window gets buildup at the call to gtk.main()... Below is my program, if you have any comments on the structure, please let me know, I know it's wrong I just don't know WHAT is wrong... I'm a newbie... the program: #!/usr/bin/env python import os,sys import string,re import pdb try: import pygtk pygtk.require("2.0") except: pass try: import gtk import gtk.glade except: sys.exit(1) GLADEFILE = "/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade" class NewCD: """Dit is de gui class als er een nieuwe cd wordt geladen""" def __init__(self): pdb.set_trace() #Set the Glade file self.Artiest='' self.CDNaam='' self.Genre='' self.gladefile = "/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade" self.wTree = gtk.glade.XML(self.gladefile) #Get the Main Window, and connect the events self.window = self.wTree.get_widget("window1") if (self.window): self.window.connect("destroy", gtk.main_quit) dic = { "on_AtriestEntry_changed" : self.ArtiestEntryChanged, "on_CDNaamEntry_changed" : self.CDNaamEntryChanged, "on_GenreEntry_changed" : self.GenreEntryChanged, "on_RipButton_clicked" : self.RipButtonClicked} self.wTree.signal_autoconnect(dic) #Create handler functies def ArtiestEntryChanged(self, widget): self.Artiest=widget.get_text() print "artiest=",self.Artiest def CDNaamEntryChanged(self, widget): self.CDNaam=widget.get_text() print "CDNaam=", self.CDNaam def GenreEntryChanged(self, widget): self.Genre=widget.get_text() print "genre=",self.Genre def RipButtonClicked(self, widget): if self.Artiest=='': print "Artist NOT set!" elif self.CDNaam=='': print "CDNaam NOT set!" elif self.Genre.isdigit()==False: print "Genre NOT set!" else: print "alles ok dus rippen!" self.RIPCD(self.Artiest,self.CDNaam,self.Genre) def RIPCD(self,Artiest,CDNaam,Genre): self.DIR='/tmp/'+self.Artiest+' - '+self.CDNaam self.DESTDIR='/media/data/music/' os.mkdir(self.DIR) os.chdir(self.DIR) os.system('cdparanoia -Bw') files=os.listdir('./') progress=Progress() for file in files: if file.rfind('.wav')!=-1: nummer=re.findall('\d',file) if len(nummer)==3: nr=nummer[0]+nummer[1]+nummer[2] elif len(nummer)==2: nr=nummer[0]+nummer[1] else: nr=nummer[0] os.system('lame --preset cd '+file+' '+nr+'.mp3') os.remove(file) os.system('eyeD3 -a '+self.Artiest+' -A '+self.CDNaam+' -G '+self.Genre+' '+nr+'.mp3') os.chdir('/tmp') os.system('mv '+self.DIR+' '+self.DESTDIR) class Progress: def __init__(self): self.wTree=gtk.glade.XML(GLADEFILE) self.progresswindow = self.wTree.get_widget("window2") if (self.progresswindow): self.progresswindow.connect("destroy", gtk.main_quit) dic = { "on_button1_clicked" : self.ButtonClicked} self.wTree.signal_autoconnect(dic) self.progress=self.wTree.get_widget("progressbar1") self.button=self.wTree.get_widget("button1") def ButtonClicked(self): print "Button Clicked!" if __name__ == "__main__": hwg = NewCD() gtk.main() Thanks for looking!!! Greetings, Geert On Fri, 2008-04-18 at 10:24 +0200, Vláďa wrote: This sounds very strange. Please check your code or post here a simple example. I'm working on an applicati
Re: [pygtk] Newbie question
Thank god I knew I was doing something realy strange... ;) The first window get buildup at self.gladefile = "/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade" self.wTree = gtk.glade.XML(self.gladefile) the second window gets buildup at the call to gtk.main()... Below is my program, if you have any comments on the structure, please let me know, I know it's wrong I just don't know WHAT is wrong... I'm a newbie... the program: #!/usr/bin/env python import os,sys import string,re import pdb try: import pygtk pygtk.require("2.0") except: pass try: import gtk import gtk.glade except: sys.exit(1) GLADEFILE = "/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade" class NewCD: """Dit is de gui class als er een nieuwe cd wordt geladen""" def __init__(self): pdb.set_trace() #Set the Glade file self.Artiest='' self.CDNaam='' self.Genre='' self.gladefile = "/home/geert/Projects/pleintheater_media-server/cd_inserted/cd_inserted.glade" self.wTree = gtk.glade.XML(self.gladefile) #Get the Main Window, and connect the events self.window = self.wTree.get_widget("window1") if (self.window): self.window.connect("destroy", gtk.main_quit) dic = { "on_AtriestEntry_changed" : self.ArtiestEntryChanged, "on_CDNaamEntry_changed" : self.CDNaamEntryChanged, "on_GenreEntry_changed" : self.GenreEntryChanged, "on_RipButton_clicked" : self.RipButtonClicked} self.wTree.signal_autoconnect(dic) #Create handler functies def ArtiestEntryChanged(self, widget): self.Artiest=widget.get_text() print "artiest=",self.Artiest def CDNaamEntryChanged(self, widget): self.CDNaam=widget.get_text() print "CDNaam=", self.CDNaam def GenreEntryChanged(self, widget): self.Genre=widget.get_text() print "genre=",self.Genre def RipButtonClicked(self, widget): if self.Artiest=='': print "Artist NOT set!" elif self.CDNaam=='': print "CDNaam NOT set!" elif self.Genre.isdigit()==False: print "Genre NOT set!" else: print "alles ok dus rippen!" self.RIPCD(self.Artiest,self.CDNaam,self.Genre) def RIPCD(self,Artiest,CDNaam,Genre): self.DIR='/tmp/'+self.Artiest+' - '+self.CDNaam self.DESTDIR='/media/data/music/' os.mkdir(self.DIR) os.chdir(self.DIR) os.system('cdparanoia -Bw') files=os.listdir('./') progress=Progress() for file in files: if file.rfind('.wav')!=-1: nummer=re.findall('\d',file) if len(nummer)==3: nr=nummer[0]+nummer[1]+nummer[2] elif len(nummer)==2: nr=nummer[0]+nummer[1] else: nr=nummer[0] os.system('lame --preset cd '+file+' '+nr+'.mp3') os.remove(file) os.system('eyeD3 -a '+self.Artiest+' -A '+self.CDNaam+' -G '+self.Genre+' '+nr+'.mp3') os.chdir('/tmp') os.system('mv '+self.DIR+' '+self.DESTDIR) class Progress: def __init__(self): self.wTree=gtk.glade.XML(GLADEFILE) self.progresswindow = self.wTree.get_widget("window2") if (self.progresswindow): self.progresswindow.connect("destroy", gtk.main_quit) dic = { "on_button1_clicked" : self.ButtonClicked} self.wTree.signal_autoconnect(dic) self.progress=self.wTree.get_widget("progressbar1") self.button=self.wTree.get_widget("button1") def ButtonClicked(self): print "Button Clicked!" if __name__ == "__main__": hwg = NewCD() gtk.main() Thanks for looking!!! Greetings, Geert On Fri, 2008-04-18 at 10:24 +0200, Vláďa wrote: > This sounds very strange. Please check your code or post here a simple > example. > > I'm working on an application which is similar to your's (but works with > DVDs and video) and everything works fine. > > Vlada > > Geert Geurts napsal(a): > > Hello, > > I'm
Re: [pygtk] Newbie question
This sounds very strange. Please check your code or post here a simple example. I'm working on an application which is similar to your's (but works with DVDs and video) and everything works fine. Vlada Geert Geurts napsal(a): Hello, I'm a newbie trying to get to know pygtk/gtk so my questions might seem stupid... Sorry for that. I'm trying to write a CDrip application using glade/pygtk. I'm now able to write a program making a gui where you can write the artist album info, and the cd is being ripped when you click the button. But I want it to also show a progress window but this second window is shown as soon you start the application altough the second window is in a seperate class and is not initialized before a button click. How come this window is shown before initialisation and how can I control this behaviour? Greetings, Geert ___ 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] Newbie question
Hello, I'm a newbie trying to get to know pygtk/gtk so my questions might seem stupid... Sorry for that. I'm trying to write a CDrip application using glade/pygtk. I'm now able to write a program making a gui where you can write the artist album info, and the cd is being ripped when you click the button. But I want it to also show a progress window but this second window is shown as soon you start the application altough the second window is in a seperate class and is not initialized before a button click. How come this window is shown before initialisation and how can I control this behaviour? Greetings, Geert ___ 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/