Hi,
Is it possible to have different items in a listbox in different
colors? Or is it just one color for all items in a listbox?
Thanks
Rahul 6 20038
On May 29, 12:02 pm, rahulna...@yaho o.com wrote:
Hi,
Is it possible to have different items in a listbox in different
colors? Or is it just one color for all items in a listbox?
Thanks
Rahul
Looks like it has to be the same color and font: http://www.pythonware.com/library/tk...on/listbox.htm
Maybe there's a custom listbox in the PMW or Tix modules?
It would appear that wxPython has a control that does allow different
colors (and likely, fonts) called wx.HtmlListBox. I assume it would
allow any kind of html, although I've never played with it for sure.
The demo seems to imply that though.
Mike
<ra********@yah oo.comwrote:
Hi,
Is it possible to have different items in a listbox in different
colors? Or is it just one color for all items in a listbox?
Thanks
Rahul
You specify text and foreground colour when you make the box,
so I don't think its possible.
- Hendrik
On Tue, 29 May 2007 19:02:03 +0200, <ra********@yah oo.comwrote:
Hi,
Is it possible to have different items in a listbox in different
colors? Or is it just one color for all items in a listbox?
Thanks
Rahul
AFAIK, this is not possible with a listbox. You can however quite easily
emulate the behaviour of a listbox with a text widget, which allows to mix
fonts and colors in any way you like.
I did it once by creating a sub-class of Tkinter.Text (cannot post the
code here - closed source, sorry...) and all I had to do was:
- make sure the text widget had its state to DISABLED all the time, except
when modifying it;
- removing all the bindings defined in the text widgets (use
widget.bind_cla ss('Text') to get all the events, then widget.bind(eve nt,
lambda e: 'break') to remove them);
- define a new binding for a button click selecting the line under the
cursor;
- define the insert, delete and getcurselection methods, taking care of
treating the special index END.
All in all, this was just a few dozen lines.
HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"
On May 29, 2:02 pm, rahulna...@yaho o.com wrote:
Hi,
Is it possible to havedifferentit ems in alistboxindiffe rentcolors? Or is it justonecolor for all items in alistbox?
Thanks
Rahul
from Tkinter import *
root = Tk()
l = Listbox(root)
l.pack()
for x in range(10):
l.insert(END, x)
l.itemconfig(2, bg='red', fg='white')
l.itemconfig(4, bg='green', fg='white')
l.itemconfig(5, bg='cyan', fg='white')
root.mainloop()
You can _only_ configurate 'background', 'foreground',
'selectbackgrou nd', 'selectforegrou d', not font :(
HTH
On May 30, 6:04 am, rfg...@gmail.co m wrote:
On May 29, 2:02 pm, rahulna...@yaho o.com wrote:
Hi,
Is it possible to havedifferentit ems in alistboxindiffe rentcolors? Or is it justonecolor for all items in alistbox?
Thanks
Rahul
from Tkinter import *
root = Tk()
l = Listbox(root)
l.pack()
for x in range(10):
l.insert(END, x)
l.itemconfig(2, bg='red', fg='white')
l.itemconfig(4, bg='green', fg='white')
l.itemconfig(5, bg='cyan', fg='white')
root.mainloop()
You can _only_ configurate 'background', 'foreground',
'selectbackgrou nd', 'selectforegrou d', not font :(
HTH
Thanks for the feedback all. I tried the itemconfig method and it
works great.
Thanks
<rf****@gmail.c omwrote:
On May 29, 2:02 pm, rahulna...@yaho o.com wrote:
Hi,
Is it possible to havedifferentit ems in alistboxindiffe rentcolors? Or is it
justonecolor for all items in alistbox?
Thanks
Rahul
from Tkinter import *
root = Tk()
l = Listbox(root)
l.pack()
for x in range(10):
l.insert(END, x)
l.itemconfig(2, bg='red', fg='white')
l.itemconfig(4, bg='green', fg='white')
l.itemconfig(5, bg='cyan', fg='white')
root.mainloop()
You can _only_ configurate 'background', 'foreground',
'selectbackgrou nd', 'selectforegrou d', not font :(
Live and learn, - was not aware you could do this - thanks, nice one.
- Hendrik This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matt |
last post by:
I'm having problems changing the text colors in an edit box in my program.
Here's what I'm trying to do, under WM_CREATE I have the following:
ClockFace = CreateWindowEx(0,
"EDIT",
"0.0.00",
WS_CHILD|WS_VISIBLE|WS_BORDER,
125,
75,
300,
|
by: RickDee |
last post by:
Does anybody know how to display different color text inside ListBox ? I was
testing it with CreateGraphics and DrawString methods, but it does not work
out.
Thanks
Regards
|
by: Nenad Dobrilovic |
last post by:
Hi,
can I have two lines with different colors in Windows ListBox control?
Thank you in advance,
Cheya
|
by: tlyczko |
last post by:
Hello, I've searched on toggling divs and didn't really find what I was
looking for, I saved a bunch of different threads.
I have a form with several different text boxes for things like dates,
numbers, etc. arranged in a table, each row has the same kind of text
boxes for data entry (10 rows probably).
I want to have a separate section above the form where I can toggle a
div containing an appropriate error message to appear after the...
|
by: vincent90152900 |
last post by:
How to pop up different text base on the selected TreeNode?
I want to pop up different Text base on the selected TreeNode of the TreeView component. So, I create a TreeView and a ModalPopupExtender. Following is my codes.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
<Nodes>...
| |
by: Gerardo ARnaez |
last post by:
Hi.
I am writing a program to help determine coumadin regimens
to look at the code: http://sourceforge.net/projects/coumadinregimen/
The issue is that I have a variable that I want the use to select if
they don't like the default.
I have made this as a listbox widget
The rest of the gui is just entry widgets
|
by: gnosys |
last post by:
In ASP.Net 1.1 using C#, I'm trying to dynamically change the
background colors of certain listbox items based on some criteria. For
example:
|
by: Patrick McGilla |
last post by:
I would like to use different link colors at different places on the same web page. Using CSS, I can't seem to differentiateand even tried using div statements to separate. Anyone got an idea?
Patrick
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |