From: Daryl F. <fly...@sb...> - 2004-09-07 03:20:30
|
I've been playing with PythonCard for about a week now and I have to say I'm impressed. It seems very well thought out. I do, however, have one issue. I would like to set the text colour of individual items in a list. Right now I'm doing a whole lot of rework just to get around having to do this, but it is becoming fairly difficult at this point. Is this even possible (without doing too much damage)? |
From: Kevin A. <al...@se...> - 2004-09-07 03:51:33
|
On Sep 6, 2004, at 8:19 PM, Daryl Fox wrote: > I've been playing with PythonCard for about a week now and I have to > say I'm > impressed. It seems very well thought out. > > I do, however, have one issue. I would like to set the text colour of > individual items in a list. Right now I'm doing a whole lot of rework > just > to get around having to do this, but it is becoming fairly difficult > at this > point. Is this even possible (without doing too much damage)? > IIRC, I don't think it is supported in the underlying wx.ListBox control used by the List component, but is supported by the wx.ListCtrl which is underneath the MultiColumnList. You can check what the wxWidgets docs say or find what you want to do in the wxPython demo and then you'll have to call the appropriate wxPython methods to set the colors. ka |
From: <gre...@co...> - 2004-09-07 18:59:00
|
Hi, I can't seem to get the word wrap to happen in a textarea. It shows the portion of text that fits in the first row of the textarea but cuts off everything after that. I've included the code I'm using at the end of this email (ignore my email's word-wrapping if possible) Should I remove the existing '\r' s and '\n's from my text, could that be confusing the textarea? Thanks, Greg This is the definition: widgetDefn={'type':'TextArea', 'name':'txt'+ column[0], 'position':(xPosWidget, yPos), 'size':(255*9, NumRows*rowHeight), 'alignment':'left', 'border':'3d', 'editable':False, 'enabled':True, 'text':'', 'toolTip':'Values in this record field', 'visible':True} Here is where it is filled: self.components[item].text=str(row[widgetCount]) And row[widgetCount] text is below: 'I saw a truck today. There was a man with a beard driving it. It had a license plate that said "god". I found myself wondering if god was a ctually in that truck. The man looked kind of non-real. I drove up next to him but he didn\'t see me. Then he turned off onto 95. I really wanted to follow him but he was going south and I have to go north. And besides, we wouldn\'t ha ve a road for him to drive on if everyone spent all their time following him. \r ' |
From: Alex T. <al...@tw...> - 2004-09-07 20:45:40
|
At 15:00 07/09/2004 -0400, Gregory Pi=F1ero wrote: >Hi, > >I can't seem to get the word wrap to happen in a textarea. It shows the=20 >portion of text that fits in the first row of the textarea but cuts off=20 >everything after that. I've included the code I'm using at the end of=20 >this email (ignore my email's word-wrapping if possible) >This is the definition: > widgetDefn=3D{'type':'TextArea', > 'name':'txt'+ column[0], > 'position':(xPosWidget, yPos), > 'size':(255*9, NumRows*rowHeight), That's 2295 pixels wide, so the text below wouldn't need to wrap to fit=20 inside it. note - the text area will NOT be confined to the screen size, or the window= =20 size, or ..... it will be 2295 pixels wide. -- Alex |
From: Daryl F. <fly...@sb...> - 2004-09-09 03:26:24
|
Okay, here's my solution to this. Please note, I'm sure that many other people have better ways, but this works for me. First, the List must become a MultiColumnList. As a bonus, I was able to remove my static text label and use the column label instead. Then each item is applied a wxCOLOR. Below is a simple example. Start up the resourceEditor. For this example, build a new 'Standard Template with File->Exit menu'. Plop down a MultiColumnList and give it the name 'MultiColumnList'. Set it's size to be about 180 x 175. Save the file. The .rsrc.py file should contain the following down near the bottom: {'type':'MultiColumnList', 'name':'MultiColumnList', 'position':(15, 10), 'size':(182, 169), 'backgroundColor':(255, 255, 255), 'columnHeadings':[], 'font':{'faceName': 'Tahoma', 'family': 'sansSerif', 'size': 8}, 'items':[], 'maxColumns':20, 'rules':1, }, Now open up the .py file. and change it to: from PythonCard import model from wx import Colour COLOURS = [Colour(0, 0, 0), Colour(0x66, 0, 0), Colour(0xff, 0, 0), Colour(0xff, 0x99, 0), Colour(0xff, 0xff, 0), Colour(0, 0xff, 0), Colour(0, 0, 0xff), Colour(0x99, 0xff, 0), Colour(0xcc, 0xcc, 0xcc), Colour(0xff, 0xff, 0xff)] class MyBackground(model.Background): def on_initialize(self, event): Items = "Bad Beer Rots Our Young Guts But Vodka Goes Well".split(" ") self.components.MultiColumnList.columnHeadings = "Color Code" self.components.MultiColumnList.items = Items for Item in range(len(self.components.MultiColumnList.items)): self.components.MultiColumnList.SetItemTextColour(Item, COLOURS[Item]) if __name__ == '__main__': app = model.Application(MyBackground) app.MainLoop() Here we build a list of colours called COLOURS. Inside the on_initialize method, the column is given a label and then populated with items. Finally, the for loop goes over each item and sets it's color. Please note, this is just a funny little example. If you populate the list with more items than we have colors Bad Things will happen. I suppose you could do a max of len(Items) and len(COLOURS) if you were worried about that... Hope this helps, -Daryl -----Original Message [With much snippage] ----- From: Kevin Altis Sent: Monday, September 06, 2004 8:51 PM To: Daryl Fox Cc: pyt...@li... Subject: Re: [Pythoncard-users] Color in Lists On Sep 6, 2004, at 8:19 PM, Daryl Fox wrote: [SNIP] > I do, however, have one issue. I would like to set the text colour of > individual items in a list. [SNIP] IIRC, I don't think it is supported in the underlying wx.ListBox control used by the List component, but is supported by the wx.ListCtrl which is underneath the MultiColumnList. You can check what the wxWidgets docs say or find what you want to do in the wxPython demo and then you'll have to call the appropriate wxPython methods to set the colors. ka |
From: Kevin A. <al...@se...> - 2004-09-09 04:24:00
|
Thanks Daryl, just as an FYI you don't have to use the Colour class, wxPython will accept a variety of formats and convert appropriately. You can use the same kind of representations you would in PythonCard. COLOURS = ['black', '#660000', 'red', (255, 0x99, 0), (255, 255, 0), 'green', 'blue', (0x99, 0xff, 0), '#cccccc', 'white'] is equivelant to COLOURS = [Colour(0, 0, 0), Colour(0x66, 0, 0), Colour(0xff, 0, 0), Colour(0xff, 0x99, 0), Colour(0xff, 0xff, 0), Colour(0, 0xff, 0), Colour(0, 0, 0xff), Colour(0x99, 0xff, 0), Colour(0xcc, 0xcc,0xcc), Colour(0xff, 0xff, 0xff)] All of the named colors that wxPython supports as well as their RGB values are defined in wx/lib/colourdb.py. The names are not case-sensitive. ka On Sep 8, 2004, at 8:25 PM, Daryl Fox wrote: > Okay, here's my solution to this. Please note, I'm sure that many > other > people have better ways, but this works for me. > > First, the List must become a MultiColumnList. As a bonus, I was able > to > remove my static text label and use the column label instead. Then > each > item is applied a wxCOLOR. Below is a simple example. > > Start up the resourceEditor. For this example, build a new 'Standard > Template with File->Exit menu'. Plop down a MultiColumnList and give > it the > name 'MultiColumnList'. Set it's size to be about 180 x 175. Save the > file. The .rsrc.py file should contain the following down near the > bottom: > {'type':'MultiColumnList', > 'name':'MultiColumnList', > 'position':(15, 10), > 'size':(182, 169), > 'backgroundColor':(255, 255, 255), > 'columnHeadings':[], > 'font':{'faceName': 'Tahoma', 'family': 'sansSerif', 'size': 8}, > 'items':[], > 'maxColumns':20, > 'rules':1, > }, > > Now open up the .py file. and change it to: > > from PythonCard import model > from wx import Colour > > COLOURS = [Colour(0, 0, 0), Colour(0x66, 0, 0), Colour(0xff, > 0, 0), > Colour(0xff, 0x99, 0), Colour(0xff, 0xff, 0), Colour(0, > 0xff, 0), > Colour(0, 0, 0xff), Colour(0x99, 0xff, 0), Colour(0xcc, > 0xcc, > 0xcc), > Colour(0xff, 0xff, 0xff)] > > class MyBackground(model.Background): > def on_initialize(self, event): > Items = "Bad Beer Rots Our Young Guts But Vodka Goes > Well".split(" ") > self.components.MultiColumnList.columnHeadings = "Color Code" > self.components.MultiColumnList.items = Items > > for Item in range(len(self.components.MultiColumnList.items)): > self.components.MultiColumnList.SetItemTextColour(Item, > COLOURS[Item]) > > if __name__ == '__main__': > app = model.Application(MyBackground) > app.MainLoop() > > Here we build a list of colours called COLOURS. Inside the > on_initialize > method, the column is given a label and then populated with items. > Finally, > the for loop goes over each item and sets it's color. Please note, > this is > just a funny little example. If you populate the list with more items > than > we have colors Bad Things will happen. I suppose you could do a max of > len(Items) and len(COLOURS) if you were worried about that... > > Hope this helps, > -Daryl > > > -----Original Message [With much snippage] ----- > From: Kevin Altis > Sent: Monday, September 06, 2004 8:51 PM > To: Daryl Fox > Cc: pyt...@li... > Subject: Re: [Pythoncard-users] Color in Lists > > On Sep 6, 2004, at 8:19 PM, Daryl Fox wrote: > > [SNIP] >> I do, however, have one issue. I would like to set the text colour of >> individual items in a list. > [SNIP] > > IIRC, I don't think it is supported in the underlying wx.ListBox > control used by the List component, but is supported by the wx.ListCtrl > which is underneath the MultiColumnList. You can check what the > wxWidgets docs say or find what you want to do in the wxPython demo and > then you'll have to call the appropriate wxPython methods to set the > colors. > > ka > > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > |