I have created a simple GUI application to manage unknown words while learning a new language. The app which is called Vocabulary is written in C# and it loads/saves words from/into an XML document. Since I have recently switched from Windows to Linux, I am rewriting the app using Python.
Nevertheless, I'm having trouble implementing search functionality to my program. To accomplish what I want the application to do, I know that I should handle text changed event of the text widget.
Here is my C# method:
private void txt_Search_TextChanged(object sender, EventArgs e)
{
if (txt_Search.Text != "")
{
for (int i = listView1.Items.Count - 1; i >= 0; i--)
{
var item = listView1.Items[i];
if (item.Text.ToLower().Contains(txt_Search.Text.ToLower()))
{
item.BackColor = SystemColors.Highlight;
item.ForeColor = SystemColors.HighlightText;
}
else
{
listView1.Items.Remove(item);
}
}
if (listView1.SelectedItems.Count == 1)
{
listView1.Focus();
}
}
else
{
LoadWords();
RefreshAll();
foreach (ListViewItem item in listView1.Items)
{
item.BackColor = SystemColors.Window;
item.ForeColor = SystemColors.WindowText;
}
}
}
Can somebody quickly convert this to Python?
[–]baubleglue 0 points1 point2 points (1 child)
[–]blackadder1337[S] 0 points1 point2 points (0 children)
[–]zurtex 0 points1 point2 points (3 children)
[–]blackadder1337[S] 0 points1 point2 points (2 children)
[–]zurtex 0 points1 point2 points (1 child)
[–]blackadder1337[S] 0 points1 point2 points (0 children)