Re: [pygtk] set_sensitive gray-out too extreme for gtk.Entry
george young wrote: [python-2.2.1, gtk-2.1.1 pygtk-1.99.14, linux] How can I change the grey background of an insensitive gtk.Entry? I tried: self.entry = gtk.Entry() map=self.entry.get_colormap() red=map.alloc('red') style=self.entry.get_style().copy() style.bg[gtk.STATE_INSENSITIVE] = red self.entry.set_style(style) from the FAQ, but it seemed to have no effect. Trying to set the foreground color likewise had no effect... I need the insensitive entry to be a much lighter grey (or the foreground to be a full black) because it's too hard to read. This widget gets dynamically switched between writable and read-only during the session. But even when read-only, it needs to be easily and clearly readable. I could just manipulate 'editable', but then it still accepts the focus and frustrates people who try to type at it. Trying to change the default appearance like this can actually be harmful when you take theming into account. If you don't like the way the insensitive widgets are displayed, I suggest you try using another theme. In your code above, consider what would happen if the text in insenstive widgets as red on black (as an example). Your code would reduce the readability even further (this is a fairly contrived example, but some of the accessibility themes are fairly different to the standard gtk theme and such a change could have a similar effect). If you understand these problems, the way to fix your code is to set style.base rather than style.bg. The style colours fg/bg are used for user interface elements such as labels (usually black on grey). For things like entries (usually black on white), the colours text/base are used. James. -- Email: [EMAIL PROTECTED] | Linux.conf.au http://linux.conf.au/ WWW: http://www.daa.com.au/~james/ | Jan 22-25 Perth, Western Australia. ___ 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] set_sensitive gray-out too extreme for gtk.Entry
[python-2.2.1, gtk-2.1.1 pygtk-1.99.14, linux] How can I change the grey background of an insensitive gtk.Entry? I tried: self.entry = gtk.Entry() map=self.entry.get_colormap() red=map.alloc('red') style=self.entry.get_style().copy() style.bg[gtk.STATE_INSENSITIVE] = red self.entry.set_style(style) from the FAQ, but it seemed to have no effect. Trying to set the foreground color likewise had no effect... I need the insensitive entry to be a much lighter grey (or the foreground to be a full black) because it's too hard to read. This widget gets dynamically switched between writable and read-only during the session. But even when read-only, it needs to be easily and clearly readable. I could just manipulate 'editable', but then it still accepts the focus and frustrates people who try to type at it. -- George -- I cannot think why the whole bed of the ocean is not one solid mass of oysters, so prolific they seem. Ah, I am wandering! Strange how the brain controls the brain! -- Sherlock Holmes in "The Dying Detective" ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Pango and french
Le 14 Jan 2003 20:56:12 -0200 Johan Dahlin <[EMAIL PROTECTED]> écrivait : > tis 2003-01-14 klockan 21.49 skrev mc collilieux: > Before inserting data into the liststore, convert them to utf-8. > > First you need to convert to a unicode object, this can be done like > this: > obj = unicode(some_string, 'latin-1') > > Then you can convert it to utf-8: > > utf8string = obj.encode('utf-8') > > and that string is what you should insert into your model > (GtkListStore/GtkTreeStore) > > -- > Johan Dahlin <[EMAIL PROTECTED]> > Async Open Source Yes, its works, greats thanks and now i can search how play with output look Fun of time zone : you have responded before i send my question :-) -- Marie-Claude Collilieux Bretagne ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] instance.__dict__ disappears with many widgets
I'm guessing that your ColorWidgets are somehow losing info because of loss of references in python but I don't understand how PyGTK handles memory in conjunction with python. I fiddled with your test program and added a list of ColorWdigets to the StyleBox instance - this seemed to fix things but I don't know exactly why. It's a hack but may be a workaround. John Ava Arachne Jarvis wrote: I'm using python 2.2 and pygtk 1.99.14, gtk 2.2.0 and friends. I'm running across an odd problem when I use a large number of widgets, and some of them are ones that inherit from original gtk widgets. When first created, these objects seem intact; however, the first time a signal callback is called, the objects' attribute dictionaries are empty. I'm attaching a version of the program that I stripped down to about 50 lines. Instruction for running this: python stripped.py #!/usr/bin/python import pygtk pygtk.require('2.0') import gtk, sys, string class ColorWidget(gtk.Button): def __init__(self, stylebox): gtk.Button.__init__(self) self.stylebox = stylebox self.color = gtk.gdk.color_parse('white') self.set_size_request(30, 30) self.connect("clicked", self.setColor) def setBackground(self, gdkcolor = None): if gdkcolor: self.color = gdkcolor for state in [gtk.STATE_ACTIVE, gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_SELECTED]: self.modify_bg(state, self.color) def setColor(self, w): print '__dict__:', self.__dict__ self.setBackground(self.stylebox.getColor(self.color)) class StyleBox(gtk.Window): def __init__(self, numwidgets = 10): gtk.Window.__init__(self) self.connect("destroy", lambda w: gtk.main_quit()) self.widgets = [] self.cdg = gtk.ColorSelectionDialog('Select Color') self.notebook = gtk.Notebook() self.notebook.set_show_tabs(0) self.add(self.notebook) for i in range(0, numwidgets): self.createTestPanel() def getColor(self, prev_color = None): if prev_color: self.cdg.colorsel.set_current_color(prev_color) color = None if self.cdg.run() == gtk.RESPONSE_OK: color = self.cdg.colorsel.get_current_color() self.cdg.hide() return color def createTestPanel(self): panel = gtk.Frame() self.notebook.append_page(panel, gtk.Label('Test')) w = ColorWidget(self) self.widgets.append(w) panel.add(w) s = StyleBox(string.atoi(sys.argv[1])) s.show_all() gtk.main()
[pygtk] PyGTK and python 2.3a1
Hello, I installed gnome-python-1.4.4 with python 2.3a1. The is a problem with pygtk.require: >python Python 2.3a1 (#1, Jan 9 2003, 22:40:56) [GCC 3.2 (SuSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pygtk [16716 refs] >>> pygtk.require("1.2") Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.3/site-packages/pygtk.py", line 47, in require versions = _get_available_versions() File "/usr/local/lib/python2.3/site-packages/pygtk.py", line 34, in _get_available_versions for filename in os.listdir(dir): OSError: [Errno 2] No such file or directory: '/usr/local/lib/python23.zip' [16778 refs] >>> import pdb [23675 refs] >>> pdb.pm() > /usr/local/lib/python2.3/site-packages/pygtk.py(34)_get_available_versions() -> for filename in os.listdir(dir): (Pdb) dir '/usr/local/lib/python23.zip' (Pdb) sys.path ['', '/usr/local/lib/python23.zip', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2', '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload', '/usr/local/lib/python2.3/site-packages', '/usr/local/lib/python2.3/site-packages/Numeric', '/usr/local/lib/python2.3/site-packages/gtk-1.2'] (Pdb) require fails with the new import hook mechanism and the standard posibility to use .ZIP archives on the import path. Greetings Berthold -- [EMAIL PROTECTED] / http://starship.python.net/crew/bhoel/ It is unlawful to use this email address for unsolicited ads (USC Title 47 Sec.227). I will assess a US$500 charge for reviewing and deleting each unsolicited ad. ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Pythonian class instances inside a TreeModel
ons 2003-01-15 klockan 13.05 skrev Roberto Cavada: > Hi, >the GTK+ FAQ states that user-defined data can be stored inside a > GtkTreeModel via a hidden column. > How can I associate each row in the TreeModel with a user-defined > python class instance? If I use an hidden column in the model, what's > the type for that column? Add another row in the Model, but don't assign a TreeViewColumn too it. for example: COLUMN_NAME=0 COLUMN_ADDRESS=1 COLUMN_PHONE=2 COLUMN_DATA=3 model = gtk.ListStore(gobject.TYPE_STRING, # name gobject.TYPE_STRING, # address gobject.TYPE_INT, # phone number gobject.TYPE_PYOBJECT) # custom ... Create TreeViewColumn for all columns except the last ... iter = model.append() model.set(iter, COLUMN_NAME, "John Doe", COLUMN_ADDRESS, "Foostreet 12", COLUMN_PHONE, "12345678", COLUMN_DATA, custom) (and model.get(iter, COLUMN_DATA) to retrieve) custom can here be any kind of object in Python (string, int, float, class/type instance etc) -- Johan Dahlin <[EMAIL PROTECTED]> Async Open Source ___ 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] RFC: Hooks for class creation process
Hi, I would like to create hooks for the class creation routines. Normally a new (GObject) class is created when gobject.type_register() is called. It would be nice if other modules can add hooks, so interfaces can be initiated and stuff like that. For example: class MyClass(GObject, TreeModel): def __init__(self): pass would be possible. Of course GObject can be replaced by any GObject class. The module's init function should register its hook: g_object_type_register_hook (PyType_GtkTreeModel, type_register_callback); If one of the base classes is GtkTreeModel, call type_register_callback. This can also be done if some extra initialization is required for specific classes. (For example DIaCanvas: it uses some extra code to set up callbacks for things like an update handler.) The callback should look like this: Callback (GtkTypeObject *class, GType instance_type); Where class is the Python class object and instance_type is the accompanying GType. I'd like to have some comments. Regards, Arjan ___ 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] Pythonian class instances inside a TreeModel
Hi, the GTK+ FAQ states that user-defined data can be stored inside a GtkTreeModel via a hidden column. How can I associate each row in the TreeModel with a user-defined python class instance? If I use an hidden column in the model, what's the type for that column? Thanks, rob ___ 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-WARNING **: Whoever translated default:LTR did so wrongly
somebody knows what is this warning and as is solved? Python 2.2.2 (#1, Jan 3 2003, 12:42:27) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pygtk >>> pygtk.require("2.0") >>> import gtk (:10215): Gtk-WARNING **: Whoever translated default:LTR did so wrongly. >>> thanks! ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] more "interesting" behavior with selections, treeviewsand scrolling
On Wed, 2003-01-15 at 06:33, David M. Cook wrote: > On Tue, Jan 14, 2003 at 10:20:32PM +, Andrew S. Townley wrote: > > This time I've included an example of what I'm trying to do. It serves > > to illustrate both my previous "double selection signal" issue as well > > as something different. > > One thing is that you're passing an integer as a path when (I think) you > should be passing in a tuple (but pygtk doesn't seem to mind ). > However, using a tuple doesn't seem to make a difference. That's actually from my mis-reading the docs of GtkTreeModel. I thought I read that it would automatically cast. Thanks for pointing it out, I'll fix it. > > To watch the first one, make sure the checkbox isn't checked, then click > > load. Choose a row, say the 4th one, and you'll see the double signals. > > I think this is the correct behavior for the first time something is selected. > But then I'm never sure what the intentions of the gtk authors really are. > If that's really the indented behavior, it seems pretty strange. I know from the docs of the GtkTreeSelection, it says that the "changed" signal is only a hint, but it seems like in order to have your application "do the right thing" you've got to write a lot of extra code to determine if there's been a previous tree selection or not so that you can ignore the very first changed signal that gets emitted by the control after it is loaded. From reading some of the other posts to this list about tree selection, it seems like the selection support in the new widget is pretty basic, and if you want to do something complicated, you've got to manage state information that is normally managed by the control in other toolkits. One other thing that I thought was interesting when I was putting together the previous test is that the control seems to ignore the unselect_all() method. If the TreeView is the only control in a window, the first row is *always* selected, even though attempting to walk the selection with selection_foreach() results in no method calls. Maybe that's the source of the problem. Guess it could be a bug in the control that unselect_all() only changes part of the state. If that was the case, why would the control not draw the selection when there are other widgets in the window? Seems pretty strange to me... -- Andrew S. Townley <[EMAIL PROTECTED]> signature.asc Description: This is a digitally signed message part
Re: [pygtk] GtkClipboard
Johan Dahlin wrote: tis 2003-01-14 klockan 23.51 skrev John Finlay: These aren't implemented in PyGTK 1.99.x - what's the reason? Are they likely to be implemented in the future? A comment in gtk-types.defs seems to indicate GTK+ 2.2. I think it's mainly because missing GTK_TYPE_* defines/macros that's missing in GTK 2.0. They will be added when we branch for 2.2. Only james know when. In my opinion it should not be before 2.0 is released, it should be shortly afterwards I was originally putting off wrapping GtkClipboard til it got assigned a GType. I bugged owen about it, but nothing happened for the 2.0 release because he wasn't sure what type he wanted it to be (in 2.0, it is an opaque pointer type). In 2.2, GtkClipboard is a GObject, so it isn't so much of a problem. We should probably add a cheesy binding for GtkClipboard for the 2.0 branch of pygtk (when we branch for 2.2, the binding will be simple). James. -- Email: [EMAIL PROTECTED] | Linux.conf.au http://linux.conf.au/ WWW: http://www.daa.com.au/~james/ | Jan 22-25 Perth, Western Australia. ___ 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] Question bout image possitioning in PyGTK
Hello, I got a question bout possitioning images on the surface of the widget. I'd like to load an image to a widget and then display a few littler images on it. Is it possible, using Pygtk, to set an exact possition of them? regards, Kender -- Pawel J. Maczewski @ HIL reg.linux user #281878 ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] custom CellRendererText
ons 2003-01-15 klockan 09.25 skrev David M. Cook: > Has anyone tried to create their own custom cell renderer in python? > In particular, I'd like to extend CellRendererText so I can add signals to > the CellEditable. But it looks like I'd have to reimplement lots of > CellRendererText in python. > Guilty of charge. Evidence attached. It's a mockup of a GtkRendererToggle. But it might be a good starting point if you want to write your own. -- Johan Dahlin <[EMAIL PROTECTED]> Async Open Source import pygtk pygtk.require('2.0') import gtk from gtk import TRUE, FALSE import gobject TOGGLE_WIDTH = 12 class MyCellRenderer(gtk.GenericCellRenderer): def __init__(self): self.__gobject_init__() self.xpad = -2; self.ypad = -2 self.xalign = 0.5; self.yalign = 0.5 self.active = 0 def on_render(self, window, widget, background_area, cell_area, expose_area, flags): x_offset, y_offset, width, height = self.on_get_size(widget, cell_area) width -= self.xpad*2 height -= self.ypad*2 #if width <= 0 or height <= 0: #return widget.style.paint_check(window, gtk.STATE_ACTIVE, gtk.SHADOW_IN, cell_area, widget, "cellradio", cell_area.x + x_offset + self.xpad, cell_area.y + y_offset + self.ypad, width - 1, height - 1) def on_get_size(self, widget, cell_area): calc_width = self.xpad * 2 + TOGGLE_WIDTH calc_height = self.ypad * 2 + TOGGLE_WIDTH if cell_area: x_offset = self.xalign * (cell_area.width - calc_width) x_offset = max(x_offset, 0) y_offset = self.yalign * (cell_area.height - calc_height) y_offset = max(y_offset, 0) else: x_offset = 0 y_offset = 0 return calc_width, calc_height, x_offset, y_offset gobject.type_register(MyCellRenderer) class Tree(gtk.TreeView): def __init__(self): self.store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) gtk.TreeView.__init__(self) self.set_size_request(300, 200) self.set_model(self.store) self.set_headers_visible(TRUE) rend = gtk.CellRendererText() column = gtk.TreeViewColumn('First', rend, text=0) self.append_column(column) rend = MyCellRenderer() column = gtk.TreeViewColumn('Second', rend) self.append_column(column) def insert(self, name): iter = self.store.append() self.store.set(iter, 0, name) w = gtk.Window() w.set_position(gtk.WIN_POS_CENTER) w.connect('delete-event', gtk.mainquit) t = Tree() t.insert('foo') t.insert('bar') t.insert('baz') w.add(t) w.show_all() gtk.main()
Re: [pygtk] Problems with gdkpixbuf
On Tue, Jan 14, 2003 at 10:52:50PM -0600, Robert Lowe wrote: > images from files. So I looked in the faq and it said to import a > module called gdkpixbuf. Now, when I attempt this, python cannot find The gdkpixbuf module was a PyGTK-1 hint. I've updated the FAQ: http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq08.002.htp Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GtkClipboard
tis 2003-01-14 klockan 23.51 skrev John Finlay: > These aren't implemented in PyGTK 1.99.x - what's the reason? Are they > likely to be implemented in the future? A comment in gtk-types.defs > seems to indicate GTK+ 2.2. I think it's mainly because missing GTK_TYPE_* defines/macros that's missing in GTK 2.0. They will be added when we branch for 2.2. Only james know when. In my opinion it should not be before 2.0 is released, it should be shortly afterwards -- Johan Dahlin <[EMAIL PROTECTED]> Async Open Source ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] instance.__dict__ disappears with many widgets
[Ava Arachne Jarvis - Wed, 15 Jan 2003 05:25:54 AM CST] > I'm attaching a version of the program that I stripped down to about 50 > lines. Instruction for running this: It would help if I attached the program. Heh. Sorry. -- | BOFH excuse #105: | | UPS interrupted the server's power #!/usr/bin/python import pygtk pygtk.require('2.0') import gtk, sys, string class ColorWidget(gtk.Button): def __init__(self, stylebox): gtk.Button.__init__(self) self.stylebox = stylebox self.color = gtk.gdk.color_parse('white') self.set_size_request(30, 30) self.connect("clicked", self.setColor) def setBackground(self, gdkcolor = None): if gdkcolor: self.color = gdkcolor for state in [gtk.STATE_ACTIVE, gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_SELECTED]: self.modify_bg(state, self.color) def setColor(self, w): print '__dict__:', self.__dict__ self.setBackground(self.stylebox.getColor(self.color)) class StyleBox(gtk.Window): def __init__(self, numwidgets = 10): gtk.Window.__init__(self) self.connect("destroy", lambda w: gtk.main_quit()) self.cdg = gtk.ColorSelectionDialog('Select Color') self.notebook = gtk.Notebook() self.notebook.set_show_tabs(0) self.add(self.notebook) for i in range(0, numwidgets): self.createTestPanel() def getColor(self, prev_color = None): if prev_color: self.cdg.colorsel.set_current_color(prev_color) color = None if self.cdg.run() == gtk.RESPONSE_OK: color = self.cdg.colorsel.get_current_color() self.cdg.hide() return color def createTestPanel(self): panel = gtk.Frame() self.notebook.append_page(panel, gtk.Label('Test')) panel.add(ColorWidget(self)) s = StyleBox(string.atoi(sys.argv[1])) s.show_all() gtk.main()
[pygtk] custom CellRendererText
Has anyone tried to create their own custom cell renderer in python? In particular, I'd like to extend CellRendererText so I can add signals to the CellEditable. But it looks like I'd have to reimplement lots of CellRendererText in python. I suppose the other option would be to modify the C code and wrap it by copying what's done in pygtk for CellRendererText (hopefully it's that simple). The reason I need to do this is that I want to be able to pop up a menu based on what cell the user is editing. get_cursor() does not seem to be the solution that I was hoping for: http://bugzilla.gnome.org/show_bug.cgi?id=100973 Dave Cook ___ 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] instance.__dict__ disappears with many widgets
I'm using python 2.2 and pygtk 1.99.14, gtk 2.2.0 and friends. I'm running across an odd problem when I use a large number of widgets, and some of them are ones that inherit from original gtk widgets. When first created, these objects seem intact; however, the first time a signal callback is called, the objects' attribute dictionaries are empty. I'm attaching a version of the program that I stripped down to about 50 lines. Instruction for running this: python stripped.py Basically, this program makes a bunch of notebook pages, each with a button that lets you set its color (the notebook tabs are hidden so that the thing isn't huge). The clicked signal callback prints out the object's attribute dictionary and then attempts to set the color via calling the dialog, which belongs to the main window. Compare 'python stripped.py 10' versus 'python stripped.py 80'. 80 color buttons is an extravagant amount, but 80 widgets of various types is not so extravagant. I'm definitely not running out of memory; nor am I using threads in my own code. I've searched the PyGTK FAQ for 'many widgets', 'inheritance', 'subclass', and 'ExtensionClass' (from browsing search results from the mailing list) but I didn't find an answer. Is this a known problem, and is there a workaround? Or am I just doing something wrong? Thanks. -- | Lackland's Laws: | (1) Never be first. (2) Never be last. (3) Never volunteer | for anything ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Problems with gdkpixbuf
Robert Lowe wrote: What would a valid code snippet look like that was using pygtk to load an image file? Try: pixbuf = gtk.gdk.pixbuf_new_from_file(imagefilename) John ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/